From 3d57e14df7ba5f14a634295caf3b2e60da50bfe2 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Fri, 6 Sep 2019 16:31:13 -0700 Subject: Remove windows python distribution from repo and add requirements.txt --- python/gevent/__greenlet_primitives.cp36-win32.pyd | Bin 41984 -> 0 bytes python/gevent/__greenlet_primitives.pxd | 44 - python/gevent/__hub_local.cp36-win32.pyd | Bin 40960 -> 0 bytes python/gevent/__hub_local.pxd | 17 - python/gevent/__hub_primitives.cp36-win32.pyd | Bin 96256 -> 0 bytes python/gevent/__hub_primitives.pxd | 69 - python/gevent/__ident.cp36-win32.pyd | Bin 37888 -> 0 bytes python/gevent/__ident.pxd | 26 - python/gevent/__imap.cp36-win32.pyd | Bin 69120 -> 0 bytes python/gevent/__imap.pxd | 45 - python/gevent/__init__.py | 178 - python/gevent/__semaphore.cp36-win32.pyd | Bin 76800 -> 0 bytes python/gevent/__semaphore.pxd | 54 - python/gevent/__tracer.cp36-win32.pyd | Bin 71680 -> 0 bytes python/gevent/__tracer.pxd | 43 - python/gevent/__waiter.cp36-win32.pyd | Bin 62976 -> 0 bytes python/gevent/__waiter.pxd | 48 - python/gevent/_compat.py | 160 - python/gevent/_config.py | 709 - python/gevent/_event.cp36-win32.pyd | Bin 105984 -> 0 bytes python/gevent/_event.pxd | 77 - python/gevent/_ffi/__init__.py | 27 - python/gevent/_ffi/callback.py | 58 - python/gevent/_ffi/loop.py | 709 - python/gevent/_ffi/watcher.py | 641 - python/gevent/_fileobjectcommon.py | 275 - python/gevent/_fileobjectposix.py | 320 - python/gevent/_greenlet.cp36-win32.pyd | Bin 194048 -> 0 bytes python/gevent/_greenlet.pxd | 174 - python/gevent/_greenlet_primitives.c | 6042 ----- python/gevent/_greenlet_primitives.py | 74 - python/gevent/_hub_local.c | 5720 ----- python/gevent/_hub_local.py | 101 - python/gevent/_hub_primitives.c | 11875 --------- python/gevent/_hub_primitives.py | 371 - python/gevent/_ident.c | 5407 ----- python/gevent/_ident.py | 84 - python/gevent/_imap.c | 10490 -------- python/gevent/_imap.py | 227 - python/gevent/_interfaces.py | 220 - python/gevent/_local.cp36-win32.pyd | Bin 105984 -> 0 bytes python/gevent/_local.pxd | 113 - python/gevent/_monitor.py | 325 - python/gevent/_patcher.py | 127 - python/gevent/_queue.cp36-win32.pyd | Bin 171520 -> 0 bytes python/gevent/_queue.pxd | 74 - python/gevent/_semaphore.c | 10292 -------- python/gevent/_semaphore.py | 303 - python/gevent/_socket2.py | 473 - python/gevent/_socket3.py | 756 - python/gevent/_socketcommon.py | 382 - python/gevent/_ssl2.py | 441 - python/gevent/_ssl3.py | 712 - python/gevent/_sslgte279.py | 714 - python/gevent/_tblib.py | 432 - python/gevent/_threading.py | 168 - python/gevent/_tracer.c | 9571 -------- python/gevent/_tracer.py | 179 - python/gevent/_util.py | 178 - python/gevent/_util_py2.py | 23 - python/gevent/_waiter.c | 8782 ------- python/gevent/_waiter.py | 204 - python/gevent/ares.py | 10 - python/gevent/backdoor.py | 210 - python/gevent/baseserver.py | 404 - python/gevent/builtins.py | 135 - python/gevent/core.py | 20 - python/gevent/event.c | 13439 ----------- python/gevent/event.py | 481 - python/gevent/events.py | 480 - python/gevent/exceptions.py | 79 - python/gevent/fileobject.py | 61 - python/gevent/greenlet.c | 24050 ------------------- python/gevent/greenlet.py | 944 - python/gevent/hub.py | 733 - python/gevent/libev/__init__.py | 0 python/gevent/libev/_corecffi_build.py | 75 - python/gevent/libev/_corecffi_cdef.c | 243 - python/gevent/libev/_corecffi_source.c | 69 - python/gevent/libev/callbacks.c | 216 - python/gevent/libev/callbacks.h | 38 - python/gevent/libev/corecext.c | 22963 ------------------ python/gevent/libev/corecext.cp36-win32.pyd | Bin 209920 -> 0 bytes python/gevent/libev/corecext.h | 147 - python/gevent/libev/corecext.pyx | 1340 -- python/gevent/libev/corecffi.py | 418 - python/gevent/libev/libev.h | 100 - python/gevent/libev/libev.pxd | 235 - python/gevent/libev/libev_vfd.h | 225 - python/gevent/libev/stathelper.c | 187 - python/gevent/libev/watcher.py | 282 - python/gevent/libuv/__init__.py | 0 python/gevent/libuv/_corecffi.cp36-win32.pyd | Bin 125952 -> 0 bytes python/gevent/libuv/_corecffi_build.py | 253 - python/gevent/libuv/_corecffi_cdef.c | 393 - python/gevent/libuv/_corecffi_source.c | 181 - python/gevent/libuv/loop.py | 601 - python/gevent/libuv/watcher.py | 732 - python/gevent/local.c | 13741 ----------- python/gevent/local.py | 605 - python/gevent/lock.py | 263 - python/gevent/monkey.py | 1079 - python/gevent/os.py | 510 - python/gevent/pool.py | 667 - python/gevent/pywsgi.py | 1545 -- python/gevent/queue.c | 22127 ----------------- python/gevent/queue.py | 685 - python/gevent/resolver/__init__.py | 103 - python/gevent/resolver/ares.py | 357 - python/gevent/resolver/blocking.py | 41 - python/gevent/resolver/cares.c | 15233 ------------ python/gevent/resolver/cares.cp36-win32.pyd | Bin 154112 -> 0 bytes python/gevent/resolver/cares.pyx | 464 - python/gevent/resolver/cares_ntop.h | 7 - python/gevent/resolver/cares_pton.h | 8 - python/gevent/resolver/dnshelper.c | 159 - python/gevent/resolver/dnspython.py | 662 - python/gevent/resolver/libcares.pxd | 109 - python/gevent/resolver/thread.py | 71 - python/gevent/resolver_ares.py | 10 - python/gevent/resolver_thread.py | 10 - python/gevent/select.py | 286 - python/gevent/server.py | 282 - python/gevent/signal.py | 137 - python/gevent/socket.py | 129 - python/gevent/ssl.py | 26 - python/gevent/subprocess.py | 1672 -- python/gevent/thread.py | 114 - python/gevent/threading.py | 235 - python/gevent/threadpool.py | 580 - python/gevent/time.py | 27 - python/gevent/timeout.py | 373 - python/gevent/util.py | 592 - python/gevent/win32util.py | 98 - 134 files changed, 211285 deletions(-) delete mode 100644 python/gevent/__greenlet_primitives.cp36-win32.pyd delete mode 100644 python/gevent/__greenlet_primitives.pxd delete mode 100644 python/gevent/__hub_local.cp36-win32.pyd delete mode 100644 python/gevent/__hub_local.pxd delete mode 100644 python/gevent/__hub_primitives.cp36-win32.pyd delete mode 100644 python/gevent/__hub_primitives.pxd delete mode 100644 python/gevent/__ident.cp36-win32.pyd delete mode 100644 python/gevent/__ident.pxd delete mode 100644 python/gevent/__imap.cp36-win32.pyd delete mode 100644 python/gevent/__imap.pxd delete mode 100644 python/gevent/__init__.py delete mode 100644 python/gevent/__semaphore.cp36-win32.pyd delete mode 100644 python/gevent/__semaphore.pxd delete mode 100644 python/gevent/__tracer.cp36-win32.pyd delete mode 100644 python/gevent/__tracer.pxd delete mode 100644 python/gevent/__waiter.cp36-win32.pyd delete mode 100644 python/gevent/__waiter.pxd delete mode 100644 python/gevent/_compat.py delete mode 100644 python/gevent/_config.py delete mode 100644 python/gevent/_event.cp36-win32.pyd delete mode 100644 python/gevent/_event.pxd delete mode 100644 python/gevent/_ffi/__init__.py delete mode 100644 python/gevent/_ffi/callback.py delete mode 100644 python/gevent/_ffi/loop.py delete mode 100644 python/gevent/_ffi/watcher.py delete mode 100644 python/gevent/_fileobjectcommon.py delete mode 100644 python/gevent/_fileobjectposix.py delete mode 100644 python/gevent/_greenlet.cp36-win32.pyd delete mode 100644 python/gevent/_greenlet.pxd delete mode 100644 python/gevent/_greenlet_primitives.c delete mode 100644 python/gevent/_greenlet_primitives.py delete mode 100644 python/gevent/_hub_local.c delete mode 100644 python/gevent/_hub_local.py delete mode 100644 python/gevent/_hub_primitives.c delete mode 100644 python/gevent/_hub_primitives.py delete mode 100644 python/gevent/_ident.c delete mode 100644 python/gevent/_ident.py delete mode 100644 python/gevent/_imap.c delete mode 100644 python/gevent/_imap.py delete mode 100644 python/gevent/_interfaces.py delete mode 100644 python/gevent/_local.cp36-win32.pyd delete mode 100644 python/gevent/_local.pxd delete mode 100644 python/gevent/_monitor.py delete mode 100644 python/gevent/_patcher.py delete mode 100644 python/gevent/_queue.cp36-win32.pyd delete mode 100644 python/gevent/_queue.pxd delete mode 100644 python/gevent/_semaphore.c delete mode 100644 python/gevent/_semaphore.py delete mode 100644 python/gevent/_socket2.py delete mode 100644 python/gevent/_socket3.py delete mode 100644 python/gevent/_socketcommon.py delete mode 100644 python/gevent/_ssl2.py delete mode 100644 python/gevent/_ssl3.py delete mode 100644 python/gevent/_sslgte279.py delete mode 100644 python/gevent/_tblib.py delete mode 100644 python/gevent/_threading.py delete mode 100644 python/gevent/_tracer.c delete mode 100644 python/gevent/_tracer.py delete mode 100644 python/gevent/_util.py delete mode 100644 python/gevent/_util_py2.py delete mode 100644 python/gevent/_waiter.c delete mode 100644 python/gevent/_waiter.py delete mode 100644 python/gevent/ares.py delete mode 100644 python/gevent/backdoor.py delete mode 100644 python/gevent/baseserver.py delete mode 100644 python/gevent/builtins.py delete mode 100644 python/gevent/core.py delete mode 100644 python/gevent/event.c delete mode 100644 python/gevent/event.py delete mode 100644 python/gevent/events.py delete mode 100644 python/gevent/exceptions.py delete mode 100644 python/gevent/fileobject.py delete mode 100644 python/gevent/greenlet.c delete mode 100644 python/gevent/greenlet.py delete mode 100644 python/gevent/hub.py delete mode 100644 python/gevent/libev/__init__.py delete mode 100644 python/gevent/libev/_corecffi_build.py delete mode 100644 python/gevent/libev/_corecffi_cdef.c delete mode 100644 python/gevent/libev/_corecffi_source.c delete mode 100644 python/gevent/libev/callbacks.c delete mode 100644 python/gevent/libev/callbacks.h delete mode 100644 python/gevent/libev/corecext.c delete mode 100644 python/gevent/libev/corecext.cp36-win32.pyd delete mode 100644 python/gevent/libev/corecext.h delete mode 100644 python/gevent/libev/corecext.pyx delete mode 100644 python/gevent/libev/corecffi.py delete mode 100644 python/gevent/libev/libev.h delete mode 100644 python/gevent/libev/libev.pxd delete mode 100644 python/gevent/libev/libev_vfd.h delete mode 100644 python/gevent/libev/stathelper.c delete mode 100644 python/gevent/libev/watcher.py delete mode 100644 python/gevent/libuv/__init__.py delete mode 100644 python/gevent/libuv/_corecffi.cp36-win32.pyd delete mode 100644 python/gevent/libuv/_corecffi_build.py delete mode 100644 python/gevent/libuv/_corecffi_cdef.c delete mode 100644 python/gevent/libuv/_corecffi_source.c delete mode 100644 python/gevent/libuv/loop.py delete mode 100644 python/gevent/libuv/watcher.py delete mode 100644 python/gevent/local.c delete mode 100644 python/gevent/local.py delete mode 100644 python/gevent/lock.py delete mode 100644 python/gevent/monkey.py delete mode 100644 python/gevent/os.py delete mode 100644 python/gevent/pool.py delete mode 100644 python/gevent/pywsgi.py delete mode 100644 python/gevent/queue.c delete mode 100644 python/gevent/queue.py delete mode 100644 python/gevent/resolver/__init__.py delete mode 100644 python/gevent/resolver/ares.py delete mode 100644 python/gevent/resolver/blocking.py delete mode 100644 python/gevent/resolver/cares.c delete mode 100644 python/gevent/resolver/cares.cp36-win32.pyd delete mode 100644 python/gevent/resolver/cares.pyx delete mode 100644 python/gevent/resolver/cares_ntop.h delete mode 100644 python/gevent/resolver/cares_pton.h delete mode 100644 python/gevent/resolver/dnshelper.c delete mode 100644 python/gevent/resolver/dnspython.py delete mode 100644 python/gevent/resolver/libcares.pxd delete mode 100644 python/gevent/resolver/thread.py delete mode 100644 python/gevent/resolver_ares.py delete mode 100644 python/gevent/resolver_thread.py delete mode 100644 python/gevent/select.py delete mode 100644 python/gevent/server.py delete mode 100644 python/gevent/signal.py delete mode 100644 python/gevent/socket.py delete mode 100644 python/gevent/ssl.py delete mode 100644 python/gevent/subprocess.py delete mode 100644 python/gevent/thread.py delete mode 100644 python/gevent/threading.py delete mode 100644 python/gevent/threadpool.py delete mode 100644 python/gevent/time.py delete mode 100644 python/gevent/timeout.py delete mode 100644 python/gevent/util.py delete mode 100644 python/gevent/win32util.py (limited to 'python/gevent') 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 Binary files a/python/gevent/__greenlet_primitives.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/__hub_local.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/__hub_primitives.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/__ident.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/__imap.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/__semaphore.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/__tracer.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/__waiter.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/_event.cp36-win32.pyd and /dev/null 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 - # 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 "" - -_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=" % (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 Binary files a/python/gevent/_greenlet.cp36-win32.pyd and /dev/null 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 -#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 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 -#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 -#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 -#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 - #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[] = ""; -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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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= 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 -#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 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 -#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 -#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 -#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 - #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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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= 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 -#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 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 -#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 -#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 -#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 - #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[] = ""; -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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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; itp_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 -#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 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 -#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 -#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 -#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 - #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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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; itp_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 -#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 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 -#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 -#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 -#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 - #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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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= 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 Binary files a/python/gevent/_local.cp36-win32.pyd and /dev/null 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 Binary files a/python/gevent/_queue.cp36-win32.pyd and /dev/null 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 -#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 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 -#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 -#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 -#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 - #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[] = ""; -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 `, 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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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; itp_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 `, 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 `_ - 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 `_ - 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 = '' % ex - - if s.startswith(" 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 `_ - 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 `_ - 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 `_ - 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.+)", line (?P\d+)(, in (?P.+))?$') - - -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 "" % (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 -#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 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 -#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 -#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 -#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 - #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 - -/* 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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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; itp_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 '' - -_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 -#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 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 -#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 -#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 -#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 - #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[] = ""; -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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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; itp_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 " - # 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 '' - - 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 = '' % ( - self.__class__.__name__, - handle.__name__, - ) - else: - handle_repr = repr(handle) - - result += ' handle=' + handle_repr - except Exception as ex: - result += str(ex) or '' - - 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 -#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 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 -#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 -#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 -#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 - #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[] = ""; -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 `, 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 `, 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 ` 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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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; itp_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 `, 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 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 ` 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 `, 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 -`_ 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 -#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 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 -#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 -#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 -#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 - #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 - -/* 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[] = ""; -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..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..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 `; an example where the exception is raised\n immediately is if this greenlet had called\n :func:`sleep(0.1) `.\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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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= 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) - `; an example where the exception is raised - immediately is if this greenlet had called - :func:`sleep(0.1) `. - - .. 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 ` 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 ` 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", - 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 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 - `. - - 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 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 -#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 -#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 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 -#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 -#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 -#include -#include -#include "callbacks.h" -#include "stathelper.c" -#include "pythread.h" -#ifdef _OPENMP -#include -#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 - #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 - -/* 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[] = ""; -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; icurexc_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; itp_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 -#include -#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 Binary files a/python/gevent/libev/corecext.cp36-win32.pyd and /dev/null 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 "" % (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, - gevent_run_callbacks) - libev.ev_timer_init(&self._periodic_signal_checker, - gevent_periodic_signal_check, - 0.3, 0.3) - libev.ev_timer_init(&self._timer0, - gevent_noop, - 0.0, 0.0) - - cdef unsigned int c_flags - cdef object old_handler = None - if ptr: - self._ptr = 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 + 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 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) - 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(libev.ev_io_start, 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, gevent_callback_io, vfd, events) - self.__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, 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, 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(libev.ev_timer_start, 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, gevent_callback_timer, after, repeat) - self.__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(libev.ev_signal_start, 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, gevent_callback_signal, signalnum) - self.__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(libev.ev_idle_start, 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, gevent_callback_idle) - self.__watcher = &self._watcher - self.__ss = &idle_ss - - - -cdef start_and_stop prepare_ss = make_ss(libev.ev_prepare_start, 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, gevent_callback_prepare) - self.__watcher = &self._watcher - self.__ss = &prepare_ss - - - -cdef start_and_stop check_ss = make_ss(libev.ev_check_start, 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, gevent_callback_check) - self.__watcher = &self._watcher - self.__ss = &check_ss - - - -cdef start_and_stop fork_ss = make_ss(libev.ev_fork_start, 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, gevent_callback_fork) - self.__watcher = &self._watcher - self.__ss = &fork_ss - - -cdef start_and_stop async_ss = make_ss(libev.ev_async_start, 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, gevent_callback_async) - self.__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(libev.ev_child_start, 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, gevent_callback_child, pid, trace) - self.__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(libev.ev_stat_start, 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 = (path).encode(sys.getfilesystemencoding()) - self._paths = paths - else: - paths = path - self._paths = paths - libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) - self.__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(_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 = typep - Py_DECREF(type) - - if valuep: - value = valuep - Py_DECREF(value) - if tracebackp: - traceback = 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 -#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 -#include - -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(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 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 Binary files a/python/gevent/libuv/_corecffi.cp36-win32.pyd and /dev/null 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 -#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 -#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 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 -#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 -#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 -#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 - #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 - -/* 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[] = ""; -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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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= 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 ` 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__', '') - - 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 `. - - .. 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 `. - - .. 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 ` 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 ` 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 '. 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 ` (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 ` -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 ` 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 - >> 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': ''} - - 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 "" - 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 "" % (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 -#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 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 -#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 -#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 -#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 - #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 ` modules.\n\nThe classes in this module implement the iterator protocol. Iterating\nover a queue means repeatedly calling :meth:`get ` until\n:meth:`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 ` 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 ` 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 ` 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 ` 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 ` 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 ` 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; icurexc_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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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; itp_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 ` modules. - -The classes in this module implement the iterator protocol. Iterating -over a queue means repeatedly calling :meth:`get ` until -:meth:`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 ` 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 ` 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 '' % (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 -#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 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 -#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 -#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 -#include -#include "dnshelper.c" -#ifdef _OPENMP -#include -#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 - #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 = 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 = 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 = data - */ - } - - /* "gevent/resolver/cares.pyx":169 - * if not data: - * return - * cdef channel ch = 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 = 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 = arg # <<<<<<<<<<<<<< - * Py_DECREF(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 = arg - * Py_DECREF(arg) # <<<<<<<<<<<<<< - * cdef object host_result - * try: - */ - Py_DECREF(((PyObject *)__pyx_v_arg)); - - /* "gevent/resolver/cares.pyx":216 - * Py_DECREF(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(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(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 = arg # <<<<<<<<<<<<<< - * Py_DECREF(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 = arg - * Py_DECREF(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 = 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 = gevent_sock_state_callback - * options.sock_state_cb_data = 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 = gevent_sock_state_callback # <<<<<<<<<<<<<< - * options.sock_state_cb_data = 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 = gevent_sock_state_callback - * options.sock_state_cb_data = 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 = gevent_sock_state_callback - * options.sock_state_cb_data = 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 = 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 = gevent_sock_state_callback - * options.sock_state_cb_data = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = server - */ - } - - /* "gevent/resolver/cares.pyx":345 - * if isinstance(server, unicode): - * server = server.encode('ascii') - * string = 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 = 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 = 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 = 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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 = &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 = &sa6 - * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) - */ - Py_INCREF(__pyx_v_arg); - - /* "gevent/resolver/cares.pyx":455 - * cdef object arg = (self, callback) - * Py_INCREF(arg) - * cdef sockaddr_t* x = &sa6 # <<<<<<<<<<<<<< - * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) - * - */ - __pyx_v_x = ((struct sockaddr *)(&__pyx_v_sa6)); - - /* "gevent/resolver/cares.pyx":456 - * Py_INCREF(arg) - * cdef sockaddr_t* x = &sa6 - * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, 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, gevent_ares_host_callback, 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, gevent_ares_nameinfo_callback, 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, gevent_ares_nameinfo_callback, 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 = 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; icurexc_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= 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 -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("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - 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 Binary files a/python/gevent/resolver/cares.cp36-win32.pyd and /dev/null 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 = 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 = arg - Py_DECREF(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 = arg - Py_DECREF(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 = gevent_sock_state_callback - options.sock_state_cb_data = 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 = 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 = 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, gevent_ares_host_callback, 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, gevent_ares_host_callback, 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 = &sa6 - cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, 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 -#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 -#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 -#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 '' % (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 ` and :class:`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 "" % ( - 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 ` 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 - `, 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 -- cgit v1.2.3