Debian Codegraph @

pypy/module/cpyext/test/test_asyncgen.c

raw symbols SCIP
1 /* Generated by Cython 0.29.34 */
2
3 /* BEGIN: Cython Metadata
4 {
5 "distutils": {
6 "name": "test_asyncgen",
7 "sources": [
8 "/tmp/test_asyncgen.py"
9 ]
10 },
11 "module_name": "test_asyncgen"
12 }
13 END: Cython Metadata */
14
15 /* The pure-python code:
16 async def test_gen():
17 a = yield 123
18 assert a is None
19 yield 456
20 yield 789
21
22 def run_until_complete(coro):
23 while True:
24 try:
25 fut = coro.send(None)
26 except StopIteration as ex:
27 return ex.args[0]
28
29 def to_list(gen):
30 async def iterate():
31 res = []
32 async for i in gen:
33 res.append(i)
34 return res
35 return run_until_complete(iterate())
36 */
37
38 #ifndef PY_SSIZE_T_CLEAN
39 #define PY_SSIZE_T_CLEAN
40 #endif /* PY_SSIZE_T_CLEAN */
41 #include "Python.h"
42 #ifndef Py_PYTHON_H
43 #error Python headers needed to compile C extensions, please install development version of Python.
44 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
45 #error Cython requires Python 2.6+ or Python 3.3+.
46 #else
47 #define CYTHON_ABI "0_29_34"
48 #define CYTHON_HEX_VERSION 0x001D22F0
49 #define CYTHON_FUTURE_DIVISION 0
50 #include <stddef.h>
51 #ifndef offsetof
52 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
53 #endif
54 #if !defined(WIN32) && !defined(MS_WINDOWS)
55 #ifndef __stdcall
56 #define __stdcall
57 #endif
58 #ifndef __cdecl
59 #define __cdecl
60 #endif
61 #ifndef __fastcall
62 #define __fastcall
63 #endif
64 #endif
65 #ifndef DL_IMPORT
66 #define DL_IMPORT(t) t
67 #endif
68 #define __PYX_COMMA ,
69 #ifndef HAVE_LONG_LONG
70 #if PY_VERSION_HEX >= 0x02070000
71 #define HAVE_LONG_LONG
72 #endif
73 #endif
74 #ifndef PY_LONG_LONG
75 #define PY_LONG_LONG LONG_LONG
76 #endif
77 #ifndef Py_HUGE_VAL
78 #define Py_HUGE_VAL HUGE_VAL
79 #endif
80 #ifdef PYPY_VERSION
81 #define CYTHON_COMPILING_IN_PYPY 1
82 #define CYTHON_COMPILING_IN_PYSTON 0
83 #define CYTHON_COMPILING_IN_CPYTHON 0
84 #define CYTHON_COMPILING_IN_NOGIL 0
85 #undef CYTHON_USE_TYPE_SLOTS
86 #define CYTHON_USE_TYPE_SLOTS 0
87 #undef CYTHON_USE_PYTYPE_LOOKUP
88 #define CYTHON_USE_PYTYPE_LOOKUP 0
89 #if PY_VERSION_HEX < 0x03050000
90 #undef CYTHON_USE_ASYNC_SLOTS
91 #define CYTHON_USE_ASYNC_SLOTS 0
92 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
93 #define CYTHON_USE_ASYNC_SLOTS 1
94 #endif
95 #undef CYTHON_USE_PYLIST_INTERNALS
96 #define CYTHON_USE_PYLIST_INTERNALS 0
97 #undef CYTHON_USE_UNICODE_INTERNALS
98 #define CYTHON_USE_UNICODE_INTERNALS 0
99 #undef CYTHON_USE_UNICODE_WRITER
100 #define CYTHON_USE_UNICODE_WRITER 0
101 #undef CYTHON_USE_PYLONG_INTERNALS
102 #define CYTHON_USE_PYLONG_INTERNALS 0
103 #undef CYTHON_AVOID_BORROWED_REFS
104 #define CYTHON_AVOID_BORROWED_REFS 1
105 #undef CYTHON_ASSUME_SAFE_MACROS
106 #define CYTHON_ASSUME_SAFE_MACROS 0
107 #undef CYTHON_UNPACK_METHODS
108 #define CYTHON_UNPACK_METHODS 0
109 #undef CYTHON_FAST_THREAD_STATE
110 #define CYTHON_FAST_THREAD_STATE 0
111 #undef CYTHON_FAST_PYCALL
112 #define CYTHON_FAST_PYCALL 0
113 #undef CYTHON_PEP489_MULTI_PHASE_INIT
114 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
115 #undef CYTHON_USE_TP_FINALIZE
116 #define CYTHON_USE_TP_FINALIZE 0
117 #undef CYTHON_USE_DICT_VERSIONS
118 #define CYTHON_USE_DICT_VERSIONS 0
119 #undef CYTHON_USE_EXC_INFO_STACK
120 #define CYTHON_USE_EXC_INFO_STACK 0
121 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
122 #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
123 #endif
124 #elif defined(PYSTON_VERSION)
125 #define CYTHON_COMPILING_IN_PYPY 0
126 #define CYTHON_COMPILING_IN_PYSTON 1
127 #define CYTHON_COMPILING_IN_CPYTHON 0
128 #define CYTHON_COMPILING_IN_NOGIL 0
129 #ifndef CYTHON_USE_TYPE_SLOTS
130 #define CYTHON_USE_TYPE_SLOTS 1
131 #endif
132 #undef CYTHON_USE_PYTYPE_LOOKUP
133 #define CYTHON_USE_PYTYPE_LOOKUP 0
134 #undef CYTHON_USE_ASYNC_SLOTS
135 #define CYTHON_USE_ASYNC_SLOTS 0
136 #undef CYTHON_USE_PYLIST_INTERNALS
137 #define CYTHON_USE_PYLIST_INTERNALS 0
138 #ifndef CYTHON_USE_UNICODE_INTERNALS
139 #define CYTHON_USE_UNICODE_INTERNALS 1
140 #endif
141 #undef CYTHON_USE_UNICODE_WRITER
142 #define CYTHON_USE_UNICODE_WRITER 0
143 #undef CYTHON_USE_PYLONG_INTERNALS
144 #define CYTHON_USE_PYLONG_INTERNALS 0
145 #ifndef CYTHON_AVOID_BORROWED_REFS
146 #define CYTHON_AVOID_BORROWED_REFS 0
147 #endif
148 #ifndef CYTHON_ASSUME_SAFE_MACROS
149 #define CYTHON_ASSUME_SAFE_MACROS 1
150 #endif
151 #ifndef CYTHON_UNPACK_METHODS
152 #define CYTHON_UNPACK_METHODS 1
153 #endif
154 #undef CYTHON_FAST_THREAD_STATE
155 #define CYTHON_FAST_THREAD_STATE 0
156 #undef CYTHON_FAST_PYCALL
157 #define CYTHON_FAST_PYCALL 0
158 #undef CYTHON_PEP489_MULTI_PHASE_INIT
159 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
160 #undef CYTHON_USE_TP_FINALIZE
161 #define CYTHON_USE_TP_FINALIZE 0
162 #undef CYTHON_USE_DICT_VERSIONS
163 #define CYTHON_USE_DICT_VERSIONS 0
164 #undef CYTHON_USE_EXC_INFO_STACK
165 #define CYTHON_USE_EXC_INFO_STACK 0
166 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
167 #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
168 #endif
169 #elif defined(PY_NOGIL)
170 #define CYTHON_COMPILING_IN_PYPY 0
171 #define CYTHON_COMPILING_IN_PYSTON 0
172 #define CYTHON_COMPILING_IN_CPYTHON 0
173 #define CYTHON_COMPILING_IN_NOGIL 1
174 #ifndef CYTHON_USE_TYPE_SLOTS
175 #define CYTHON_USE_TYPE_SLOTS 1
176 #endif
177 #undef CYTHON_USE_PYTYPE_LOOKUP
178 #define CYTHON_USE_PYTYPE_LOOKUP 0
179 #ifndef CYTHON_USE_ASYNC_SLOTS
180 #define CYTHON_USE_ASYNC_SLOTS 1
181 #endif
182 #undef CYTHON_USE_PYLIST_INTERNALS
183 #define CYTHON_USE_PYLIST_INTERNALS 0
184 #ifndef CYTHON_USE_UNICODE_INTERNALS
185 #define CYTHON_USE_UNICODE_INTERNALS 1
186 #endif
187 #undef CYTHON_USE_UNICODE_WRITER
188 #define CYTHON_USE_UNICODE_WRITER 0
189 #undef CYTHON_USE_PYLONG_INTERNALS
190 #define CYTHON_USE_PYLONG_INTERNALS 0
191 #ifndef CYTHON_AVOID_BORROWED_REFS
192 #define CYTHON_AVOID_BORROWED_REFS 0
193 #endif
194 #ifndef CYTHON_ASSUME_SAFE_MACROS
195 #define CYTHON_ASSUME_SAFE_MACROS 1
196 #endif
197 #ifndef CYTHON_UNPACK_METHODS
198 #define CYTHON_UNPACK_METHODS 1
199 #endif
200 #undef CYTHON_FAST_THREAD_STATE
201 #define CYTHON_FAST_THREAD_STATE 0
202 #undef CYTHON_FAST_PYCALL
203 #define CYTHON_FAST_PYCALL 0
204 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
205 #define CYTHON_PEP489_MULTI_PHASE_INIT 1
206 #endif
207 #ifndef CYTHON_USE_TP_FINALIZE
208 #define CYTHON_USE_TP_FINALIZE 1
209 #endif
210 #undef CYTHON_USE_DICT_VERSIONS
211 #define CYTHON_USE_DICT_VERSIONS 0
212 #undef CYTHON_USE_EXC_INFO_STACK
213 #define CYTHON_USE_EXC_INFO_STACK 0
214 #else
215 #define CYTHON_COMPILING_IN_PYPY 0
216 #define CYTHON_COMPILING_IN_PYSTON 0
217 #define CYTHON_COMPILING_IN_CPYTHON 1
218 #define CYTHON_COMPILING_IN_NOGIL 0
219 #ifndef CYTHON_USE_TYPE_SLOTS
220 #define CYTHON_USE_TYPE_SLOTS 1
221 #endif
222 #if PY_VERSION_HEX < 0x02070000
223 #undef CYTHON_USE_PYTYPE_LOOKUP
224 #define CYTHON_USE_PYTYPE_LOOKUP 0
225 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
226 #define CYTHON_USE_PYTYPE_LOOKUP 1
227 #endif
228 #if PY_MAJOR_VERSION < 3
229 #undef CYTHON_USE_ASYNC_SLOTS
230 #define CYTHON_USE_ASYNC_SLOTS 0
231 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
232 #define CYTHON_USE_ASYNC_SLOTS 1
233 #endif
234 #if PY_VERSION_HEX < 0x02070000
235 #undef CYTHON_USE_PYLONG_INTERNALS
236 #define CYTHON_USE_PYLONG_INTERNALS 0
237 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
238 #define CYTHON_USE_PYLONG_INTERNALS (PY_VERSION_HEX < 0x030C00A5)
239 #endif
240 #ifndef CYTHON_USE_PYLIST_INTERNALS
241 #define CYTHON_USE_PYLIST_INTERNALS 1
242 #endif
243 #ifndef CYTHON_USE_UNICODE_INTERNALS
244 #define CYTHON_USE_UNICODE_INTERNALS 1
245 #endif
246 #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
247 #undef CYTHON_USE_UNICODE_WRITER
248 #define CYTHON_USE_UNICODE_WRITER 0
249 #elif !defined(CYTHON_USE_UNICODE_WRITER)
250 #define CYTHON_USE_UNICODE_WRITER 1
251 #endif
252 #ifndef CYTHON_AVOID_BORROWED_REFS
253 #define CYTHON_AVOID_BORROWED_REFS 0
254 #endif
255 #ifndef CYTHON_ASSUME_SAFE_MACROS
256 #define CYTHON_ASSUME_SAFE_MACROS 1
257 #endif
258 #ifndef CYTHON_UNPACK_METHODS
259 #define CYTHON_UNPACK_METHODS 1
260 #endif
261 #if PY_VERSION_HEX >= 0x030B00A4
262 #undef CYTHON_FAST_THREAD_STATE
263 #define CYTHON_FAST_THREAD_STATE 0
264 #elif !defined(CYTHON_FAST_THREAD_STATE)
265 #define CYTHON_FAST_THREAD_STATE 1
266 #endif
267 #ifndef CYTHON_FAST_PYCALL
268 #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
269 #endif
270 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
271 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
272 #endif
273 #ifndef CYTHON_USE_TP_FINALIZE
274 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
275 #endif
276 #ifndef CYTHON_USE_DICT_VERSIONS
277 #define CYTHON_USE_DICT_VERSIONS ((PY_VERSION_HEX >= 0x030600B1) && (PY_VERSION_HEX < 0x030C00A5))
278 #endif
279 #if PY_VERSION_HEX >= 0x030B00A4
280 #undef CYTHON_USE_EXC_INFO_STACK
281 #define CYTHON_USE_EXC_INFO_STACK 0
282 #elif !defined(CYTHON_USE_EXC_INFO_STACK)
283 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
284 #endif
285 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
286 #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
287 #endif
288 #endif
289 #if !defined(CYTHON_FAST_PYCCALL)
290 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
291 #endif
292 #if CYTHON_USE_PYLONG_INTERNALS
293 #if PY_MAJOR_VERSION < 3
294 #include "longintrepr.h"
295 #endif
296 #undef SHIFT
297 #undef BASE
298 #undef MASK
299 #ifdef SIZEOF_VOID_P
300 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
301 #endif
302 #endif
303 #ifndef __has_attribute
304 #define __has_attribute(x) 0
305 #endif
306 #ifndef __has_cpp_attribute
307 #define __has_cpp_attribute(x) 0
308 #endif
309 #ifndef CYTHON_RESTRICT
310 #if defined(__GNUC__)
311 #define CYTHON_RESTRICT __restrict__
312 #elif defined(_MSC_VER) && _MSC_VER >= 1400
313 #define CYTHON_RESTRICT __restrict
314 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
315 #define CYTHON_RESTRICT restrict
316 #else
317 #define CYTHON_RESTRICT
318 #endif
319 #endif
320 #ifndef CYTHON_UNUSED
321 # if defined(__GNUC__)
322 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
323 # define CYTHON_UNUSED __attribute__ ((__unused__))
324 # else
325 # define CYTHON_UNUSED
326 # endif
327 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
328 # define CYTHON_UNUSED __attribute__ ((__unused__))
329 # else
330 # define CYTHON_UNUSED
331 # endif
332 #endif
333 #ifndef CYTHON_MAYBE_UNUSED_VAR
334 # if defined(__cplusplus)
335 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
336 # else
337 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
338 # endif
339 #endif
340 #ifndef CYTHON_NCP_UNUSED
341 # if CYTHON_COMPILING_IN_CPYTHON
342 # define CYTHON_NCP_UNUSED
343 # else
344 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
345 # endif
346 #endif
347 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
348 #ifdef _MSC_VER
349 #ifndef _MSC_STDINT_H_
350 #if _MSC_VER < 1300
351 typedef unsigned char uint8_t;
352 typedef unsigned int uint32_t;
353 #else
354 typedef unsigned __int8 uint8_t;
355 typedef unsigned __int32 uint32_t;
356 #endif
357 #endif
358 #else
359 #include <stdint.h>
360 #endif
361 #ifndef CYTHON_FALLTHROUGH
362 #if defined(__cplusplus) && __cplusplus >= 201103L
363 #if __has_cpp_attribute(fallthrough)
364 #define CYTHON_FALLTHROUGH [[fallthrough]]
365 #elif __has_cpp_attribute(clang::fallthrough)
366 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
367 #elif __has_cpp_attribute(gnu::fallthrough)
368 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
369 #endif
370 #endif
371 #ifndef CYTHON_FALLTHROUGH
372 #if __has_attribute(fallthrough)
373 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
374 #else
375 #define CYTHON_FALLTHROUGH
376 #endif
377 #endif
378 #if defined(__clang__ ) && defined(__apple_build_version__)
379 #if __apple_build_version__ < 7000000
380 #undef CYTHON_FALLTHROUGH
381 #define CYTHON_FALLTHROUGH
382 #endif
383 #endif
384 #endif
385
386 #ifndef CYTHON_INLINE
387 #if defined(__clang__)
388 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
389 #elif defined(__GNUC__)
390 #define CYTHON_INLINE __inline__
391 #elif defined(_MSC_VER)
392 #define CYTHON_INLINE __inline
393 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
394 #define CYTHON_INLINE inline
395 #else
396 #define CYTHON_INLINE
397 #endif
398 #endif
399
400 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
401 #define Py_OptimizeFlag 0
402 #endif
403 #define __PYX_BUILD_PY_SSIZE_T "n"
404 #define CYTHON_FORMAT_SSIZE_T "z"
405 #if PY_MAJOR_VERSION < 3
406 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
407 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
408 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
409 #define __Pyx_DefaultClassType PyClass_Type
410 #else
411 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
412 #define __Pyx_DefaultClassType PyType_Type
413 #if PY_VERSION_HEX >= 0x030B00A1
414 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
415 PyObject *code, PyObject *c, PyObject* n, PyObject *v,
416 PyObject *fv, PyObject *cell, PyObject* fn,
417 PyObject *name, int fline, PyObject *lnos) {
418 PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
419 PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
420 const char *fn_cstr=NULL;
421 const char *name_cstr=NULL;
422 PyCodeObject* co=NULL;
423 PyObject *type, *value, *traceback;
424 PyErr_Fetch(&type, &value, &traceback);
425 if (!(kwds=PyDict_New())) goto end;
426 if (!(argcount=PyLong_FromLong(a))) goto end;
427 if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
428 if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
429 if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
430 if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
431 if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
432 if (!(nlocals=PyLong_FromLong(l))) goto end;
433 if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
434 if (!(stacksize=PyLong_FromLong(s))) goto end;
435 if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
436 if (!(flags=PyLong_FromLong(f))) goto end;
437 if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
438 if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
439 if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
440 if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
441 if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
442 if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
443 if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
444 if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
445 if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
446 if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
447 if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
448 if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
449 if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
450 if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
451 Py_XDECREF((PyObject*)co);
452 co = (PyCodeObject*)call_result;
453 call_result = NULL;
454 if (0) {
455 cleanup_code_too:
456 Py_XDECREF((PyObject*)co);
457 co = NULL;
458 }
459 end:
460 Py_XDECREF(kwds);
461 Py_XDECREF(argcount);
462 Py_XDECREF(posonlyargcount);
463 Py_XDECREF(kwonlyargcount);
464 Py_XDECREF(nlocals);
465 Py_XDECREF(stacksize);
466 Py_XDECREF(replace);
467 Py_XDECREF(call_result);
468 Py_XDECREF(empty);
469 if (type) {
470 PyErr_Restore(type, value, traceback);
471 }
472 return co;
473 }
474 #else
475 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
476 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
477 #endif
478 #define __Pyx_DefaultClassType PyType_Type
479 #endif
480 #ifndef Py_TPFLAGS_CHECKTYPES
481 #define Py_TPFLAGS_CHECKTYPES 0
482 #endif
483 #ifndef Py_TPFLAGS_HAVE_INDEX
484 #define Py_TPFLAGS_HAVE_INDEX 0
485 #endif
486 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
487 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
488 #endif
489 #ifndef Py_TPFLAGS_HAVE_FINALIZE
490 #define Py_TPFLAGS_HAVE_FINALIZE 0
491 #endif
492 #ifndef METH_STACKLESS
493 #define METH_STACKLESS 0
494 #endif
495 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
496 #ifndef METH_FASTCALL
497 #define METH_FASTCALL 0x80
498 #endif
499 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
500 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
501 Py_ssize_t nargs, PyObject *kwnames);
502 #else
503 #define __Pyx_PyCFunctionFast _PyCFunctionFast
504 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
505 #endif
506 #if CYTHON_FAST_PYCCALL
507 #define __Pyx_PyFastCFunction_Check(func)\
508 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
509 #else
510 #define __Pyx_PyFastCFunction_Check(func) 0
511 #endif
512 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
513 #define PyObject_Malloc(s) PyMem_Malloc(s)
514 #define PyObject_Free(p) PyMem_Free(p)
515 #define PyObject_Realloc(p) PyMem_Realloc(p)
516 #endif
517 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
518 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
519 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
520 #define PyMem_RawFree(p) PyMem_Free(p)
521 #endif
522 #if CYTHON_COMPILING_IN_PYSTON
523 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
524 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
525 #else
526 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
527 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
528 #endif
529 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
530 #define __Pyx_PyThreadState_Current PyThreadState_GET()
531 #elif PY_VERSION_HEX >= 0x03060000
532 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
533 #elif PY_VERSION_HEX >= 0x03000000
534 #define __Pyx_PyThreadState_Current PyThreadState_GET()
535 #else
536 #define __Pyx_PyThreadState_Current _PyThreadState_Current
537 #endif
538 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
539 #include "pythread.h"
540 #define Py_tss_NEEDS_INIT 0
541 typedef int Py_tss_t;
542 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
543 *key = PyThread_create_key();
544 return 0;
545 }
546 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
547 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
548 *key = Py_tss_NEEDS_INIT;
549 return key;
550 }
551 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
552 PyObject_Free(key);
553 }
554 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
555 return *key != Py_tss_NEEDS_INIT;
556 }
557 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
558 PyThread_delete_key(*key);
559 *key = Py_tss_NEEDS_INIT;
560 }
561 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
562 return PyThread_set_key_value(*key, value);
563 }
564 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
565 return PyThread_get_key_value(*key);
566 }
567 #endif
568 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
569 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
570 #else
571 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
572 #endif
573 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
574 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
575 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
576 #else
577 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
578 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
579 #endif
580 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
581 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
582 #else
583 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
584 #endif
585 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
586 #define CYTHON_PEP393_ENABLED 1
587 #if PY_VERSION_HEX >= 0x030C0000
588 #define __Pyx_PyUnicode_READY(op) (0)
589 #else
590 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
591 0 : _PyUnicode_Ready((PyObject *)(op)))
592 #endif
593 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
594 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
595 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
596 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
597 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
598 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
599 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
600 #if PY_VERSION_HEX >= 0x030C0000
601 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
602 #else
603 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
604 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
605 #else
606 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
607 #endif
608 #endif
609 #else
610 #define CYTHON_PEP393_ENABLED 0
611 #define PyUnicode_1BYTE_KIND 1
612 #define PyUnicode_2BYTE_KIND 2
613 #define PyUnicode_4BYTE_KIND 4
614 #define __Pyx_PyUnicode_READY(op) (0)
615 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
616 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
617 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
618 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
619 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
620 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
621 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
622 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
623 #endif
624 #if CYTHON_COMPILING_IN_PYPY
625 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
626 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
627 #else
628 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
629 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
630 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
631 #endif
632 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
633 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
634 #endif
635 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
636 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
637 #endif
638 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
639 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
640 #endif
641 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
642 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
643 #if PY_MAJOR_VERSION >= 3
644 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
645 #else
646 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
647 #endif
648 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
649 #define PyObject_ASCII(o) PyObject_Repr(o)
650 #endif
651 #if PY_MAJOR_VERSION >= 3
652 #define PyBaseString_Type PyUnicode_Type
653 #define PyStringObject PyUnicodeObject
654 #define PyString_Type PyUnicode_Type
655 #define PyString_Check PyUnicode_Check
656 #define PyString_CheckExact PyUnicode_CheckExact
657 #ifndef PyObject_Unicode
658 #define PyObject_Unicode PyObject_Str
659 #endif
660 #endif
661 #if PY_MAJOR_VERSION >= 3
662 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
663 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
664 #else
665 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
666 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
667 #endif
668 #ifndef PySet_CheckExact
669 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
670 #endif
671 #if PY_VERSION_HEX >= 0x030900A4
672 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
673 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
674 #else
675 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
676 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
677 #endif
678 #if CYTHON_ASSUME_SAFE_MACROS
679 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
680 #else
681 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
682 #endif
683 #if PY_MAJOR_VERSION >= 3
684 #define PyIntObject PyLongObject
685 #define PyInt_Type PyLong_Type
686 #define PyInt_Check(op) PyLong_Check(op)
687 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
688 #define PyInt_FromString PyLong_FromString
689 #define PyInt_FromUnicode PyLong_FromUnicode
690 #define PyInt_FromLong PyLong_FromLong
691 #define PyInt_FromSize_t PyLong_FromSize_t
692 #define PyInt_FromSsize_t PyLong_FromSsize_t
693 #define PyInt_AsLong PyLong_AsLong
694 #define PyInt_AS_LONG PyLong_AS_LONG
695 #define PyInt_AsSsize_t PyLong_AsSsize_t
696 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
697 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
698 #define PyNumber_Int PyNumber_Long
699 #endif
700 #if PY_MAJOR_VERSION >= 3
701 #define PyBoolObject PyLongObject
702 #endif
703 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
704 #ifndef PyUnicode_InternFromString
705 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
706 #endif
707 #endif
708 #if PY_VERSION_HEX < 0x030200A4
709 typedef long Py_hash_t;
710 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
711 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t
712 #else
713 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
714 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
715 #endif
716 #if PY_MAJOR_VERSION >= 3
717 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
718 #else
719 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
720 #endif
721 #if CYTHON_USE_ASYNC_SLOTS
722 #if PY_VERSION_HEX >= 0x030500B1
723 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
724 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
725 #else
726 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
727 #endif
728 #else
729 #define __Pyx_PyType_AsAsync(obj) NULL
730 #endif
731 #ifndef __Pyx_PyAsyncMethodsStruct
732 typedef struct {
733 unaryfunc am_await;
734 unaryfunc am_aiter;
735 unaryfunc am_anext;
736 } __Pyx_PyAsyncMethodsStruct;
737 #endif
738
739 #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
740 #if !defined(_USE_MATH_DEFINES)
741 #define _USE_MATH_DEFINES
742 #endif
743 #endif
744 #include <math.h>
745 #ifdef NAN
746 #define __PYX_NAN() ((float) NAN)
747 #else
748 static CYTHON_INLINE float __PYX_NAN() {
749 float value;
750 memset(&value, 0xFF, sizeof(value));
751 return value;
752 }
753 #endif
754 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
755 #define __Pyx_truncl trunc
756 #else
757 #define __Pyx_truncl truncl
758 #endif
759
760 #define __PYX_MARK_ERR_POS(f_index, lineno) \
761 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
762 #define __PYX_ERR(f_index, lineno, Ln_error) \
763 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
764
765 #ifndef __PYX_EXTERN_C
766 #ifdef __cplusplus
767 #define __PYX_EXTERN_C extern "C"
768 #else
769 #define __PYX_EXTERN_C extern
770 #endif
771 #endif
772
773 #define __PYX_HAVE__test_asyncgen
774 #define __PYX_HAVE_API__test_asyncgen
775 /* Early includes */
776 #ifdef _OPENMP
777 #include <omp.h>
778 #endif /* _OPENMP */
779
780 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
781 #define CYTHON_WITHOUT_ASSERTIONS
782 #endif
783
784 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
785 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
786
787 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
788 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
789 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
790 #define __PYX_DEFAULT_STRING_ENCODING ""
791 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
792 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
793 #define __Pyx_uchar_cast(c) ((unsigned char)c)
794 #define __Pyx_long_cast(x) ((long)x)
795 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
796 (sizeof(type) < sizeof(Py_ssize_t)) ||\
797 (sizeof(type) > sizeof(Py_ssize_t) &&\
798 likely(v < (type)PY_SSIZE_T_MAX ||\
799 v == (type)PY_SSIZE_T_MAX) &&\
800 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
801 v == (type)PY_SSIZE_T_MIN))) ||\
802 (sizeof(type) == sizeof(Py_ssize_t) &&\
803 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
804 v == (type)PY_SSIZE_T_MAX))) )
805 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
806 return (size_t) i < (size_t) limit;
807 }
808 #if defined (__cplusplus) && __cplusplus >= 201103L
809 #include <cstdlib>
810 #define __Pyx_sst_abs(value) std::abs(value)
811 #elif SIZEOF_INT >= SIZEOF_SIZE_T
812 #define __Pyx_sst_abs(value) abs(value)
813 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
814 #define __Pyx_sst_abs(value) labs(value)
815 #elif defined (_MSC_VER)
816 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
817 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
818 #define __Pyx_sst_abs(value) llabs(value)
819 #elif defined (__GNUC__)
820 #define __Pyx_sst_abs(value) __builtin_llabs(value)
821 #else
822 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
823 #endif
824 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
825 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
826 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
827 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
828 #define __Pyx_PyBytes_FromString PyBytes_FromString
829 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
830 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
831 #if PY_MAJOR_VERSION < 3
832 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
833 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
834 #else
835 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
836 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
837 #endif
838 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
839 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
840 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
841 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
842 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
843 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
844 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
845 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
846 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
847 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
848 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
849 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
850 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
851 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
852 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
853 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
854 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
855 const Py_UNICODE *u_end = u;
856 while (*u_end++) ;
857 return (size_t)(u_end - u - 1);
858 }
859 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
860 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
861 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
862 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
863 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
864 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
865 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
866 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
867 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
868 #define __Pyx_PySequence_Tuple(obj)\
869 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
870 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
871 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
872 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
873 #if CYTHON_ASSUME_SAFE_MACROS
874 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
875 #else
876 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
877 #endif
878 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
879 #if PY_MAJOR_VERSION >= 3
880 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
881 #else
882 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
883 #endif
884 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
885 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
886 static int __Pyx_sys_getdefaultencoding_not_ascii;
887 static int __Pyx_init_sys_getdefaultencoding_params(void) {
888 PyObject* sys;
889 PyObject* default_encoding = NULL;
890 PyObject* ascii_chars_u = NULL;
891 PyObject* ascii_chars_b = NULL;
892 const char* default_encoding_c;
893 sys = PyImport_ImportModule("sys");
894 if (!sys) goto bad;
895 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
896 Py_DECREF(sys);
897 if (!default_encoding) goto bad;
898 default_encoding_c = PyBytes_AsString(default_encoding);
899 if (!default_encoding_c) goto bad;
900 if (strcmp(default_encoding_c, "ascii") == 0) {
901 __Pyx_sys_getdefaultencoding_not_ascii = 0;
902 } else {
903 char ascii_chars[128];
904 int c;
905 for (c = 0; c < 128; c++) {
906 ascii_chars[c] = c;
907 }
908 __Pyx_sys_getdefaultencoding_not_ascii = 1;
909 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
910 if (!ascii_chars_u) goto bad;
911 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
912 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
913 PyErr_Format(
914 PyExc_ValueError,
915 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
916 default_encoding_c);
917 goto bad;
918 }
919 Py_DECREF(ascii_chars_u);
920 Py_DECREF(ascii_chars_b);
921 }
922 Py_DECREF(default_encoding);
923 return 0;
924 bad:
925 Py_XDECREF(default_encoding);
926 Py_XDECREF(ascii_chars_u);
927 Py_XDECREF(ascii_chars_b);
928 return -1;
929 }
930 #endif
931 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
932 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
933 #else
934 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
935 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
936 static char* __PYX_DEFAULT_STRING_ENCODING;
937 static int __Pyx_init_sys_getdefaultencoding_params(void) {
938 PyObject* sys;
939 PyObject* default_encoding = NULL;
940 char* default_encoding_c;
941 sys = PyImport_ImportModule("sys");
942 if (!sys) goto bad;
943 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
944 Py_DECREF(sys);
945 if (!default_encoding) goto bad;
946 default_encoding_c = PyBytes_AsString(default_encoding);
947 if (!default_encoding_c) goto bad;
948 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
949 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
950 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
951 Py_DECREF(default_encoding);
952 return 0;
953 bad:
954 Py_XDECREF(default_encoding);
955 return -1;
956 }
957 #endif
958 #endif
959
960
961 /* Test for GCC > 2.95 */
962 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
963 #define likely(x) __builtin_expect(!!(x), 1)
964 #define unlikely(x) __builtin_expect(!!(x), 0)
965 #else /* !__GNUC__ or GCC < 2.95 */
966 #define likely(x) (x)
967 #define unlikely(x) (x)
968 #endif /* __GNUC__ */
969 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
970
971 static PyObject *__pyx_m = NULL;
972 static PyObject *__pyx_d;
973 static PyObject *__pyx_b;
974 static PyObject *__pyx_cython_runtime = NULL;
975 static PyObject *__pyx_empty_tuple;
976 static PyObject *__pyx_empty_bytes;
977 static PyObject *__pyx_empty_unicode;
978 static int __pyx_lineno;
979 static int __pyx_clineno = 0;
980 static const char * __pyx_cfilenm= __FILE__;
981 static const char *__pyx_filename;
982
983
984 static const char *__pyx_f[] = {
985 "test_asyncgen.py",
986 };
987
988 /*--- Type declarations ---*/
989 struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen;
990 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list;
991 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate;
992
993 /* "test_asyncgen.py":1
994 * async def test_gen(): # <<<<<<<<<<<<<<
995 * a = yield 123
996 * assert a is None
997 */
998 struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen {
999 PyObject_HEAD
1000 PyObject *__pyx_v_a;
1001 };
1002
1003
1004 /* "test_asyncgen.py":14
1005 * return ex.args[0]
1006 *
1007 * def to_list(gen): # <<<<<<<<<<<<<<
1008 * async def iterate():
1009 * res = []
1010 */
1011 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list {
1012 PyObject_HEAD
1013 PyObject *__pyx_v_gen;
1014 };
1015
1016
1017 /* "test_asyncgen.py":15
1018 *
1019 * def to_list(gen):
1020 * async def iterate(): # <<<<<<<<<<<<<<
1021 * res = []
1022 * async for i in gen:
1023 */
1024 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate {
1025 PyObject_HEAD
1026 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *__pyx_outer_scope;
1027 PyObject *__pyx_v_i;
1028 PyObject *__pyx_v_res;
1029 PyObject *__pyx_t_0;
1030 };
1031
1032
1033 /* --- Runtime support code (head) --- */
1034 /* Refnanny.proto */
1035 #ifndef CYTHON_REFNANNY
1036 #define CYTHON_REFNANNY 0
1037 #endif
1038 #if CYTHON_REFNANNY
1039 typedef struct {
1040 void (*INCREF)(void*, PyObject*, int);
1041 void (*DECREF)(void*, PyObject*, int);
1042 void (*GOTREF)(void*, PyObject*, int);
1043 void (*GIVEREF)(void*, PyObject*, int);
1044 void* (*SetupContext)(const char*, int, const char*);
1045 void (*FinishContext)(void**);
1046 } __Pyx_RefNannyAPIStruct;
1047 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1048 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1049 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1050 #ifdef WITH_THREAD
1051 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1052 if (acquire_gil) {\
1053 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1054 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1055 PyGILState_Release(__pyx_gilstate_save);\
1056 } else {\
1057 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1058 }
1059 #else
1060 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1061 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1062 #endif
1063 #define __Pyx_RefNannyFinishContext()\
1064 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1065 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1066 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1067 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1068 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1069 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1070 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1071 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1072 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1073 #else
1074 #define __Pyx_RefNannyDeclarations
1075 #define __Pyx_RefNannySetupContext(name, acquire_gil)
1076 #define __Pyx_RefNannyFinishContext()
1077 #define __Pyx_INCREF(r) Py_INCREF(r)
1078 #define __Pyx_DECREF(r) Py_DECREF(r)
1079 #define __Pyx_GOTREF(r)
1080 #define __Pyx_GIVEREF(r)
1081 #define __Pyx_XINCREF(r) Py_XINCREF(r)
1082 #define __Pyx_XDECREF(r) Py_XDECREF(r)
1083 #define __Pyx_XGOTREF(r)
1084 #define __Pyx_XGIVEREF(r)
1085 #endif
1086 #define __Pyx_XDECREF_SET(r, v) do {\
1087 PyObject *tmp = (PyObject *) r;\
1088 r = v; __Pyx_XDECREF(tmp);\
1089 } while (0)
1090 #define __Pyx_DECREF_SET(r, v) do {\
1091 PyObject *tmp = (PyObject *) r;\
1092 r = v; __Pyx_DECREF(tmp);\
1093 } while (0)
1094 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1095 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1096
1097 /* PyObjectGetAttrStr.proto */
1098 #if CYTHON_USE_TYPE_SLOTS
1099 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1100 #else
1101 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1102 #endif
1103
1104 /* GetBuiltinName.proto */
1105 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1106
1107 /* StopAsyncIteration.proto */
1108 #define __Pyx_StopAsyncIteration_USED
1109 static PyObject *__Pyx_PyExc_StopAsyncIteration;
1110 static int __pyx_StopAsyncIteration_init(void);
1111
1112 /* PyCFunctionFastCall.proto */
1113 #if CYTHON_FAST_PYCCALL
1114 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1115 #else
1116 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1117 #endif
1118
1119 /* PyFunctionFastCall.proto */
1120 #if CYTHON_FAST_PYCALL
1121 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1122 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1123 #if 1 || PY_VERSION_HEX < 0x030600B1
1124 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1125 #else
1126 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1127 #endif
1128 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1129 (sizeof(char [1 - 2*!(cond)]) - 1)
1130 #ifndef Py_MEMBER_SIZE
1131 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1132 #endif
1133 #if CYTHON_FAST_PYCALL
1134 static size_t __pyx_pyframe_localsplus_offset = 0;
1135 #include "frameobject.h"
1136 #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
1137 #ifndef Py_BUILD_CORE
1138 #define Py_BUILD_CORE 1
1139 #endif
1140 #include "internal/pycore_frame.h"
1141 #endif
1142 #define __Pxy_PyFrame_Initialize_Offsets()\
1143 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1144 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1145 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1146 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1147 #endif // CYTHON_FAST_PYCALL
1148 #endif
1149
1150 /* PyObjectCall.proto */
1151 #if CYTHON_COMPILING_IN_CPYTHON
1152 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1153 #else
1154 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1155 #endif
1156
1157 /* PyObjectCall2Args.proto */
1158 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1159
1160 /* PyObjectCallMethO.proto */
1161 #if CYTHON_COMPILING_IN_CPYTHON
1162 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1163 #endif
1164
1165 /* PyObjectCallOneArg.proto */
1166 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1167
1168 /* GetTopmostException.proto */
1169 #if CYTHON_USE_EXC_INFO_STACK
1170 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1171 #endif
1172
1173 /* PyThreadStateGet.proto */
1174 #if CYTHON_FAST_THREAD_STATE
1175 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1176 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1177 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1178 #else
1179 #define __Pyx_PyThreadState_declare
1180 #define __Pyx_PyThreadState_assign
1181 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1182 #endif
1183
1184 /* SaveResetException.proto */
1185 #if CYTHON_FAST_THREAD_STATE
1186 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1187 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1188 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1189 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1190 #else
1191 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1192 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1193 #endif
1194
1195 /* PyErrExceptionMatches.proto */
1196 #if CYTHON_FAST_THREAD_STATE
1197 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1198 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1199 #else
1200 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1201 #endif
1202
1203 /* GetException.proto */
1204 #if CYTHON_FAST_THREAD_STATE
1205 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1206 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1207 #else
1208 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1209 #endif
1210
1211 /* GetItemInt.proto */
1212 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1213 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1214 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1215 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1216 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1217 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1218 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1219 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1220 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1221 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1222 int wraparound, int boundscheck);
1223 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1224 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1225 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1226 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1227 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1228 int wraparound, int boundscheck);
1229 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1230 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1231 int is_list, int wraparound, int boundscheck);
1232
1233 /* None.proto */
1234 static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
1235
1236 /* PyObjectCallNoArg.proto */
1237 #if CYTHON_COMPILING_IN_CPYTHON
1238 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1239 #else
1240 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1241 #endif
1242
1243 /* PyObjectGetMethod.proto */
1244 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1245
1246 /* GetAwaitIter.proto */
1247 static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o);
1248 static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o);
1249
1250 /* PyObjectCallMethod0.proto */
1251 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
1252
1253 /* AsyncIter.proto */
1254 static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *o);
1255 static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o);
1256
1257 /* FetchCommonType.proto */
1258 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1259
1260 /* PyErrFetchRestore.proto */
1261 #if CYTHON_FAST_THREAD_STATE
1262 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1263 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1264 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1265 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1266 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1267 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1268 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1269 #if CYTHON_COMPILING_IN_CPYTHON
1270 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1271 #else
1272 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1273 #endif
1274 #else
1275 #define __Pyx_PyErr_Clear() PyErr_Clear()
1276 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1277 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1278 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1279 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1280 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1281 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1282 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1283 #endif
1284
1285 /* RaiseException.proto */
1286 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1287
1288 /* SwapException.proto */
1289 #if CYTHON_FAST_THREAD_STATE
1290 #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1291 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1292 #else
1293 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1294 #endif
1295
1296 /* PyObjectCallMethod1.proto */
1297 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
1298
1299 /* CoroutineBase.proto */
1300 typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
1301 #if CYTHON_USE_EXC_INFO_STACK
1302 #define __Pyx_ExcInfoStruct _PyErr_StackItem
1303 #else
1304 typedef struct {
1305 PyObject *exc_type;
1306 PyObject *exc_value;
1307 PyObject *exc_traceback;
1308 } __Pyx_ExcInfoStruct;
1309 #endif
1310 typedef struct {
1311 PyObject_HEAD
1312 __pyx_coroutine_body_t body;
1313 PyObject *closure;
1314 __Pyx_ExcInfoStruct gi_exc_state;
1315 PyObject *gi_weakreflist;
1316 PyObject *classobj;
1317 PyObject *yieldfrom;
1318 PyObject *gi_name;
1319 PyObject *gi_qualname;
1320 PyObject *gi_modulename;
1321 PyObject *gi_code;
1322 PyObject *gi_frame;
1323 int resume_label;
1324 char is_running;
1325 } __pyx_CoroutineObject;
1326 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
1327 PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1328 PyObject *name, PyObject *qualname, PyObject *module_name);
1329 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
1330 __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1331 PyObject *name, PyObject *qualname, PyObject *module_name);
1332 static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
1333 static int __Pyx_Coroutine_clear(PyObject *self);
1334 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
1335 static PyObject *__Pyx_Coroutine_Close(PyObject *self);
1336 static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
1337 #if CYTHON_USE_EXC_INFO_STACK
1338 #define __Pyx_Coroutine_SwapException(self)
1339 #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
1340 #else
1341 #define __Pyx_Coroutine_SwapException(self) {\
1342 __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
1343 __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
1344 }
1345 #define __Pyx_Coroutine_ResetAndClearException(self) {\
1346 __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
1347 (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
1348 }
1349 #endif
1350 #if CYTHON_FAST_THREAD_STATE
1351 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
1352 __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
1353 #else
1354 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
1355 __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
1356 #endif
1357 static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
1358 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
1359
1360 /* PyObject_GenericGetAttrNoDict.proto */
1361 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1362 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1363 #else
1364 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1365 #endif
1366
1367 /* PatchModuleWithCoroutine.proto */
1368 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
1369
1370 /* PatchGeneratorABC.proto */
1371 static int __Pyx_patch_abc(void);
1372
1373 /* Coroutine.proto */
1374 #define __Pyx_Coroutine_USED
1375 static PyTypeObject *__pyx_CoroutineType = 0;
1376 static PyTypeObject *__pyx_CoroutineAwaitType = 0;
1377 #define __Pyx_Coroutine_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineType)
1378 #define __Pyx_Coroutine_Check(obj) __Pyx_Coroutine_CheckExact(obj)
1379 #define __Pyx_CoroutineAwait_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineAwaitType)
1380 #define __Pyx_Coroutine_New(body, code, closure, name, qualname, module_name)\
1381 __Pyx__Coroutine_New(__pyx_CoroutineType, body, code, closure, name, qualname, module_name)
1382 static int __pyx_Coroutine_init(void);
1383 static PyObject *__Pyx__Coroutine_await(PyObject *coroutine);
1384 typedef struct {
1385 PyObject_HEAD
1386 PyObject *coroutine;
1387 } __pyx_CoroutineAwaitObject;
1388 static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self, PyObject *arg);
1389 static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args);
1390
1391 /* CoroutineYieldFrom.proto */
1392 static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source);
1393
1394 /* ListAppend.proto */
1395 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
1396 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1397 PyListObject* L = (PyListObject*) list;
1398 Py_ssize_t len = Py_SIZE(list);
1399 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1400 Py_INCREF(x);
1401 PyList_SET_ITEM(list, len, x);
1402 __Pyx_SET_SIZE(list, len + 1);
1403 return 0;
1404 }
1405 return PyList_Append(list, x);
1406 }
1407 #else
1408 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1409 #endif
1410
1411 /* ReturnWithStopIteration.proto */
1412 #define __Pyx_ReturnWithStopIteration(value)\
1413 if (value == Py_None) PyErr_SetNone(PyExc_StopIteration); else __Pyx__ReturnWithStopIteration(value)
1414 static void __Pyx__ReturnWithStopIteration(PyObject* value);
1415
1416 /* CythonFunctionShared.proto */
1417 #define __Pyx_CyFunction_USED 1
1418 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
1419 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
1420 #define __Pyx_CYFUNCTION_CCLASS 0x04
1421 #define __Pyx_CyFunction_GetClosure(f)\
1422 (((__pyx_CyFunctionObject *) (f))->func_closure)
1423 #define __Pyx_CyFunction_GetClassObj(f)\
1424 (((__pyx_CyFunctionObject *) (f))->func_classobj)
1425 #define __Pyx_CyFunction_Defaults(type, f)\
1426 ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
1427 #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
1428 ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
1429 typedef struct {
1430 PyCFunctionObject func;
1431 #if PY_VERSION_HEX < 0x030500A0
1432 PyObject *func_weakreflist;
1433 #endif
1434 PyObject *func_dict;
1435 PyObject *func_name;
1436 PyObject *func_qualname;
1437 PyObject *func_doc;
1438 PyObject *func_globals;
1439 PyObject *func_code;
1440 PyObject *func_closure;
1441 PyObject *func_classobj;
1442 void *defaults;
1443 int defaults_pyobjects;
1444 size_t defaults_size; // used by FusedFunction for copying defaults
1445 int flags;
1446 PyObject *defaults_tuple;
1447 PyObject *defaults_kwdict;
1448 PyObject *(*defaults_getter)(PyObject *);
1449 PyObject *func_annotations;
1450 } __pyx_CyFunctionObject;
1451 static PyTypeObject *__pyx_CyFunctionType = 0;
1452 #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
1453 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
1454 int flags, PyObject* qualname,
1455 PyObject *self,
1456 PyObject *module, PyObject *globals,
1457 PyObject* code);
1458 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
1459 size_t size,
1460 int pyobjects);
1461 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
1462 PyObject *tuple);
1463 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
1464 PyObject *dict);
1465 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
1466 PyObject *dict);
1467 static int __pyx_CyFunction_init(void);
1468
1469 /* CythonFunction.proto */
1470 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
1471 int flags, PyObject* qualname,
1472 PyObject *closure,
1473 PyObject *module, PyObject *globals,
1474 PyObject* code);
1475
1476 /* PyDictVersioning.proto */
1477 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1478 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1479 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1480 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1481 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1482 (cache_var) = (value);
1483 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1484 static PY_UINT64_T __pyx_dict_version = 0;\
1485 static PyObject *__pyx_dict_cached_value = NULL;\
1486 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1487 (VAR) = __pyx_dict_cached_value;\
1488 } else {\
1489 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1490 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1491 }\
1492 }
1493 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1494 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1495 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1496 #else
1497 #define __PYX_GET_DICT_VERSION(dict) (0)
1498 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1499 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1500 #endif
1501
1502 /* GetModuleGlobalName.proto */
1503 #if CYTHON_USE_DICT_VERSIONS
1504 #define __Pyx_GetModuleGlobalName(var, name) do {\
1505 static PY_UINT64_T __pyx_dict_version = 0;\
1506 static PyObject *__pyx_dict_cached_value = NULL;\
1507 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1508 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1509 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1510 } while(0)
1511 #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\
1512 PY_UINT64_T __pyx_dict_version;\
1513 PyObject *__pyx_dict_cached_value;\
1514 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1515 } while(0)
1516 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1517 #else
1518 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1519 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1520 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1521 #endif
1522
1523 /* IncludeStringH.proto */
1524 #include <string.h>
1525
1526 /* CLineInTraceback.proto */
1527 #ifdef CYTHON_CLINE_IN_TRACEBACK
1528 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1529 #else
1530 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1531 #endif
1532
1533 /* CodeObjectCache.proto */
1534 typedef struct {
1535 PyCodeObject* code_object;
1536 int code_line;
1537 } __Pyx_CodeObjectCacheEntry;
1538 struct __Pyx_CodeObjectCache {
1539 int count;
1540 int max_count;
1541 __Pyx_CodeObjectCacheEntry* entries;
1542 };
1543 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1544 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1545 static PyCodeObject *__pyx_find_code_object(int code_line);
1546 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1547
1548 /* AddTraceback.proto */
1549 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1550 int py_line, const char *filename);
1551
1552 /* GCCDiagnostics.proto */
1553 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1554 #define __Pyx_HAS_GCC_DIAGNOSTIC
1555 #endif
1556
1557 /* CIntToPy.proto */
1558 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1559
1560 /* CIntFromPy.proto */
1561 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1562
1563 /* CIntFromPy.proto */
1564 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1565
1566 /* FastTypeChecks.proto */
1567 #if CYTHON_COMPILING_IN_CPYTHON
1568 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1569 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1570 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1571 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1572 #else
1573 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1574 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1575 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1576 #endif
1577 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1578
1579 /* AsyncGenerator.proto */
1580 #define __Pyx_AsyncGen_USED
1581 typedef struct {
1582 __pyx_CoroutineObject coro;
1583 PyObject *ag_finalizer;
1584 int ag_hooks_inited;
1585 int ag_closed;
1586 } __pyx_PyAsyncGenObject;
1587 static PyTypeObject *__pyx__PyAsyncGenWrappedValueType = 0;
1588 static PyTypeObject *__pyx__PyAsyncGenASendType = 0;
1589 static PyTypeObject *__pyx__PyAsyncGenAThrowType = 0;
1590 static PyTypeObject *__pyx_AsyncGenType = 0;
1591 #define __Pyx_AsyncGen_CheckExact(obj) (Py_TYPE(obj) == __pyx_AsyncGenType)
1592 #define __pyx_PyAsyncGenASend_CheckExact(o)\
1593 (Py_TYPE(o) == __pyx__PyAsyncGenASendType)
1594 #define __pyx_PyAsyncGenAThrow_CheckExact(o)\
1595 (Py_TYPE(o) == __pyx__PyAsyncGenAThrowType)
1596 static PyObject *__Pyx_async_gen_anext(PyObject *o);
1597 static CYTHON_INLINE PyObject *__Pyx_async_gen_asend_iternext(PyObject *o);
1598 static PyObject *__Pyx_async_gen_asend_send(PyObject *o, PyObject *arg);
1599 static PyObject *__Pyx_async_gen_asend_close(PyObject *o, PyObject *args);
1600 static PyObject *__Pyx_async_gen_athrow_close(PyObject *o, PyObject *args);
1601 static PyObject *__Pyx__PyAsyncGenValueWrapperNew(PyObject *val);
1602 static __pyx_CoroutineObject *__Pyx_AsyncGen_New(
1603 __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1604 PyObject *name, PyObject *qualname, PyObject *module_name) {
1605 __pyx_PyAsyncGenObject *gen = PyObject_GC_New(__pyx_PyAsyncGenObject, __pyx_AsyncGenType);
1606 if (unlikely(!gen))
1607 return NULL;
1608 gen->ag_finalizer = NULL;
1609 gen->ag_closed = 0;
1610 gen->ag_hooks_inited = 0;
1611 return __Pyx__Coroutine_NewInit((__pyx_CoroutineObject*)gen, body, code, closure, name, qualname, module_name);
1612 }
1613 static int __pyx_AsyncGen_init(void);
1614 static void __Pyx_PyAsyncGen_Fini(void);
1615
1616 /* CheckBinaryVersion.proto */
1617 static int __Pyx_check_binary_version(void);
1618
1619 /* InitStrings.proto */
1620 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1621
1622
1623 /* Module declarations from 'test_asyncgen' */
1624 static PyTypeObject *__pyx_ptype_13test_asyncgen___pyx_scope_struct__test_gen = 0;
1625 static PyTypeObject *__pyx_ptype_13test_asyncgen___pyx_scope_struct_1_to_list = 0;
1626 static PyTypeObject *__pyx_ptype_13test_asyncgen___pyx_scope_struct_2_iterate = 0;
1627 #define __Pyx_MODULE_NAME "test_asyncgen"
1628 extern int __pyx_module_is_main_test_asyncgen;
1629 int __pyx_module_is_main_test_asyncgen = 0;
1630
1631 /* Implementation of 'test_asyncgen' */
1632 static PyObject *__pyx_builtin_StopIteration;
1633 static const char __pyx_k_a[] = "a";
1634 static const char __pyx_k_i[] = "i";
1635 static const char __pyx_k_ex[] = "ex";
1636 static const char __pyx_k_fut[] = "fut";
1637 static const char __pyx_k_gen[] = "gen";
1638 static const char __pyx_k_res[] = "res";
1639 static const char __pyx_k_args[] = "args";
1640 static const char __pyx_k_coro[] = "coro";
1641 static const char __pyx_k_main[] = "__main__";
1642 static const char __pyx_k_name[] = "__name__";
1643 static const char __pyx_k_send[] = "send";
1644 static const char __pyx_k_test[] = "__test__";
1645 static const char __pyx_k_aiter[] = "__aiter__";
1646 static const char __pyx_k_anext[] = "__anext__";
1647 static const char __pyx_k_await[] = "__await__";
1648 static const char __pyx_k_close[] = "close";
1649 static const char __pyx_k_throw[] = "throw";
1650 static const char __pyx_k_iterate[] = "iterate";
1651 static const char __pyx_k_to_list[] = "to_list";
1652 static const char __pyx_k_test_gen[] = "test_gen";
1653 static const char __pyx_k_StopIteration[] = "StopIteration";
1654 static const char __pyx_k_test_asyncgen[] = "test_asyncgen";
1655 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1656 static const char __pyx_k_run_until_complete[] = "run_until_complete";
1657 static const char __pyx_k_tmp_test_asyncgen_py[] = "/tmp/test_asyncgen.py";
1658 static const char __pyx_k_to_list_locals_iterate[] = "to_list.<locals>.iterate";
1659 static PyObject *__pyx_n_s_StopIteration;
1660 static PyObject *__pyx_n_s_a;
1661 static PyObject *__pyx_n_s_aiter;
1662 static PyObject *__pyx_n_s_anext;
1663 static PyObject *__pyx_n_s_args;
1664 static PyObject *__pyx_n_s_await;
1665 static PyObject *__pyx_n_s_cline_in_traceback;
1666 static PyObject *__pyx_n_s_close;
1667 static PyObject *__pyx_n_s_coro;
1668 static PyObject *__pyx_n_s_ex;
1669 static PyObject *__pyx_n_s_fut;
1670 static PyObject *__pyx_n_s_gen;
1671 static PyObject *__pyx_n_s_i;
1672 static PyObject *__pyx_n_s_iterate;
1673 static PyObject *__pyx_n_s_main;
1674 static PyObject *__pyx_n_s_name;
1675 static PyObject *__pyx_n_s_res;
1676 static PyObject *__pyx_n_s_run_until_complete;
1677 static PyObject *__pyx_n_s_send;
1678 static PyObject *__pyx_n_s_test;
1679 static PyObject *__pyx_n_s_test_asyncgen;
1680 static PyObject *__pyx_n_s_test_gen;
1681 static PyObject *__pyx_n_s_throw;
1682 static PyObject *__pyx_kp_s_tmp_test_asyncgen_py;
1683 static PyObject *__pyx_n_s_to_list;
1684 static PyObject *__pyx_n_s_to_list_locals_iterate;
1685 static PyObject *__pyx_pf_13test_asyncgen_test_gen(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
1686 static PyObject *__pyx_pf_13test_asyncgen_3run_until_complete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_coro); /* proto */
1687 static PyObject *__pyx_pf_13test_asyncgen_7to_list_iterate(PyObject *__pyx_self); /* proto */
1688 static PyObject *__pyx_pf_13test_asyncgen_5to_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_gen); /* proto */
1689 static PyObject *__pyx_tp_new_13test_asyncgen___pyx_scope_struct__test_gen(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1690 static PyObject *__pyx_tp_new_13test_asyncgen___pyx_scope_struct_1_to_list(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1691 static PyObject *__pyx_tp_new_13test_asyncgen___pyx_scope_struct_2_iterate(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1692 static PyObject *__pyx_int_123;
1693 static PyObject *__pyx_int_456;
1694 static PyObject *__pyx_int_789;
1695 static PyObject *__pyx_codeobj_;
1696 static PyObject *__pyx_tuple__2;
1697 static PyObject *__pyx_tuple__4;
1698 static PyObject *__pyx_tuple__5;
1699 static PyObject *__pyx_tuple__7;
1700 static PyObject *__pyx_codeobj__3;
1701 static PyObject *__pyx_codeobj__6;
1702 static PyObject *__pyx_codeobj__8;
1703 /* Late includes */
1704 static PyObject *__pyx_gb_13test_asyncgen_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
1705
1706 /* "test_asyncgen.py":1
1707 * async def test_gen(): # <<<<<<<<<<<<<<
1708 * a = yield 123
1709 * assert a is None
1710 */
1711
1712 /* Python wrapper */
1713 static PyObject *__pyx_pw_13test_asyncgen_1test_gen(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1714 static PyMethodDef __pyx_mdef_13test_asyncgen_1test_gen = {"test_gen", (PyCFunction)__pyx_pw_13test_asyncgen_1test_gen, METH_NOARGS, 0};
1715 static PyObject *__pyx_pw_13test_asyncgen_1test_gen(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
1716 PyObject *__pyx_r = 0;
1717 __Pyx_RefNannyDeclarations
1718 __Pyx_RefNannySetupContext("test_gen (wrapper)", 0);
1719 __pyx_r = __pyx_pf_13test_asyncgen_test_gen(__pyx_self);
1720
1721 /* function exit code */
1722 __Pyx_RefNannyFinishContext();
1723 return __pyx_r;
1724 }
1725
1726 static PyObject *__pyx_pf_13test_asyncgen_test_gen(CYTHON_UNUSED PyObject *__pyx_self) {
1727 struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *__pyx_cur_scope;
1728 PyObject *__pyx_r = NULL;
1729 __Pyx_RefNannyDeclarations
1730 int __pyx_lineno = 0;
1731 const char *__pyx_filename = NULL;
1732 int __pyx_clineno = 0;
1733 __Pyx_RefNannySetupContext("test_gen", 0);
1734 __pyx_cur_scope = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *)__pyx_tp_new_13test_asyncgen___pyx_scope_struct__test_gen(__pyx_ptype_13test_asyncgen___pyx_scope_struct__test_gen, __pyx_empty_tuple, NULL);
1735 if (unlikely(!__pyx_cur_scope)) {
1736 __pyx_cur_scope = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *)Py_None);
1737 __Pyx_INCREF(Py_None);
1738 __PYX_ERR(0, 1, __pyx_L1_error)
1739 } else {
1740 __Pyx_GOTREF(__pyx_cur_scope);
1741 }
1742 {
1743 __pyx_CoroutineObject *gen = __Pyx_AsyncGen_New((__pyx_coroutine_body_t) __pyx_gb_13test_asyncgen_2generator, __pyx_codeobj_, (PyObject *) __pyx_cur_scope, __pyx_n_s_test_gen, __pyx_n_s_test_gen, __pyx_n_s_test_asyncgen); if (unlikely(!gen)) __PYX_ERR(0, 1, __pyx_L1_error)
1744 __Pyx_DECREF(__pyx_cur_scope);
1745 __Pyx_RefNannyFinishContext();
1746 return (PyObject *) gen;
1747 }
1748
1749 /* function exit code */
1750 __pyx_L1_error:;
1751 __Pyx_AddTraceback("test_asyncgen.test_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
1752 __pyx_r = NULL;
1753 __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
1754 __Pyx_XGIVEREF(__pyx_r);
1755 __Pyx_RefNannyFinishContext();
1756 return __pyx_r;
1757 }
1758
1759 static PyObject *__pyx_gb_13test_asyncgen_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
1760 {
1761 struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *__pyx_cur_scope = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *)__pyx_generator->closure);
1762 PyObject *__pyx_r = NULL;
1763 PyObject *__pyx_t_1 = NULL;
1764 int __pyx_t_2;
1765 int __pyx_lineno = 0;
1766 const char *__pyx_filename = NULL;
1767 int __pyx_clineno = 0;
1768 __Pyx_RefNannyDeclarations
1769 __Pyx_RefNannySetupContext("test_gen", 0);
1770 switch (__pyx_generator->resume_label) {
1771 case 0: goto __pyx_L3_first_run;
1772 case 1: goto __pyx_L4_resume_from_yield;
1773 case 2: goto __pyx_L5_resume_from_yield;
1774 case 3: goto __pyx_L6_resume_from_yield;
1775 default: /* CPython raises the right error here */
1776 __Pyx_RefNannyFinishContext();
1777 return NULL;
1778 }
1779 __pyx_L3_first_run:;
1780 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1, __pyx_L1_error)
1781
1782 /* "test_asyncgen.py":2
1783 * async def test_gen():
1784 * a = yield 123 # <<<<<<<<<<<<<<
1785 * assert a is None
1786 * yield 456
1787 */
1788 __Pyx_INCREF(__pyx_int_123);
1789 __pyx_r = __pyx_int_123;
1790 __Pyx_XGIVEREF(__pyx_r);
1791 __Pyx_RefNannyFinishContext();
1792 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
1793 /* return from async generator, yielding value */
1794 __pyx_generator->resume_label = 1;
1795 return __Pyx__PyAsyncGenValueWrapperNew(__pyx_r);
1796 __pyx_L4_resume_from_yield:;
1797 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2, __pyx_L1_error)
1798 __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
1799 __Pyx_GIVEREF(__pyx_t_1);
1800 __pyx_cur_scope->__pyx_v_a = __pyx_t_1;
1801 __pyx_t_1 = 0;
1802
1803 /* "test_asyncgen.py":3
1804 * async def test_gen():
1805 * a = yield 123
1806 * assert a is None # <<<<<<<<<<<<<<
1807 * yield 456
1808 * yield 789
1809 */
1810 #ifndef CYTHON_WITHOUT_ASSERTIONS
1811 if (unlikely(!Py_OptimizeFlag)) {
1812 __pyx_t_2 = (__pyx_cur_scope->__pyx_v_a == Py_None);
1813 if (unlikely(!(__pyx_t_2 != 0))) {
1814 PyErr_SetNone(PyExc_AssertionError);
1815 __PYX_ERR(0, 3, __pyx_L1_error)
1816 }
1817 }
1818 #endif
1819
1820 /* "test_asyncgen.py":4
1821 * a = yield 123
1822 * assert a is None
1823 * yield 456 # <<<<<<<<<<<<<<
1824 * yield 789
1825 *
1826 */
1827 __Pyx_INCREF(__pyx_int_456);
1828 __pyx_r = __pyx_int_456;
1829 __Pyx_XGIVEREF(__pyx_r);
1830 __Pyx_RefNannyFinishContext();
1831 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
1832 /* return from async generator, yielding value */
1833 __pyx_generator->resume_label = 2;
1834 return __Pyx__PyAsyncGenValueWrapperNew(__pyx_r);
1835 __pyx_L5_resume_from_yield:;
1836 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4, __pyx_L1_error)
1837
1838 /* "test_asyncgen.py":5
1839 * assert a is None
1840 * yield 456
1841 * yield 789 # <<<<<<<<<<<<<<
1842 *
1843 * def run_until_complete(coro):
1844 */
1845 __Pyx_INCREF(__pyx_int_789);
1846 __pyx_r = __pyx_int_789;
1847 __Pyx_XGIVEREF(__pyx_r);
1848 __Pyx_RefNannyFinishContext();
1849 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
1850 /* return from async generator, yielding value */
1851 __pyx_generator->resume_label = 3;
1852 return __Pyx__PyAsyncGenValueWrapperNew(__pyx_r);
1853 __pyx_L6_resume_from_yield:;
1854 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5, __pyx_L1_error)
1855 CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
1856
1857 /* "test_asyncgen.py":1
1858 * async def test_gen(): # <<<<<<<<<<<<<<
1859 * a = yield 123
1860 * assert a is None
1861 */
1862
1863 /* function exit code */
1864 PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
1865 goto __pyx_L0;
1866 __pyx_L1_error:;
1867 __Pyx_XDECREF(__pyx_t_1);
1868 __Pyx_AddTraceback("test_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
1869 __pyx_L0:;
1870 __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
1871 #if !CYTHON_USE_EXC_INFO_STACK
1872 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
1873 #endif
1874 __pyx_generator->resume_label = -1;
1875 __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
1876 __Pyx_RefNannyFinishContext();
1877 return __pyx_r;
1878 }
1879
1880 /* "test_asyncgen.py":7
1881 * yield 789
1882 *
1883 * def run_until_complete(coro): # <<<<<<<<<<<<<<
1884 * while True:
1885 * try:
1886 */
1887
1888 /* Python wrapper */
1889 static PyObject *__pyx_pw_13test_asyncgen_4run_until_complete(PyObject *__pyx_self, PyObject *__pyx_v_coro); /*proto*/
1890 static PyMethodDef __pyx_mdef_13test_asyncgen_4run_until_complete = {"run_until_complete", (PyCFunction)__pyx_pw_13test_asyncgen_4run_until_complete, METH_O, 0};
1891 static PyObject *__pyx_pw_13test_asyncgen_4run_until_complete(PyObject *__pyx_self, PyObject *__pyx_v_coro) {
1892 PyObject *__pyx_r = 0;
1893 __Pyx_RefNannyDeclarations
1894 __Pyx_RefNannySetupContext("run_until_complete (wrapper)", 0);
1895 __pyx_r = __pyx_pf_13test_asyncgen_3run_until_complete(__pyx_self, ((PyObject *)__pyx_v_coro));
1896
1897 /* function exit code */
1898 __Pyx_RefNannyFinishContext();
1899 return __pyx_r;
1900 }
1901
1902 static PyObject *__pyx_pf_13test_asyncgen_3run_until_complete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_coro) {
1903 CYTHON_UNUSED PyObject *__pyx_v_fut = NULL;
1904 PyObject *__pyx_v_ex = NULL;
1905 PyObject *__pyx_r = NULL;
1906 __Pyx_RefNannyDeclarations
1907 PyObject *__pyx_t_1 = NULL;
1908 PyObject *__pyx_t_2 = NULL;
1909 PyObject *__pyx_t_3 = NULL;
1910 PyObject *__pyx_t_4 = NULL;
1911 PyObject *__pyx_t_5 = NULL;
1912 PyObject *__pyx_t_6 = NULL;
1913 int __pyx_t_7;
1914 PyObject *__pyx_t_8 = NULL;
1915 PyObject *__pyx_t_9 = NULL;
1916 int __pyx_lineno = 0;
1917 const char *__pyx_filename = NULL;
1918 int __pyx_clineno = 0;
1919 __Pyx_RefNannySetupContext("run_until_complete", 0);
1920
1921 /* "test_asyncgen.py":8
1922 *
1923 * def run_until_complete(coro):
1924 * while True: # <<<<<<<<<<<<<<
1925 * try:
1926 * fut = coro.send(None)
1927 */
1928 while (1) {
1929
1930 /* "test_asyncgen.py":9
1931 * def run_until_complete(coro):
1932 * while True:
1933 * try: # <<<<<<<<<<<<<<
1934 * fut = coro.send(None)
1935 * except StopIteration as ex:
1936 */
1937 {
1938 __Pyx_PyThreadState_declare
1939 __Pyx_PyThreadState_assign
1940 __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
1941 __Pyx_XGOTREF(__pyx_t_1);
1942 __Pyx_XGOTREF(__pyx_t_2);
1943 __Pyx_XGOTREF(__pyx_t_3);
1944 /*try:*/ {
1945
1946 /* "test_asyncgen.py":10
1947 * while True:
1948 * try:
1949 * fut = coro.send(None) # <<<<<<<<<<<<<<
1950 * except StopIteration as ex:
1951 * return ex.args[0]
1952 */
1953 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_coro, __pyx_n_s_send); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 10, __pyx_L5_error)
1954 __Pyx_GOTREF(__pyx_t_5);
1955 __pyx_t_6 = NULL;
1956 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
1957 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
1958 if (likely(__pyx_t_6)) {
1959 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
1960 __Pyx_INCREF(__pyx_t_6);
1961 __Pyx_INCREF(function);
1962 __Pyx_DECREF_SET(__pyx_t_5, function);
1963 }
1964 }
1965 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, Py_None) : __Pyx_PyObject_CallOneArg(__pyx_t_5, Py_None);
1966 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
1967 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 10, __pyx_L5_error)
1968 __Pyx_GOTREF(__pyx_t_4);
1969 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1970 __Pyx_XDECREF_SET(__pyx_v_fut, __pyx_t_4);
1971 __pyx_t_4 = 0;
1972
1973 /* "test_asyncgen.py":9
1974 * def run_until_complete(coro):
1975 * while True:
1976 * try: # <<<<<<<<<<<<<<
1977 * fut = coro.send(None)
1978 * except StopIteration as ex:
1979 */
1980 }
1981 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
1982 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1983 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1984 goto __pyx_L12_try_end;
1985 __pyx_L5_error:;
1986 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1987 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1988 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
1989
1990 /* "test_asyncgen.py":11
1991 * try:
1992 * fut = coro.send(None)
1993 * except StopIteration as ex: # <<<<<<<<<<<<<<
1994 * return ex.args[0]
1995 *
1996 */
1997 __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
1998 if (__pyx_t_7) {
1999 __Pyx_AddTraceback("test_asyncgen.run_until_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
2000 if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 11, __pyx_L7_except_error)
2001 __Pyx_GOTREF(__pyx_t_4);
2002 __Pyx_GOTREF(__pyx_t_5);
2003 __Pyx_GOTREF(__pyx_t_6);
2004 __Pyx_INCREF(__pyx_t_5);
2005 __pyx_v_ex = __pyx_t_5;
2006
2007 /* "test_asyncgen.py":12
2008 * fut = coro.send(None)
2009 * except StopIteration as ex:
2010 * return ex.args[0] # <<<<<<<<<<<<<<
2011 *
2012 * def to_list(gen):
2013 */
2014 __Pyx_XDECREF(__pyx_r);
2015 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_ex, __pyx_n_s_args); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 12, __pyx_L7_except_error)
2016 __Pyx_GOTREF(__pyx_t_8);
2017 __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 12, __pyx_L7_except_error)
2018 __Pyx_GOTREF(__pyx_t_9);
2019 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2020 __pyx_r = __pyx_t_9;
2021 __pyx_t_9 = 0;
2022 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2023 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2024 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2025 goto __pyx_L8_except_return;
2026 }
2027 goto __pyx_L7_except_error;
2028 __pyx_L7_except_error:;
2029
2030 /* "test_asyncgen.py":9
2031 * def run_until_complete(coro):
2032 * while True:
2033 * try: # <<<<<<<<<<<<<<
2034 * fut = coro.send(None)
2035 * except StopIteration as ex:
2036 */
2037 __Pyx_XGIVEREF(__pyx_t_1);
2038 __Pyx_XGIVEREF(__pyx_t_2);
2039 __Pyx_XGIVEREF(__pyx_t_3);
2040 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
2041 goto __pyx_L1_error;
2042 __pyx_L8_except_return:;
2043 __Pyx_XGIVEREF(__pyx_t_1);
2044 __Pyx_XGIVEREF(__pyx_t_2);
2045 __Pyx_XGIVEREF(__pyx_t_3);
2046 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
2047 goto __pyx_L0;
2048 __pyx_L12_try_end:;
2049 }
2050 }
2051
2052 /* "test_asyncgen.py":7
2053 * yield 789
2054 *
2055 * def run_until_complete(coro): # <<<<<<<<<<<<<<
2056 * while True:
2057 * try:
2058 */
2059
2060 /* function exit code */
2061 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2062 goto __pyx_L0;
2063 __pyx_L1_error:;
2064 __Pyx_XDECREF(__pyx_t_4);
2065 __Pyx_XDECREF(__pyx_t_5);
2066 __Pyx_XDECREF(__pyx_t_6);
2067 __Pyx_XDECREF(__pyx_t_8);
2068 __Pyx_XDECREF(__pyx_t_9);
2069 __Pyx_AddTraceback("test_asyncgen.run_until_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
2070 __pyx_r = NULL;
2071 __pyx_L0:;
2072 __Pyx_XDECREF(__pyx_v_fut);
2073 __Pyx_XDECREF(__pyx_v_ex);
2074 __Pyx_XGIVEREF(__pyx_r);
2075 __Pyx_RefNannyFinishContext();
2076 return __pyx_r;
2077 }
2078
2079 /* "test_asyncgen.py":14
2080 * return ex.args[0]
2081 *
2082 * def to_list(gen): # <<<<<<<<<<<<<<
2083 * async def iterate():
2084 * res = []
2085 */
2086
2087 /* Python wrapper */
2088 static PyObject *__pyx_pw_13test_asyncgen_6to_list(PyObject *__pyx_self, PyObject *__pyx_v_gen); /*proto*/
2089 static PyMethodDef __pyx_mdef_13test_asyncgen_6to_list = {"to_list", (PyCFunction)__pyx_pw_13test_asyncgen_6to_list, METH_O, 0};
2090 static PyObject *__pyx_pw_13test_asyncgen_6to_list(PyObject *__pyx_self, PyObject *__pyx_v_gen) {
2091 PyObject *__pyx_r = 0;
2092 __Pyx_RefNannyDeclarations
2093 __Pyx_RefNannySetupContext("to_list (wrapper)", 0);
2094 __pyx_r = __pyx_pf_13test_asyncgen_5to_list(__pyx_self, ((PyObject *)__pyx_v_gen));
2095
2096 /* function exit code */
2097 __Pyx_RefNannyFinishContext();
2098 return __pyx_r;
2099 }
2100 static PyObject *__pyx_gb_13test_asyncgen_7to_list_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
2101
2102 /* "test_asyncgen.py":15
2103 *
2104 * def to_list(gen):
2105 * async def iterate(): # <<<<<<<<<<<<<<
2106 * res = []
2107 * async for i in gen:
2108 */
2109
2110 /* Python wrapper */
2111 static PyObject *__pyx_pw_13test_asyncgen_7to_list_1iterate(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
2112 static PyMethodDef __pyx_mdef_13test_asyncgen_7to_list_1iterate = {"iterate", (PyCFunction)__pyx_pw_13test_asyncgen_7to_list_1iterate, METH_NOARGS, 0};
2113 static PyObject *__pyx_pw_13test_asyncgen_7to_list_1iterate(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
2114 PyObject *__pyx_r = 0;
2115 __Pyx_RefNannyDeclarations
2116 __Pyx_RefNannySetupContext("iterate (wrapper)", 0);
2117 __pyx_r = __pyx_pf_13test_asyncgen_7to_list_iterate(__pyx_self);
2118
2119 /* function exit code */
2120 __Pyx_RefNannyFinishContext();
2121 return __pyx_r;
2122 }
2123
2124 static PyObject *__pyx_pf_13test_asyncgen_7to_list_iterate(PyObject *__pyx_self) {
2125 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *__pyx_cur_scope;
2126 PyObject *__pyx_r = NULL;
2127 __Pyx_RefNannyDeclarations
2128 int __pyx_lineno = 0;
2129 const char *__pyx_filename = NULL;
2130 int __pyx_clineno = 0;
2131 __Pyx_RefNannySetupContext("iterate", 0);
2132 __pyx_cur_scope = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *)__pyx_tp_new_13test_asyncgen___pyx_scope_struct_2_iterate(__pyx_ptype_13test_asyncgen___pyx_scope_struct_2_iterate, __pyx_empty_tuple, NULL);
2133 if (unlikely(!__pyx_cur_scope)) {
2134 __pyx_cur_scope = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *)Py_None);
2135 __Pyx_INCREF(Py_None);
2136 __PYX_ERR(0, 15, __pyx_L1_error)
2137 } else {
2138 __Pyx_GOTREF(__pyx_cur_scope);
2139 }
2140 __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *) __Pyx_CyFunction_GetClosure(__pyx_self);
2141 __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
2142 __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
2143 {
2144 __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_13test_asyncgen_7to_list_2generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iterate, __pyx_n_s_to_list_locals_iterate, __pyx_n_s_test_asyncgen); if (unlikely(!gen)) __PYX_ERR(0, 15, __pyx_L1_error)
2145 __Pyx_DECREF(__pyx_cur_scope);
2146 __Pyx_RefNannyFinishContext();
2147 return (PyObject *) gen;
2148 }
2149
2150 /* function exit code */
2151 __pyx_L1_error:;
2152 __Pyx_AddTraceback("test_asyncgen.to_list.iterate", __pyx_clineno, __pyx_lineno, __pyx_filename);
2153 __pyx_r = NULL;
2154 __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
2155 __Pyx_XGIVEREF(__pyx_r);
2156 __Pyx_RefNannyFinishContext();
2157 return __pyx_r;
2158 }
2159
2160 static PyObject *__pyx_gb_13test_asyncgen_7to_list_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
2161 {
2162 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *__pyx_cur_scope = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *)__pyx_generator->closure);
2163 PyObject *__pyx_r = NULL;
2164 PyObject *__pyx_t_1 = NULL;
2165 PyObject *__pyx_t_2 = NULL;
2166 int __pyx_t_3;
2167 int __pyx_lineno = 0;
2168 const char *__pyx_filename = NULL;
2169 int __pyx_clineno = 0;
2170 __Pyx_RefNannyDeclarations
2171 __Pyx_RefNannySetupContext("iterate", 0);
2172 switch (__pyx_generator->resume_label) {
2173 case 0: goto __pyx_L3_first_run;
2174 case 1: goto __pyx_L6_resume_from_await;
2175 default: /* CPython raises the right error here */
2176 __Pyx_RefNannyFinishContext();
2177 return NULL;
2178 }
2179 __pyx_L3_first_run:;
2180 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 15, __pyx_L1_error)
2181
2182 /* "test_asyncgen.py":16
2183 * def to_list(gen):
2184 * async def iterate():
2185 * res = [] # <<<<<<<<<<<<<<
2186 * async for i in gen:
2187 * res.append(i)
2188 */
2189 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
2190 __Pyx_GOTREF(__pyx_t_1);
2191 __Pyx_GIVEREF(__pyx_t_1);
2192 __pyx_cur_scope->__pyx_v_res = ((PyObject*)__pyx_t_1);
2193 __pyx_t_1 = 0;
2194
2195 /* "test_asyncgen.py":17
2196 * async def iterate():
2197 * res = []
2198 * async for i in gen: # <<<<<<<<<<<<<<
2199 * res.append(i)
2200 * return res
2201 */
2202 if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_gen)) { __Pyx_RaiseClosureNameError("gen"); __PYX_ERR(0, 17, __pyx_L1_error) }
2203 __pyx_t_1 = __Pyx_Coroutine_GetAsyncIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_gen); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
2204 __Pyx_GOTREF(__pyx_t_1);
2205 for (;;) {
2206 __pyx_t_2 = __Pyx_Coroutine_AsyncIterNext(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
2207 __Pyx_GOTREF(__pyx_t_2);
2208 __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2);
2209 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2210 __Pyx_XGOTREF(__pyx_r);
2211 if (likely(__pyx_r)) {
2212 __Pyx_XGIVEREF(__pyx_t_1);
2213 __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
2214 __Pyx_XGIVEREF(__pyx_r);
2215 __Pyx_RefNannyFinishContext();
2216 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
2217 /* return from generator, awaiting value */
2218 __pyx_generator->resume_label = 1;
2219 return __pyx_r;
2220 __pyx_L6_resume_from_await:;
2221 __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
2222 __pyx_cur_scope->__pyx_t_0 = 0;
2223 __Pyx_XGOTREF(__pyx_t_1);
2224 if (unlikely(!__pyx_sent_value)) {
2225 PyObject* exc_type = __Pyx_PyErr_Occurred();
2226 if (unlikely(exc_type && (exc_type == __Pyx_PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, __Pyx_PyExc_StopAsyncIteration))))) {
2227 PyErr_Clear();
2228 break;
2229 }
2230 __PYX_ERR(0, 17, __pyx_L1_error)
2231 }
2232 __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
2233 } else {
2234 PyObject* exc_type = __Pyx_PyErr_Occurred();
2235 if (unlikely(exc_type && (exc_type == __Pyx_PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, __Pyx_PyExc_StopAsyncIteration))))) {
2236 PyErr_Clear();
2237 break;
2238 }
2239 __pyx_t_2 = NULL;
2240 if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
2241 __Pyx_GOTREF(__pyx_t_2);
2242 }
2243 __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
2244 __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_2);
2245 __Pyx_GIVEREF(__pyx_t_2);
2246 __pyx_t_2 = 0;
2247
2248 /* "test_asyncgen.py":18
2249 * res = []
2250 * async for i in gen:
2251 * res.append(i) # <<<<<<<<<<<<<<
2252 * return res
2253 *
2254 */
2255 __pyx_t_3 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_res, __pyx_cur_scope->__pyx_v_i); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 18, __pyx_L1_error)
2256
2257 /* "test_asyncgen.py":17
2258 * async def iterate():
2259 * res = []
2260 * async for i in gen: # <<<<<<<<<<<<<<
2261 * res.append(i)
2262 * return res
2263 */
2264 }
2265 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2266
2267 /* "test_asyncgen.py":19
2268 * async for i in gen:
2269 * res.append(i)
2270 * return res # <<<<<<<<<<<<<<
2271 *
2272 * return run_until_complete(iterate())
2273 */
2274 __Pyx_XDECREF(__pyx_r);
2275 __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_cur_scope->__pyx_v_res);
2276 goto __pyx_L0;
2277 CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
2278
2279 /* "test_asyncgen.py":15
2280 *
2281 * def to_list(gen):
2282 * async def iterate(): # <<<<<<<<<<<<<<
2283 * res = []
2284 * async for i in gen:
2285 */
2286
2287 /* function exit code */
2288 __pyx_L1_error:;
2289 __Pyx_XDECREF(__pyx_t_1);
2290 __Pyx_XDECREF(__pyx_t_2);
2291 __Pyx_AddTraceback("iterate", __pyx_clineno, __pyx_lineno, __pyx_filename);
2292 __pyx_L0:;
2293 __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
2294 #if !CYTHON_USE_EXC_INFO_STACK
2295 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
2296 #endif
2297 __pyx_generator->resume_label = -1;
2298 __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
2299 __Pyx_RefNannyFinishContext();
2300 return __pyx_r;
2301 }
2302
2303 /* "test_asyncgen.py":14
2304 * return ex.args[0]
2305 *
2306 * def to_list(gen): # <<<<<<<<<<<<<<
2307 * async def iterate():
2308 * res = []
2309 */
2310
2311 static PyObject *__pyx_pf_13test_asyncgen_5to_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_gen) {
2312 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *__pyx_cur_scope;
2313 PyObject *__pyx_v_iterate = 0;
2314 PyObject *__pyx_gb_13test_asyncgen_7to_list_2generator1 = 0;
2315 PyObject *__pyx_r = NULL;
2316 __Pyx_RefNannyDeclarations
2317 PyObject *__pyx_t_1 = NULL;
2318 PyObject *__pyx_t_2 = NULL;
2319 PyObject *__pyx_t_3 = NULL;
2320 PyObject *__pyx_t_4 = NULL;
2321 int __pyx_lineno = 0;
2322 const char *__pyx_filename = NULL;
2323 int __pyx_clineno = 0;
2324 __Pyx_RefNannySetupContext("to_list", 0);
2325 __pyx_cur_scope = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *)__pyx_tp_new_13test_asyncgen___pyx_scope_struct_1_to_list(__pyx_ptype_13test_asyncgen___pyx_scope_struct_1_to_list, __pyx_empty_tuple, NULL);
2326 if (unlikely(!__pyx_cur_scope)) {
2327 __pyx_cur_scope = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *)Py_None);
2328 __Pyx_INCREF(Py_None);
2329 __PYX_ERR(0, 14, __pyx_L1_error)
2330 } else {
2331 __Pyx_GOTREF(__pyx_cur_scope);
2332 }
2333 __pyx_cur_scope->__pyx_v_gen = __pyx_v_gen;
2334 __Pyx_INCREF(__pyx_cur_scope->__pyx_v_gen);
2335 __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_gen);
2336
2337 /* "test_asyncgen.py":15
2338 *
2339 * def to_list(gen):
2340 * async def iterate(): # <<<<<<<<<<<<<<
2341 * res = []
2342 * async for i in gen:
2343 */
2344 __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_13test_asyncgen_7to_list_1iterate, 0, __pyx_n_s_to_list_locals_iterate, ((PyObject*)__pyx_cur_scope), __pyx_n_s_test_asyncgen, __pyx_d, ((PyObject *)__pyx_codeobj__3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
2345 __Pyx_GOTREF(__pyx_t_1);
2346 __pyx_v_iterate = __pyx_t_1;
2347 __pyx_t_1 = 0;
2348
2349 /* "test_asyncgen.py":21
2350 * return res
2351 *
2352 * return run_until_complete(iterate()) # <<<<<<<<<<<<<<
2353 *
2354 */
2355 __Pyx_XDECREF(__pyx_r);
2356 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_run_until_complete); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
2357 __Pyx_GOTREF(__pyx_t_2);
2358 __pyx_t_3 = __pyx_pf_13test_asyncgen_7to_list_iterate(__pyx_v_iterate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error)
2359 __Pyx_GOTREF(__pyx_t_3);
2360 __pyx_t_4 = NULL;
2361 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
2362 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
2363 if (likely(__pyx_t_4)) {
2364 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2365 __Pyx_INCREF(__pyx_t_4);
2366 __Pyx_INCREF(function);
2367 __Pyx_DECREF_SET(__pyx_t_2, function);
2368 }
2369 }
2370 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
2371 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2372 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2373 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
2374 __Pyx_GOTREF(__pyx_t_1);
2375 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2376 __pyx_r = __pyx_t_1;
2377 __pyx_t_1 = 0;
2378 goto __pyx_L0;
2379
2380 /* "test_asyncgen.py":14
2381 * return ex.args[0]
2382 *
2383 * def to_list(gen): # <<<<<<<<<<<<<<
2384 * async def iterate():
2385 * res = []
2386 */
2387
2388 /* function exit code */
2389 __pyx_L1_error:;
2390 __Pyx_XDECREF(__pyx_t_1);
2391 __Pyx_XDECREF(__pyx_t_2);
2392 __Pyx_XDECREF(__pyx_t_3);
2393 __Pyx_XDECREF(__pyx_t_4);
2394 __Pyx_AddTraceback("test_asyncgen.to_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
2395 __pyx_r = NULL;
2396 __pyx_L0:;
2397 __Pyx_XDECREF(__pyx_v_iterate);
2398 __Pyx_XDECREF(__pyx_gb_13test_asyncgen_7to_list_2generator1);
2399 __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
2400 __Pyx_XGIVEREF(__pyx_r);
2401 __Pyx_RefNannyFinishContext();
2402 return __pyx_r;
2403 }
2404
2405 static struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *__pyx_freelist_13test_asyncgen___pyx_scope_struct__test_gen[8];
2406 static int __pyx_freecount_13test_asyncgen___pyx_scope_struct__test_gen = 0;
2407
2408 static PyObject *__pyx_tp_new_13test_asyncgen___pyx_scope_struct__test_gen(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
2409 PyObject *o;
2410 if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_13test_asyncgen___pyx_scope_struct__test_gen > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen)))) {
2411 o = (PyObject*)__pyx_freelist_13test_asyncgen___pyx_scope_struct__test_gen[--__pyx_freecount_13test_asyncgen___pyx_scope_struct__test_gen];
2412 memset(o, 0, sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen));
2413 (void) PyObject_INIT(o, t);
2414 PyObject_GC_Track(o);
2415 } else {
2416 o = (*t->tp_alloc)(t, 0);
2417 if (unlikely(!o)) return 0;
2418 }
2419 return o;
2420 }
2421
2422 static void __pyx_tp_dealloc_13test_asyncgen___pyx_scope_struct__test_gen(PyObject *o) {
2423 struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *p = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *)o;
2424 PyObject_GC_UnTrack(o);
2425 Py_CLEAR(p->__pyx_v_a);
2426 if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_13test_asyncgen___pyx_scope_struct__test_gen < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen)))) {
2427 __pyx_freelist_13test_asyncgen___pyx_scope_struct__test_gen[__pyx_freecount_13test_asyncgen___pyx_scope_struct__test_gen++] = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *)o);
2428 } else {
2429 (*Py_TYPE(o)->tp_free)(o);
2430 }
2431 }
2432
2433 static int __pyx_tp_traverse_13test_asyncgen___pyx_scope_struct__test_gen(PyObject *o, visitproc v, void *a) {
2434 int e;
2435 struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *p = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen *)o;
2436 if (p->__pyx_v_a) {
2437 e = (*v)(p->__pyx_v_a, a); if (e) return e;
2438 }
2439 return 0;
2440 }
2441
2442 static PyTypeObject __pyx_type_13test_asyncgen___pyx_scope_struct__test_gen = {
2443 PyVarObject_HEAD_INIT(0, 0)
2444 "test_asyncgen.__pyx_scope_struct__test_gen", /*tp_name*/
2445 sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct__test_gen), /*tp_basicsize*/
2446 0, /*tp_itemsize*/
2447 __pyx_tp_dealloc_13test_asyncgen___pyx_scope_struct__test_gen, /*tp_dealloc*/
2448 #if PY_VERSION_HEX < 0x030800b4
2449 0, /*tp_print*/
2450 #endif
2451 #if PY_VERSION_HEX >= 0x030800b4
2452 0, /*tp_vectorcall_offset*/
2453 #endif
2454 0, /*tp_getattr*/
2455 0, /*tp_setattr*/
2456 #if PY_MAJOR_VERSION < 3
2457 0, /*tp_compare*/
2458 #endif
2459 #if PY_MAJOR_VERSION >= 3
2460 0, /*tp_as_async*/
2461 #endif
2462 0, /*tp_repr*/
2463 0, /*tp_as_number*/
2464 0, /*tp_as_sequence*/
2465 0, /*tp_as_mapping*/
2466 0, /*tp_hash*/
2467 0, /*tp_call*/
2468 0, /*tp_str*/
2469 0, /*tp_getattro*/
2470 0, /*tp_setattro*/
2471 0, /*tp_as_buffer*/
2472 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
2473 0, /*tp_doc*/
2474 __pyx_tp_traverse_13test_asyncgen___pyx_scope_struct__test_gen, /*tp_traverse*/
2475 0, /*tp_clear*/
2476 0, /*tp_richcompare*/
2477 0, /*tp_weaklistoffset*/
2478 0, /*tp_iter*/
2479 0, /*tp_iternext*/
2480 0, /*tp_methods*/
2481 0, /*tp_members*/
2482 0, /*tp_getset*/
2483 0, /*tp_base*/
2484 0, /*tp_dict*/
2485 0, /*tp_descr_get*/
2486 0, /*tp_descr_set*/
2487 0, /*tp_dictoffset*/
2488 0, /*tp_init*/
2489 0, /*tp_alloc*/
2490 __pyx_tp_new_13test_asyncgen___pyx_scope_struct__test_gen, /*tp_new*/
2491 0, /*tp_free*/
2492 0, /*tp_is_gc*/
2493 0, /*tp_bases*/
2494 0, /*tp_mro*/
2495 0, /*tp_cache*/
2496 0, /*tp_subclasses*/
2497 0, /*tp_weaklist*/
2498 0, /*tp_del*/
2499 0, /*tp_version_tag*/
2500 #if PY_VERSION_HEX >= 0x030400a1
2501 0, /*tp_finalize*/
2502 #endif
2503 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
2504 0, /*tp_vectorcall*/
2505 #endif
2506 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2507 0, /*tp_print*/
2508 #endif
2509 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
2510 0, /*tp_pypy_flags*/
2511 #endif
2512 };
2513
2514 static struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *__pyx_freelist_13test_asyncgen___pyx_scope_struct_1_to_list[8];
2515 static int __pyx_freecount_13test_asyncgen___pyx_scope_struct_1_to_list = 0;
2516
2517 static PyObject *__pyx_tp_new_13test_asyncgen___pyx_scope_struct_1_to_list(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
2518 PyObject *o;
2519 if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_13test_asyncgen___pyx_scope_struct_1_to_list > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list)))) {
2520 o = (PyObject*)__pyx_freelist_13test_asyncgen___pyx_scope_struct_1_to_list[--__pyx_freecount_13test_asyncgen___pyx_scope_struct_1_to_list];
2521 memset(o, 0, sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list));
2522 (void) PyObject_INIT(o, t);
2523 PyObject_GC_Track(o);
2524 } else {
2525 o = (*t->tp_alloc)(t, 0);
2526 if (unlikely(!o)) return 0;
2527 }
2528 return o;
2529 }
2530
2531 static void __pyx_tp_dealloc_13test_asyncgen___pyx_scope_struct_1_to_list(PyObject *o) {
2532 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *p = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *)o;
2533 PyObject_GC_UnTrack(o);
2534 Py_CLEAR(p->__pyx_v_gen);
2535 if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_13test_asyncgen___pyx_scope_struct_1_to_list < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list)))) {
2536 __pyx_freelist_13test_asyncgen___pyx_scope_struct_1_to_list[__pyx_freecount_13test_asyncgen___pyx_scope_struct_1_to_list++] = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *)o);
2537 } else {
2538 (*Py_TYPE(o)->tp_free)(o);
2539 }
2540 }
2541
2542 static int __pyx_tp_traverse_13test_asyncgen___pyx_scope_struct_1_to_list(PyObject *o, visitproc v, void *a) {
2543 int e;
2544 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *p = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *)o;
2545 if (p->__pyx_v_gen) {
2546 e = (*v)(p->__pyx_v_gen, a); if (e) return e;
2547 }
2548 return 0;
2549 }
2550
2551 static int __pyx_tp_clear_13test_asyncgen___pyx_scope_struct_1_to_list(PyObject *o) {
2552 PyObject* tmp;
2553 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *p = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list *)o;
2554 tmp = ((PyObject*)p->__pyx_v_gen);
2555 p->__pyx_v_gen = Py_None; Py_INCREF(Py_None);
2556 Py_XDECREF(tmp);
2557 return 0;
2558 }
2559
2560 static PyTypeObject __pyx_type_13test_asyncgen___pyx_scope_struct_1_to_list = {
2561 PyVarObject_HEAD_INIT(0, 0)
2562 "test_asyncgen.__pyx_scope_struct_1_to_list", /*tp_name*/
2563 sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_1_to_list), /*tp_basicsize*/
2564 0, /*tp_itemsize*/
2565 __pyx_tp_dealloc_13test_asyncgen___pyx_scope_struct_1_to_list, /*tp_dealloc*/
2566 #if PY_VERSION_HEX < 0x030800b4
2567 0, /*tp_print*/
2568 #endif
2569 #if PY_VERSION_HEX >= 0x030800b4
2570 0, /*tp_vectorcall_offset*/
2571 #endif
2572 0, /*tp_getattr*/
2573 0, /*tp_setattr*/
2574 #if PY_MAJOR_VERSION < 3
2575 0, /*tp_compare*/
2576 #endif
2577 #if PY_MAJOR_VERSION >= 3
2578 0, /*tp_as_async*/
2579 #endif
2580 0, /*tp_repr*/
2581 0, /*tp_as_number*/
2582 0, /*tp_as_sequence*/
2583 0, /*tp_as_mapping*/
2584 0, /*tp_hash*/
2585 0, /*tp_call*/
2586 0, /*tp_str*/
2587 0, /*tp_getattro*/
2588 0, /*tp_setattro*/
2589 0, /*tp_as_buffer*/
2590 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
2591 0, /*tp_doc*/
2592 __pyx_tp_traverse_13test_asyncgen___pyx_scope_struct_1_to_list, /*tp_traverse*/
2593 __pyx_tp_clear_13test_asyncgen___pyx_scope_struct_1_to_list, /*tp_clear*/
2594 0, /*tp_richcompare*/
2595 0, /*tp_weaklistoffset*/
2596 0, /*tp_iter*/
2597 0, /*tp_iternext*/
2598 0, /*tp_methods*/
2599 0, /*tp_members*/
2600 0, /*tp_getset*/
2601 0, /*tp_base*/
2602 0, /*tp_dict*/
2603 0, /*tp_descr_get*/
2604 0, /*tp_descr_set*/
2605 0, /*tp_dictoffset*/
2606 0, /*tp_init*/
2607 0, /*tp_alloc*/
2608 __pyx_tp_new_13test_asyncgen___pyx_scope_struct_1_to_list, /*tp_new*/
2609 0, /*tp_free*/
2610 0, /*tp_is_gc*/
2611 0, /*tp_bases*/
2612 0, /*tp_mro*/
2613 0, /*tp_cache*/
2614 0, /*tp_subclasses*/
2615 0, /*tp_weaklist*/
2616 0, /*tp_del*/
2617 0, /*tp_version_tag*/
2618 #if PY_VERSION_HEX >= 0x030400a1
2619 0, /*tp_finalize*/
2620 #endif
2621 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
2622 0, /*tp_vectorcall*/
2623 #endif
2624 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2625 0, /*tp_print*/
2626 #endif
2627 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
2628 0, /*tp_pypy_flags*/
2629 #endif
2630 };
2631
2632 static struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *__pyx_freelist_13test_asyncgen___pyx_scope_struct_2_iterate[8];
2633 static int __pyx_freecount_13test_asyncgen___pyx_scope_struct_2_iterate = 0;
2634
2635 static PyObject *__pyx_tp_new_13test_asyncgen___pyx_scope_struct_2_iterate(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
2636 PyObject *o;
2637 if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_13test_asyncgen___pyx_scope_struct_2_iterate > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate)))) {
2638 o = (PyObject*)__pyx_freelist_13test_asyncgen___pyx_scope_struct_2_iterate[--__pyx_freecount_13test_asyncgen___pyx_scope_struct_2_iterate];
2639 memset(o, 0, sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate));
2640 (void) PyObject_INIT(o, t);
2641 PyObject_GC_Track(o);
2642 } else {
2643 o = (*t->tp_alloc)(t, 0);
2644 if (unlikely(!o)) return 0;
2645 }
2646 return o;
2647 }
2648
2649 static void __pyx_tp_dealloc_13test_asyncgen___pyx_scope_struct_2_iterate(PyObject *o) {
2650 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *p = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *)o;
2651 PyObject_GC_UnTrack(o);
2652 Py_CLEAR(p->__pyx_outer_scope);
2653 Py_CLEAR(p->__pyx_v_i);
2654 Py_CLEAR(p->__pyx_v_res);
2655 Py_CLEAR(p->__pyx_t_0);
2656 if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_13test_asyncgen___pyx_scope_struct_2_iterate < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate)))) {
2657 __pyx_freelist_13test_asyncgen___pyx_scope_struct_2_iterate[__pyx_freecount_13test_asyncgen___pyx_scope_struct_2_iterate++] = ((struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *)o);
2658 } else {
2659 (*Py_TYPE(o)->tp_free)(o);
2660 }
2661 }
2662
2663 static int __pyx_tp_traverse_13test_asyncgen___pyx_scope_struct_2_iterate(PyObject *o, visitproc v, void *a) {
2664 int e;
2665 struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *p = (struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate *)o;
2666 if (p->__pyx_outer_scope) {
2667 e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
2668 }
2669 if (p->__pyx_v_i) {
2670 e = (*v)(p->__pyx_v_i, a); if (e) return e;
2671 }
2672 if (p->__pyx_v_res) {
2673 e = (*v)(p->__pyx_v_res, a); if (e) return e;
2674 }
2675 if (p->__pyx_t_0) {
2676 e = (*v)(p->__pyx_t_0, a); if (e) return e;
2677 }
2678 return 0;
2679 }
2680
2681 static PyTypeObject __pyx_type_13test_asyncgen___pyx_scope_struct_2_iterate = {
2682 PyVarObject_HEAD_INIT(0, 0)
2683 "test_asyncgen.__pyx_scope_struct_2_iterate", /*tp_name*/
2684 sizeof(struct __pyx_obj_13test_asyncgen___pyx_scope_struct_2_iterate), /*tp_basicsize*/
2685 0, /*tp_itemsize*/
2686 __pyx_tp_dealloc_13test_asyncgen___pyx_scope_struct_2_iterate, /*tp_dealloc*/
2687 #if PY_VERSION_HEX < 0x030800b4
2688 0, /*tp_print*/
2689 #endif
2690 #if PY_VERSION_HEX >= 0x030800b4
2691 0, /*tp_vectorcall_offset*/
2692 #endif
2693 0, /*tp_getattr*/
2694 0, /*tp_setattr*/
2695 #if PY_MAJOR_VERSION < 3
2696 0, /*tp_compare*/
2697 #endif
2698 #if PY_MAJOR_VERSION >= 3
2699 0, /*tp_as_async*/
2700 #endif
2701 0, /*tp_repr*/
2702 0, /*tp_as_number*/
2703 0, /*tp_as_sequence*/
2704 0, /*tp_as_mapping*/
2705 0, /*tp_hash*/
2706 0, /*tp_call*/
2707 0, /*tp_str*/
2708 0, /*tp_getattro*/
2709 0, /*tp_setattro*/
2710 0, /*tp_as_buffer*/
2711 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
2712 0, /*tp_doc*/
2713 __pyx_tp_traverse_13test_asyncgen___pyx_scope_struct_2_iterate, /*tp_traverse*/
2714 0, /*tp_clear*/
2715 0, /*tp_richcompare*/
2716 0, /*tp_weaklistoffset*/
2717 0, /*tp_iter*/
2718 0, /*tp_iternext*/
2719 0, /*tp_methods*/
2720 0, /*tp_members*/
2721 0, /*tp_getset*/
2722 0, /*tp_base*/
2723 0, /*tp_dict*/
2724 0, /*tp_descr_get*/
2725 0, /*tp_descr_set*/
2726 0, /*tp_dictoffset*/
2727 0, /*tp_init*/
2728 0, /*tp_alloc*/
2729 __pyx_tp_new_13test_asyncgen___pyx_scope_struct_2_iterate, /*tp_new*/
2730 0, /*tp_free*/
2731 0, /*tp_is_gc*/
2732 0, /*tp_bases*/
2733 0, /*tp_mro*/
2734 0, /*tp_cache*/
2735 0, /*tp_subclasses*/
2736 0, /*tp_weaklist*/
2737 0, /*tp_del*/
2738 0, /*tp_version_tag*/
2739 #if PY_VERSION_HEX >= 0x030400a1
2740 0, /*tp_finalize*/
2741 #endif
2742 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
2743 0, /*tp_vectorcall*/
2744 #endif
2745 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2746 0, /*tp_print*/
2747 #endif
2748 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
2749 0, /*tp_pypy_flags*/
2750 #endif
2751 };
2752
2753 static PyMethodDef __pyx_methods[] = {
2754 {0, 0, 0, 0}
2755 };
2756
2757 #if PY_MAJOR_VERSION >= 3
2758 #if CYTHON_PEP489_MULTI_PHASE_INIT
2759 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
2760 static int __pyx_pymod_exec_test_asyncgen(PyObject* module); /*proto*/
2761 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
2762 {Py_mod_create, (void*)__pyx_pymod_create},
2763 {Py_mod_exec, (void*)__pyx_pymod_exec_test_asyncgen},
2764 {0, NULL}
2765 };
2766 #endif
2767
2768 static struct PyModuleDef __pyx_moduledef = {
2769 PyModuleDef_HEAD_INIT,
2770 "test_asyncgen",
2771 0, /* m_doc */
2772 #if CYTHON_PEP489_MULTI_PHASE_INIT
2773 0, /* m_size */
2774 #else
2775 -1, /* m_size */
2776 #endif
2777 __pyx_methods /* m_methods */,
2778 #if CYTHON_PEP489_MULTI_PHASE_INIT
2779 __pyx_moduledef_slots, /* m_slots */
2780 #else
2781 NULL, /* m_reload */
2782 #endif
2783 NULL, /* m_traverse */
2784 NULL, /* m_clear */
2785 NULL /* m_free */
2786 };
2787 #endif
2788 #ifndef CYTHON_SMALL_CODE
2789 #if defined(__clang__)
2790 #define CYTHON_SMALL_CODE
2791 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
2792 #define CYTHON_SMALL_CODE __attribute__((cold))
2793 #else
2794 #define CYTHON_SMALL_CODE
2795 #endif
2796 #endif
2797
2798 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2799 {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
2800 {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
2801 {&__pyx_n_s_aiter, __pyx_k_aiter, sizeof(__pyx_k_aiter), 0, 0, 1, 1},
2802 {&__pyx_n_s_anext, __pyx_k_anext, sizeof(__pyx_k_anext), 0, 0, 1, 1},
2803 {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
2804 {&__pyx_n_s_await, __pyx_k_await, sizeof(__pyx_k_await), 0, 0, 1, 1},
2805 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2806 {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
2807 {&__pyx_n_s_coro, __pyx_k_coro, sizeof(__pyx_k_coro), 0, 0, 1, 1},
2808 {&__pyx_n_s_ex, __pyx_k_ex, sizeof(__pyx_k_ex), 0, 0, 1, 1},
2809 {&__pyx_n_s_fut, __pyx_k_fut, sizeof(__pyx_k_fut), 0, 0, 1, 1},
2810 {&__pyx_n_s_gen, __pyx_k_gen, sizeof(__pyx_k_gen), 0, 0, 1, 1},
2811 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
2812 {&__pyx_n_s_iterate, __pyx_k_iterate, sizeof(__pyx_k_iterate), 0, 0, 1, 1},
2813 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2814 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
2815 {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1},
2816 {&__pyx_n_s_run_until_complete, __pyx_k_run_until_complete, sizeof(__pyx_k_run_until_complete), 0, 0, 1, 1},
2817 {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
2818 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2819 {&__pyx_n_s_test_asyncgen, __pyx_k_test_asyncgen, sizeof(__pyx_k_test_asyncgen), 0, 0, 1, 1},
2820 {&__pyx_n_s_test_gen, __pyx_k_test_gen, sizeof(__pyx_k_test_gen), 0, 0, 1, 1},
2821 {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
2822 {&__pyx_kp_s_tmp_test_asyncgen_py, __pyx_k_tmp_test_asyncgen_py, sizeof(__pyx_k_tmp_test_asyncgen_py), 0, 0, 1, 0},
2823 {&__pyx_n_s_to_list, __pyx_k_to_list, sizeof(__pyx_k_to_list), 0, 0, 1, 1},
2824 {&__pyx_n_s_to_list_locals_iterate, __pyx_k_to_list_locals_iterate, sizeof(__pyx_k_to_list_locals_iterate), 0, 0, 1, 1},
2825 {0, 0, 0, 0, 0, 0, 0}
2826 };
2827 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
2828 __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 11, __pyx_L1_error)
2829 return 0;
2830 __pyx_L1_error:;
2831 return -1;
2832 }
2833
2834 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
2835 __Pyx_RefNannyDeclarations
2836 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2837
2838 /* "test_asyncgen.py":15
2839 *
2840 * def to_list(gen):
2841 * async def iterate(): # <<<<<<<<<<<<<<
2842 * res = []
2843 * async for i in gen:
2844 */
2845 __pyx_tuple__2 = PyTuple_Pack(2, __pyx_n_s_res, __pyx_n_s_i); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 15, __pyx_L1_error)
2846 __Pyx_GOTREF(__pyx_tuple__2);
2847 __Pyx_GIVEREF(__pyx_tuple__2);
2848 __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(0, 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_tmp_test_asyncgen_py, __pyx_n_s_iterate, 15, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 15, __pyx_L1_error)
2849
2850 /* "test_asyncgen.py":1
2851 * async def test_gen(): # <<<<<<<<<<<<<<
2852 * a = yield 123
2853 * assert a is None
2854 */
2855 __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_a); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 1, __pyx_L1_error)
2856 __Pyx_GOTREF(__pyx_tuple__4);
2857 __Pyx_GIVEREF(__pyx_tuple__4);
2858 __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(0, 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_tmp_test_asyncgen_py, __pyx_n_s_test_gen, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 1, __pyx_L1_error)
2859
2860 /* "test_asyncgen.py":7
2861 * yield 789
2862 *
2863 * def run_until_complete(coro): # <<<<<<<<<<<<<<
2864 * while True:
2865 * try:
2866 */
2867 __pyx_tuple__5 = PyTuple_Pack(3, __pyx_n_s_coro, __pyx_n_s_fut, __pyx_n_s_ex); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 7, __pyx_L1_error)
2868 __Pyx_GOTREF(__pyx_tuple__5);
2869 __Pyx_GIVEREF(__pyx_tuple__5);
2870 __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 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_tmp_test_asyncgen_py, __pyx_n_s_run_until_complete, 7, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 7, __pyx_L1_error)
2871
2872 /* "test_asyncgen.py":14
2873 * return ex.args[0]
2874 *
2875 * def to_list(gen): # <<<<<<<<<<<<<<
2876 * async def iterate():
2877 * res = []
2878 */
2879 __pyx_tuple__7 = PyTuple_Pack(3, __pyx_n_s_gen, __pyx_n_s_iterate, __pyx_n_s_iterate); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 14, __pyx_L1_error)
2880 __Pyx_GOTREF(__pyx_tuple__7);
2881 __Pyx_GIVEREF(__pyx_tuple__7);
2882 __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 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_tmp_test_asyncgen_py, __pyx_n_s_to_list, 14, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 14, __pyx_L1_error)
2883 __Pyx_RefNannyFinishContext();
2884 return 0;
2885 __pyx_L1_error:;
2886 __Pyx_RefNannyFinishContext();
2887 return -1;
2888 }
2889
2890 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
2891 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2892 __pyx_int_123 = PyInt_FromLong(123); if (unlikely(!__pyx_int_123)) __PYX_ERR(0, 1, __pyx_L1_error)
2893 __pyx_int_456 = PyInt_FromLong(456); if (unlikely(!__pyx_int_456)) __PYX_ERR(0, 1, __pyx_L1_error)
2894 __pyx_int_789 = PyInt_FromLong(789); if (unlikely(!__pyx_int_789)) __PYX_ERR(0, 1, __pyx_L1_error)
2895 return 0;
2896 __pyx_L1_error:;
2897 return -1;
2898 }
2899
2900 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
2901 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
2902 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
2903 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
2904 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
2905 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
2906 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
2907
2908 static int __Pyx_modinit_global_init_code(void) {
2909 __Pyx_RefNannyDeclarations
2910 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
2911 /*--- Global init code ---*/
2912 __Pyx_RefNannyFinishContext();
2913 return 0;
2914 }
2915
2916 static int __Pyx_modinit_variable_export_code(void) {
2917 __Pyx_RefNannyDeclarations
2918 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
2919 /*--- Variable export code ---*/
2920 __Pyx_RefNannyFinishContext();
2921 return 0;
2922 }
2923
2924 static int __Pyx_modinit_function_export_code(void) {
2925 __Pyx_RefNannyDeclarations
2926 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
2927 /*--- Function export code ---*/
2928 __Pyx_RefNannyFinishContext();
2929 return 0;
2930 }
2931
2932 static int __Pyx_modinit_type_init_code(void) {
2933 __Pyx_RefNannyDeclarations
2934 int __pyx_lineno = 0;
2935 const char *__pyx_filename = NULL;
2936 int __pyx_clineno = 0;
2937 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
2938 /*--- Type init code ---*/
2939 if (PyType_Ready(&__pyx_type_13test_asyncgen___pyx_scope_struct__test_gen) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2940 #if PY_VERSION_HEX < 0x030800B1
2941 __pyx_type_13test_asyncgen___pyx_scope_struct__test_gen.tp_print = 0;
2942 #endif
2943 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_13test_asyncgen___pyx_scope_struct__test_gen.tp_dictoffset && __pyx_type_13test_asyncgen___pyx_scope_struct__test_gen.tp_getattro == PyObject_GenericGetAttr)) {
2944 __pyx_type_13test_asyncgen___pyx_scope_struct__test_gen.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
2945 }
2946 __pyx_ptype_13test_asyncgen___pyx_scope_struct__test_gen = &__pyx_type_13test_asyncgen___pyx_scope_struct__test_gen;
2947 if (PyType_Ready(&__pyx_type_13test_asyncgen___pyx_scope_struct_1_to_list) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
2948 #if PY_VERSION_HEX < 0x030800B1
2949 __pyx_type_13test_asyncgen___pyx_scope_struct_1_to_list.tp_print = 0;
2950 #endif
2951 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_13test_asyncgen___pyx_scope_struct_1_to_list.tp_dictoffset && __pyx_type_13test_asyncgen___pyx_scope_struct_1_to_list.tp_getattro == PyObject_GenericGetAttr)) {
2952 __pyx_type_13test_asyncgen___pyx_scope_struct_1_to_list.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
2953 }
2954 __pyx_ptype_13test_asyncgen___pyx_scope_struct_1_to_list = &__pyx_type_13test_asyncgen___pyx_scope_struct_1_to_list;
2955 if (PyType_Ready(&__pyx_type_13test_asyncgen___pyx_scope_struct_2_iterate) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
2956 #if PY_VERSION_HEX < 0x030800B1
2957 __pyx_type_13test_asyncgen___pyx_scope_struct_2_iterate.tp_print = 0;
2958 #endif
2959 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_13test_asyncgen___pyx_scope_struct_2_iterate.tp_dictoffset && __pyx_type_13test_asyncgen___pyx_scope_struct_2_iterate.tp_getattro == PyObject_GenericGetAttr)) {
2960 __pyx_type_13test_asyncgen___pyx_scope_struct_2_iterate.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
2961 }
2962 __pyx_ptype_13test_asyncgen___pyx_scope_struct_2_iterate = &__pyx_type_13test_asyncgen___pyx_scope_struct_2_iterate;
2963 __Pyx_RefNannyFinishContext();
2964 return 0;
2965 __pyx_L1_error:;
2966 __Pyx_RefNannyFinishContext();
2967 return -1;
2968 }
2969
2970 static int __Pyx_modinit_type_import_code(void) {
2971 __Pyx_RefNannyDeclarations
2972 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
2973 /*--- Type import code ---*/
2974 __Pyx_RefNannyFinishContext();
2975 return 0;
2976 }
2977
2978 static int __Pyx_modinit_variable_import_code(void) {
2979 __Pyx_RefNannyDeclarations
2980 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
2981 /*--- Variable import code ---*/
2982 __Pyx_RefNannyFinishContext();
2983 return 0;
2984 }
2985
2986 static int __Pyx_modinit_function_import_code(void) {
2987 __Pyx_RefNannyDeclarations
2988 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
2989 /*--- Function import code ---*/
2990 __Pyx_RefNannyFinishContext();
2991 return 0;
2992 }
2993
2994
2995 #ifndef CYTHON_NO_PYINIT_EXPORT
2996 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
2997 #elif PY_MAJOR_VERSION < 3
2998 #ifdef __cplusplus
2999 #define __Pyx_PyMODINIT_FUNC extern "C" void
3000 #else
3001 #define __Pyx_PyMODINIT_FUNC void
3002 #endif
3003 #else
3004 #ifdef __cplusplus
3005 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
3006 #else
3007 #define __Pyx_PyMODINIT_FUNC PyObject *
3008 #endif
3009 #endif
3010
3011
3012 #if PY_MAJOR_VERSION < 3
3013 __Pyx_PyMODINIT_FUNC inittest_asyncgen(void) CYTHON_SMALL_CODE; /*proto*/
3014 __Pyx_PyMODINIT_FUNC inittest_asyncgen(void)
3015 #else
3016 __Pyx_PyMODINIT_FUNC PyInit_test_asyncgen(void) CYTHON_SMALL_CODE; /*proto*/
3017 __Pyx_PyMODINIT_FUNC PyInit_test_asyncgen(void)
3018 #if CYTHON_PEP489_MULTI_PHASE_INIT
3019 {
3020 return PyModuleDef_Init(&__pyx_moduledef);
3021 }
3022 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
3023 #if PY_VERSION_HEX >= 0x030700A1
3024 static PY_INT64_T main_interpreter_id = -1;
3025 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
3026 if (main_interpreter_id == -1) {
3027 main_interpreter_id = current_id;
3028 return (unlikely(current_id == -1)) ? -1 : 0;
3029 } else if (unlikely(main_interpreter_id != current_id))
3030 #else
3031 static PyInterpreterState *main_interpreter = NULL;
3032 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
3033 if (!main_interpreter) {
3034 main_interpreter = current_interpreter;
3035 } else if (unlikely(main_interpreter != current_interpreter))
3036 #endif
3037 {
3038 PyErr_SetString(
3039 PyExc_ImportError,
3040 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
3041 return -1;
3042 }
3043 return 0;
3044 }
3045 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
3046 PyObject *value = PyObject_GetAttrString(spec, from_name);
3047 int result = 0;
3048 if (likely(value)) {
3049 if (allow_none || value != Py_None) {
3050 result = PyDict_SetItemString(moddict, to_name, value);
3051 }
3052 Py_DECREF(value);
3053 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
3054 PyErr_Clear();
3055 } else {
3056 result = -1;
3057 }
3058 return result;
3059 }
3060 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
3061 PyObject *module = NULL, *moddict, *modname;
3062 if (__Pyx_check_single_interpreter())
3063 return NULL;
3064 if (__pyx_m)
3065 return __Pyx_NewRef(__pyx_m);
3066 modname = PyObject_GetAttrString(spec, "name");
3067 if (unlikely(!modname)) goto bad;
3068 module = PyModule_NewObject(modname);
3069 Py_DECREF(modname);
3070 if (unlikely(!module)) goto bad;
3071 moddict = PyModule_GetDict(module);
3072 if (unlikely(!moddict)) goto bad;
3073 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
3074 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
3075 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
3076 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
3077 return module;
3078 bad:
3079 Py_XDECREF(module);
3080 return NULL;
3081 }
3082
3083
3084 static CYTHON_SMALL_CODE int __pyx_pymod_exec_test_asyncgen(PyObject *__pyx_pyinit_module)
3085 #endif
3086 #endif
3087 {
3088 PyObject *__pyx_t_1 = NULL;
3089 int __pyx_lineno = 0;
3090 const char *__pyx_filename = NULL;
3091 int __pyx_clineno = 0;
3092 __Pyx_RefNannyDeclarations
3093 #if CYTHON_PEP489_MULTI_PHASE_INIT
3094 if (__pyx_m) {
3095 if (__pyx_m == __pyx_pyinit_module) return 0;
3096 PyErr_SetString(PyExc_RuntimeError, "Module 'test_asyncgen' has already been imported. Re-initialisation is not supported.");
3097 return -1;
3098 }
3099 #elif PY_MAJOR_VERSION >= 3
3100 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
3101 #endif
3102 #if CYTHON_REFNANNY
3103 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
3104 if (!__Pyx_RefNanny) {
3105 PyErr_Clear();
3106 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
3107 if (!__Pyx_RefNanny)
3108 Py_FatalError("failed to import 'refnanny' module");
3109 }
3110 #endif
3111 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_test_asyncgen(void)", 0);
3112 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3113 #ifdef __Pxy_PyFrame_Initialize_Offsets
3114 __Pxy_PyFrame_Initialize_Offsets();
3115 #endif
3116 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
3117 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
3118 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
3119 #ifdef __Pyx_CyFunction_USED
3120 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3121 #endif
3122 #ifdef __Pyx_FusedFunction_USED
3123 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3124 #endif
3125 #ifdef __Pyx_Coroutine_USED
3126 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3127 #endif
3128 #ifdef __Pyx_Generator_USED
3129 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3130 #endif
3131 #ifdef __Pyx_AsyncGen_USED
3132 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3133 #endif
3134 #ifdef __Pyx_StopAsyncIteration_USED
3135 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3136 #endif
3137 /*--- Library function declarations ---*/
3138 /*--- Threads initialization code ---*/
3139 #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3140 PyEval_InitThreads();
3141 #endif
3142 /*--- Module creation code ---*/
3143 #if CYTHON_PEP489_MULTI_PHASE_INIT
3144 __pyx_m = __pyx_pyinit_module;
3145 Py_INCREF(__pyx_m);
3146 #else
3147 #if PY_MAJOR_VERSION < 3
3148 __pyx_m = Py_InitModule4("test_asyncgen", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3149 #else
3150 __pyx_m = PyModule_Create(&__pyx_moduledef);
3151 #endif
3152 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
3153 #endif
3154 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
3155 Py_INCREF(__pyx_d);
3156 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
3157 Py_INCREF(__pyx_b);
3158 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
3159 Py_INCREF(__pyx_cython_runtime);
3160 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3161 /*--- Initialize various global constants etc. ---*/
3162 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3163 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3164 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3165 #endif
3166 if (__pyx_module_is_main_test_asyncgen) {
3167 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3168 }
3169 #if PY_MAJOR_VERSION >= 3
3170 {
3171 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
3172 if (!PyDict_GetItemString(modules, "test_asyncgen")) {
3173 if (unlikely(PyDict_SetItemString(modules, "test_asyncgen", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3174 }
3175 }
3176 #endif
3177 /*--- Builtin init code ---*/
3178 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3179 /*--- Constants init code ---*/
3180 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3181 /*--- Global type/function init code ---*/
3182 (void)__Pyx_modinit_global_init_code();
3183 (void)__Pyx_modinit_variable_export_code();
3184 (void)__Pyx_modinit_function_export_code();
3185 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3186 (void)__Pyx_modinit_type_import_code();
3187 (void)__Pyx_modinit_variable_import_code();
3188 (void)__Pyx_modinit_function_import_code();
3189 /*--- Execution code ---*/
3190 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
3191 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3192 #endif
3193
3194 /* "test_asyncgen.py":1
3195 * async def test_gen(): # <<<<<<<<<<<<<<
3196 * a = yield 123
3197 * assert a is None
3198 */
3199 __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_13test_asyncgen_1test_gen, 0, __pyx_n_s_test_gen, NULL, __pyx_n_s_test_asyncgen, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
3200 __Pyx_GOTREF(__pyx_t_1);
3201 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_gen, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3202 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3203
3204 /* "test_asyncgen.py":7
3205 * yield 789
3206 *
3207 * def run_until_complete(coro): # <<<<<<<<<<<<<<
3208 * while True:
3209 * try:
3210 */
3211 __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_13test_asyncgen_4run_until_complete, 0, __pyx_n_s_run_until_complete, NULL, __pyx_n_s_test_asyncgen, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
3212 __Pyx_GOTREF(__pyx_t_1);
3213 if (PyDict_SetItem(__pyx_d, __pyx_n_s_run_until_complete, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
3214 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3215
3216 /* "test_asyncgen.py":14
3217 * return ex.args[0]
3218 *
3219 * def to_list(gen): # <<<<<<<<<<<<<<
3220 * async def iterate():
3221 * res = []
3222 */
3223 __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_13test_asyncgen_6to_list, 0, __pyx_n_s_to_list, NULL, __pyx_n_s_test_asyncgen, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
3224 __Pyx_GOTREF(__pyx_t_1);
3225 if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_list, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
3226 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3227
3228 /* "test_asyncgen.py":1
3229 * async def test_gen(): # <<<<<<<<<<<<<<
3230 * a = yield 123
3231 * assert a is None
3232 */
3233 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
3234 __Pyx_GOTREF(__pyx_t_1);
3235 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3236 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3237
3238 /*--- Wrapped vars code ---*/
3239
3240 goto __pyx_L0;
3241 __pyx_L1_error:;
3242 __Pyx_XDECREF(__pyx_t_1);
3243 if (__pyx_m) {
3244 if (__pyx_d) {
3245 __Pyx_AddTraceback("init test_asyncgen", __pyx_clineno, __pyx_lineno, __pyx_filename);
3246 }
3247 Py_CLEAR(__pyx_m);
3248 } else if (!PyErr_Occurred()) {
3249 PyErr_SetString(PyExc_ImportError, "init test_asyncgen");
3250 }
3251 __pyx_L0:;
3252 __Pyx_RefNannyFinishContext();
3253 #if CYTHON_PEP489_MULTI_PHASE_INIT
3254 return (__pyx_m != NULL) ? 0 : -1;
3255 #elif PY_MAJOR_VERSION >= 3
3256 return __pyx_m;
3257 #else
3258 return;
3259 #endif
3260 }
3261
3262 /* --- Runtime support code --- */
3263 /* Refnanny */
3264 #if CYTHON_REFNANNY
3265 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
3266 PyObject *m = NULL, *p = NULL;
3267 void *r = NULL;
3268 m = PyImport_ImportModule(modname);
3269 if (!m) goto end;
3270 p = PyObject_GetAttrString(m, "RefNannyAPI");
3271 if (!p) goto end;
3272 r = PyLong_AsVoidPtr(p);
3273 end:
3274 Py_XDECREF(p);
3275 Py_XDECREF(m);
3276 return (__Pyx_RefNannyAPIStruct *)r;
3277 }
3278 #endif
3279
3280 /* PyObjectGetAttrStr */
3281 #if CYTHON_USE_TYPE_SLOTS
3282 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
3283 PyTypeObject* tp = Py_TYPE(obj);
3284 if (likely(tp->tp_getattro))
3285 return tp->tp_getattro(obj, attr_name);
3286 #if PY_MAJOR_VERSION < 3
3287 if (likely(tp->tp_getattr))
3288 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
3289 #endif
3290 return PyObject_GetAttr(obj, attr_name);
3291 }
3292 #endif
3293
3294 /* GetBuiltinName */
3295 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
3296 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
3297 if (unlikely(!result)) {
3298 PyErr_Format(PyExc_NameError,
3299 #if PY_MAJOR_VERSION >= 3
3300 "name '%U' is not defined", name);
3301 #else
3302 "name '%.200s' is not defined", PyString_AS_STRING(name));
3303 #endif
3304 }
3305 return result;
3306 }
3307
3308 /* StopAsyncIteration */
3309 #if PY_VERSION_HEX < 0x030500B1
3310 static PyTypeObject __Pyx__PyExc_StopAsyncIteration_type = {
3311 PyVarObject_HEAD_INIT(0, 0)
3312 "StopAsyncIteration",
3313 sizeof(PyBaseExceptionObject),
3314 0,
3315 0,
3316 0,
3317 0,
3318 0,
3319 0,
3320 0,
3321 0,
3322 0,
3323 0,
3324 0,
3325 0,
3326 0,
3327 0,
3328 0,
3329 0,
3330 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
3331 PyDoc_STR("Signal the end from iterator.__anext__()."),
3332 0,
3333 0,
3334 0,
3335 0,
3336 0,
3337 0,
3338 0,
3339 0,
3340 0,
3341 0,
3342 0,
3343 0,
3344 0,
3345 0,
3346 0,
3347 0,
3348 0,
3349 0,
3350 0,
3351 0,
3352 0,
3353 0,
3354 0,
3355 0,
3356 0,
3357 0,
3358 #if PY_VERSION_HEX >= 0x030400a1
3359 0,
3360 #endif
3361 #if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM+0 >= 0x06000000
3362 0,
3363 #endif
3364 };
3365 #endif
3366 static int __pyx_StopAsyncIteration_init(void) {
3367 #if PY_VERSION_HEX >= 0x030500B1
3368 __Pyx_PyExc_StopAsyncIteration = PyExc_StopAsyncIteration;
3369 #else
3370 PyObject *builtins = PyEval_GetBuiltins();
3371 if (likely(builtins)) {
3372 PyObject *exc = PyMapping_GetItemString(builtins, (char*) "StopAsyncIteration");
3373 if (exc) {
3374 __Pyx_PyExc_StopAsyncIteration = exc;
3375 return 0;
3376 }
3377 }
3378 PyErr_Clear();
3379 __Pyx__PyExc_StopAsyncIteration_type.tp_traverse = ((PyTypeObject*)PyExc_BaseException)->tp_traverse;
3380 __Pyx__PyExc_StopAsyncIteration_type.tp_clear = ((PyTypeObject*)PyExc_BaseException)->tp_clear;
3381 __Pyx__PyExc_StopAsyncIteration_type.tp_dictoffset = ((PyTypeObject*)PyExc_BaseException)->tp_dictoffset;
3382 __Pyx__PyExc_StopAsyncIteration_type.tp_base = (PyTypeObject*)PyExc_Exception;
3383 __Pyx_PyExc_StopAsyncIteration = (PyObject*) __Pyx_FetchCommonType(&__Pyx__PyExc_StopAsyncIteration_type);
3384 if (unlikely(!__Pyx_PyExc_StopAsyncIteration))
3385 return -1;
3386 if (builtins && unlikely(PyMapping_SetItemString(builtins, (char*) "StopAsyncIteration", __Pyx_PyExc_StopAsyncIteration) < 0))
3387 return -1;
3388 #endif
3389 return 0;
3390 }
3391
3392 /* PyCFunctionFastCall */
3393 #if CYTHON_FAST_PYCCALL
3394 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
3395 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
3396 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
3397 PyObject *self = PyCFunction_GET_SELF(func);
3398 int flags = PyCFunction_GET_FLAGS(func);
3399 assert(PyCFunction_Check(func));
3400 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
3401 assert(nargs >= 0);
3402 assert(nargs == 0 || args != NULL);
3403 /* _PyCFunction_FastCallDict() must not be called with an exception set,
3404 because it may clear it (directly or indirectly) and so the
3405 caller loses its exception */
3406 assert(!PyErr_Occurred());
3407 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
3408 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
3409 } else {
3410 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
3411 }
3412 }
3413 #endif
3414
3415 /* PyFunctionFastCall */
3416 #if CYTHON_FAST_PYCALL
3417 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
3418 PyObject *globals) {
3419 PyFrameObject *f;
3420 PyThreadState *tstate = __Pyx_PyThreadState_Current;
3421 PyObject **fastlocals;
3422 Py_ssize_t i;
3423 PyObject *result;
3424 assert(globals != NULL);
3425 /* XXX Perhaps we should create a specialized
3426 PyFrame_New() that doesn't take locals, but does
3427 take builtins without sanity checking them.
3428 */
3429 assert(tstate != NULL);
3430 f = PyFrame_New(tstate, co, globals, NULL);
3431 if (f == NULL) {
3432 return NULL;
3433 }
3434 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
3435 for (i = 0; i < na; i++) {
3436 Py_INCREF(*args);
3437 fastlocals[i] = *args++;
3438 }
3439 result = PyEval_EvalFrameEx(f,0);
3440 ++tstate->recursion_depth;
3441 Py_DECREF(f);
3442 --tstate->recursion_depth;
3443 return result;
3444 }
3445 #if 1 || PY_VERSION_HEX < 0x030600B1
3446 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
3447 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
3448 PyObject *globals = PyFunction_GET_GLOBALS(func);
3449 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
3450 PyObject *closure;
3451 #if PY_MAJOR_VERSION >= 3
3452 PyObject *kwdefs;
3453 #endif
3454 PyObject *kwtuple, **k;
3455 PyObject **d;
3456 Py_ssize_t nd;
3457 Py_ssize_t nk;
3458 PyObject *result;
3459 assert(kwargs == NULL || PyDict_Check(kwargs));
3460 nk = kwargs ? PyDict_Size(kwargs) : 0;
3461 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
3462 return NULL;
3463 }
3464 if (
3465 #if PY_MAJOR_VERSION >= 3
3466 co->co_kwonlyargcount == 0 &&
3467 #endif
3468 likely(kwargs == NULL || nk == 0) &&
3469 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
3470 if (argdefs == NULL && co->co_argcount == nargs) {
3471 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
3472 goto done;
3473 }
3474 else if (nargs == 0 && argdefs != NULL
3475 && co->co_argcount == Py_SIZE(argdefs)) {
3476 /* function called with no arguments, but all parameters have
3477 a default value: use default values as arguments .*/
3478 args = &PyTuple_GET_ITEM(argdefs, 0);
3479 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
3480 goto done;
3481 }
3482 }
3483 if (kwargs != NULL) {
3484 Py_ssize_t pos, i;
3485 kwtuple = PyTuple_New(2 * nk);
3486 if (kwtuple == NULL) {
3487 result = NULL;
3488 goto done;
3489 }
3490 k = &PyTuple_GET_ITEM(kwtuple, 0);
3491 pos = i = 0;
3492 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
3493 Py_INCREF(k[i]);
3494 Py_INCREF(k[i+1]);
3495 i += 2;
3496 }
3497 nk = i / 2;
3498 }
3499 else {
3500 kwtuple = NULL;
3501 k = NULL;
3502 }
3503 closure = PyFunction_GET_CLOSURE(func);
3504 #if PY_MAJOR_VERSION >= 3
3505 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
3506 #endif
3507 if (argdefs != NULL) {
3508 d = &PyTuple_GET_ITEM(argdefs, 0);
3509 nd = Py_SIZE(argdefs);
3510 }
3511 else {
3512 d = NULL;
3513 nd = 0;
3514 }
3515 #if PY_MAJOR_VERSION >= 3
3516 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
3517 args, (int)nargs,
3518 k, (int)nk,
3519 d, (int)nd, kwdefs, closure);
3520 #else
3521 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
3522 args, (int)nargs,
3523 k, (int)nk,
3524 d, (int)nd, closure);
3525 #endif
3526 Py_XDECREF(kwtuple);
3527 done:
3528 Py_LeaveRecursiveCall();
3529 return result;
3530 }
3531 #endif
3532 #endif
3533
3534 /* PyObjectCall */
3535 #if CYTHON_COMPILING_IN_CPYTHON
3536 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
3537 PyObject *result;
3538 ternaryfunc call = Py_TYPE(func)->tp_call;
3539 if (unlikely(!call))
3540 return PyObject_Call(func, arg, kw);
3541 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3542 return NULL;
3543 result = (*call)(func, arg, kw);
3544 Py_LeaveRecursiveCall();
3545 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3546 PyErr_SetString(
3547 PyExc_SystemError,
3548 "NULL result without error in PyObject_Call");
3549 }
3550 return result;
3551 }
3552 #endif
3553
3554 /* PyObjectCall2Args */
3555 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
3556 PyObject *args, *result = NULL;
3557 #if CYTHON_FAST_PYCALL
3558 if (PyFunction_Check(function)) {
3559 PyObject *args[2] = {arg1, arg2};
3560 return __Pyx_PyFunction_FastCall(function, args, 2);
3561 }
3562 #endif
3563 #if CYTHON_FAST_PYCCALL
3564 if (__Pyx_PyFastCFunction_Check(function)) {
3565 PyObject *args[2] = {arg1, arg2};
3566 return __Pyx_PyCFunction_FastCall(function, args, 2);
3567 }
3568 #endif
3569 args = PyTuple_New(2);
3570 if (unlikely(!args)) goto done;
3571 Py_INCREF(arg1);
3572 PyTuple_SET_ITEM(args, 0, arg1);
3573 Py_INCREF(arg2);
3574 PyTuple_SET_ITEM(args, 1, arg2);
3575 Py_INCREF(function);
3576 result = __Pyx_PyObject_Call(function, args, NULL);
3577 Py_DECREF(args);
3578 Py_DECREF(function);
3579 done:
3580 return result;
3581 }
3582
3583 /* PyObjectCallMethO */
3584 #if CYTHON_COMPILING_IN_CPYTHON
3585 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
3586 PyObject *self, *result;
3587 PyCFunction cfunc;
3588 cfunc = PyCFunction_GET_FUNCTION(func);
3589 self = PyCFunction_GET_SELF(func);
3590 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3591 return NULL;
3592 result = cfunc(self, arg);
3593 Py_LeaveRecursiveCall();
3594 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3595 PyErr_SetString(
3596 PyExc_SystemError,
3597 "NULL result without error in PyObject_Call");
3598 }
3599 return result;
3600 }
3601 #endif
3602
3603 /* PyObjectCallOneArg */
3604 #if CYTHON_COMPILING_IN_CPYTHON
3605 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3606 PyObject *result;
3607 PyObject *args = PyTuple_New(1);
3608 if (unlikely(!args)) return NULL;
3609 Py_INCREF(arg);
3610 PyTuple_SET_ITEM(args, 0, arg);
3611 result = __Pyx_PyObject_Call(func, args, NULL);
3612 Py_DECREF(args);
3613 return result;
3614 }
3615 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3616 #if CYTHON_FAST_PYCALL
3617 if (PyFunction_Check(func)) {
3618 return __Pyx_PyFunction_FastCall(func, &arg, 1);
3619 }
3620 #endif
3621 if (likely(PyCFunction_Check(func))) {
3622 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
3623 return __Pyx_PyObject_CallMethO(func, arg);
3624 #if CYTHON_FAST_PYCCALL
3625 } else if (__Pyx_PyFastCFunction_Check(func)) {
3626 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
3627 #endif
3628 }
3629 }
3630 return __Pyx__PyObject_CallOneArg(func, arg);
3631 }
3632 #else
3633 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3634 PyObject *result;
3635 PyObject *args = PyTuple_Pack(1, arg);
3636 if (unlikely(!args)) return NULL;
3637 result = __Pyx_PyObject_Call(func, args, NULL);
3638 Py_DECREF(args);
3639 return result;
3640 }
3641 #endif
3642
3643 /* GetTopmostException */
3644 #if CYTHON_USE_EXC_INFO_STACK
3645 static _PyErr_StackItem *
3646 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
3647 {
3648 _PyErr_StackItem *exc_info = tstate->exc_info;
3649 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
3650 exc_info->previous_item != NULL)
3651 {
3652 exc_info = exc_info->previous_item;
3653 }
3654 return exc_info;
3655 }
3656 #endif
3657
3658 /* SaveResetException */
3659 #if CYTHON_FAST_THREAD_STATE
3660 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3661 #if CYTHON_USE_EXC_INFO_STACK
3662 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
3663 *type = exc_info->exc_type;
3664 *value = exc_info->exc_value;
3665 *tb = exc_info->exc_traceback;
3666 #else
3667 *type = tstate->exc_type;
3668 *value = tstate->exc_value;
3669 *tb = tstate->exc_traceback;
3670 #endif
3671 Py_XINCREF(*type);
3672 Py_XINCREF(*value);
3673 Py_XINCREF(*tb);
3674 }
3675 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3676 PyObject *tmp_type, *tmp_value, *tmp_tb;
3677 #if CYTHON_USE_EXC_INFO_STACK
3678 _PyErr_StackItem *exc_info = tstate->exc_info;
3679 tmp_type = exc_info->exc_type;
3680 tmp_value = exc_info->exc_value;
3681 tmp_tb = exc_info->exc_traceback;
3682 exc_info->exc_type = type;
3683 exc_info->exc_value = value;
3684 exc_info->exc_traceback = tb;
3685 #else
3686 tmp_type = tstate->exc_type;
3687 tmp_value = tstate->exc_value;
3688 tmp_tb = tstate->exc_traceback;
3689 tstate->exc_type = type;
3690 tstate->exc_value = value;
3691 tstate->exc_traceback = tb;
3692 #endif
3693 Py_XDECREF(tmp_type);
3694 Py_XDECREF(tmp_value);
3695 Py_XDECREF(tmp_tb);
3696 }
3697 #endif
3698
3699 /* PyErrExceptionMatches */
3700 #if CYTHON_FAST_THREAD_STATE
3701 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3702 Py_ssize_t i, n;
3703 n = PyTuple_GET_SIZE(tuple);
3704 #if PY_MAJOR_VERSION >= 3
3705 for (i=0; i<n; i++) {
3706 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3707 }
3708 #endif
3709 for (i=0; i<n; i++) {
3710 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
3711 }
3712 return 0;
3713 }
3714 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
3715 PyObject *exc_type = tstate->curexc_type;
3716 if (exc_type == err) return 1;
3717 if (unlikely(!exc_type)) return 0;
3718 if (unlikely(PyTuple_Check(err)))
3719 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
3720 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
3721 }
3722 #endif
3723
3724 /* GetException */
3725 #if CYTHON_FAST_THREAD_STATE
3726 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
3727 #else
3728 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
3729 #endif
3730 {
3731 PyObject *local_type, *local_value, *local_tb;
3732 #if CYTHON_FAST_THREAD_STATE
3733 PyObject *tmp_type, *tmp_value, *tmp_tb;
3734 local_type = tstate->curexc_type;
3735 local_value = tstate->curexc_value;
3736 local_tb = tstate->curexc_traceback;
3737 tstate->curexc_type = 0;
3738 tstate->curexc_value = 0;
3739 tstate->curexc_traceback = 0;
3740 #else
3741 PyErr_Fetch(&local_type, &local_value, &local_tb);
3742 #endif
3743 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
3744 #if CYTHON_FAST_THREAD_STATE
3745 if (unlikely(tstate->curexc_type))
3746 #else
3747 if (unlikely(PyErr_Occurred()))
3748 #endif
3749 goto bad;
3750 #if PY_MAJOR_VERSION >= 3
3751 if (local_tb) {
3752 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
3753 goto bad;
3754 }
3755 #endif
3756 Py_XINCREF(local_tb);
3757 Py_XINCREF(local_type);
3758 Py_XINCREF(local_value);
3759 *type = local_type;
3760 *value = local_value;
3761 *tb = local_tb;
3762 #if CYTHON_FAST_THREAD_STATE
3763 #if CYTHON_USE_EXC_INFO_STACK
3764 {
3765 _PyErr_StackItem *exc_info = tstate->exc_info;
3766 tmp_type = exc_info->exc_type;
3767 tmp_value = exc_info->exc_value;
3768 tmp_tb = exc_info->exc_traceback;
3769 exc_info->exc_type = local_type;
3770 exc_info->exc_value = local_value;
3771 exc_info->exc_traceback = local_tb;
3772 }
3773 #else
3774 tmp_type = tstate->exc_type;
3775 tmp_value = tstate->exc_value;
3776 tmp_tb = tstate->exc_traceback;
3777 tstate->exc_type = local_type;
3778 tstate->exc_value = local_value;
3779 tstate->exc_traceback = local_tb;
3780 #endif
3781 Py_XDECREF(tmp_type);
3782 Py_XDECREF(tmp_value);
3783 Py_XDECREF(tmp_tb);
3784 #else
3785 PyErr_SetExcInfo(local_type, local_value, local_tb);
3786 #endif
3787 return 0;
3788 bad:
3789 *type = 0;
3790 *value = 0;
3791 *tb = 0;
3792 Py_XDECREF(local_type);
3793 Py_XDECREF(local_value);
3794 Py_XDECREF(local_tb);
3795 return -1;
3796 }
3797
3798 /* GetItemInt */
3799 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
3800 PyObject *r;
3801 if (!j) return NULL;
3802 r = PyObject_GetItem(o, j);
3803 Py_DECREF(j);
3804 return r;
3805 }
3806 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
3807 CYTHON_NCP_UNUSED int wraparound,
3808 CYTHON_NCP_UNUSED int boundscheck) {
3809 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3810 Py_ssize_t wrapped_i = i;
3811 if (wraparound & unlikely(i < 0)) {
3812 wrapped_i += PyList_GET_SIZE(o);
3813 }
3814 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
3815 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
3816 Py_INCREF(r);
3817 return r;
3818 }
3819 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
3820 #else
3821 return PySequence_GetItem(o, i);
3822 #endif
3823 }
3824 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
3825 CYTHON_NCP_UNUSED int wraparound,
3826 CYTHON_NCP_UNUSED int boundscheck) {
3827 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3828 Py_ssize_t wrapped_i = i;
3829 if (wraparound & unlikely(i < 0)) {
3830 wrapped_i += PyTuple_GET_SIZE(o);
3831 }
3832 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
3833 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
3834 Py_INCREF(r);
3835 return r;
3836 }
3837 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
3838 #else
3839 return PySequence_GetItem(o, i);
3840 #endif
3841 }
3842 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
3843 CYTHON_NCP_UNUSED int wraparound,
3844 CYTHON_NCP_UNUSED int boundscheck) {
3845 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
3846 if (is_list || PyList_CheckExact(o)) {
3847 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
3848 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
3849 PyObject *r = PyList_GET_ITEM(o, n);
3850 Py_INCREF(r);
3851 return r;
3852 }
3853 }
3854 else if (PyTuple_CheckExact(o)) {
3855 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
3856 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
3857 PyObject *r = PyTuple_GET_ITEM(o, n);
3858 Py_INCREF(r);
3859 return r;
3860 }
3861 } else {
3862 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
3863 if (likely(m && m->sq_item)) {
3864 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
3865 Py_ssize_t l = m->sq_length(o);
3866 if (likely(l >= 0)) {
3867 i += l;
3868 } else {
3869 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
3870 return NULL;
3871 PyErr_Clear();
3872 }
3873 }
3874 return m->sq_item(o, i);
3875 }
3876 }
3877 #else
3878 if (is_list || PySequence_Check(o)) {
3879 return PySequence_GetItem(o, i);
3880 }
3881 #endif
3882 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
3883 }
3884
3885 /* None */
3886 static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
3887 PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
3888 }
3889
3890 /* PyObjectCallNoArg */
3891 #if CYTHON_COMPILING_IN_CPYTHON
3892 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
3893 #if CYTHON_FAST_PYCALL
3894 if (PyFunction_Check(func)) {
3895 return __Pyx_PyFunction_FastCall(func, NULL, 0);
3896 }
3897 #endif
3898 #if defined(__Pyx_CyFunction_USED) && defined(NDEBUG)
3899 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
3900 #else
3901 if (likely(PyCFunction_Check(func)))
3902 #endif
3903 {
3904 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
3905 return __Pyx_PyObject_CallMethO(func, NULL);
3906 }
3907 }
3908 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
3909 }
3910 #endif
3911
3912 /* PyObjectGetMethod */
3913 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
3914 PyObject *attr;
3915 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
3916 PyTypeObject *tp = Py_TYPE(obj);
3917 PyObject *descr;
3918 descrgetfunc f = NULL;
3919 PyObject **dictptr, *dict;
3920 int meth_found = 0;
3921 assert (*method == NULL);
3922 if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
3923 attr = __Pyx_PyObject_GetAttrStr(obj, name);
3924 goto try_unpack;
3925 }
3926 if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
3927 return 0;
3928 }
3929 descr = _PyType_Lookup(tp, name);
3930 if (likely(descr != NULL)) {
3931 Py_INCREF(descr);
3932 #if PY_MAJOR_VERSION >= 3
3933 #ifdef __Pyx_CyFunction_USED
3934 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
3935 #else
3936 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
3937 #endif
3938 #else
3939 #ifdef __Pyx_CyFunction_USED
3940 if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
3941 #else
3942 if (likely(PyFunction_Check(descr)))
3943 #endif
3944 #endif
3945 {
3946 meth_found = 1;
3947 } else {
3948 f = Py_TYPE(descr)->tp_descr_get;
3949 if (f != NULL && PyDescr_IsData(descr)) {
3950 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
3951 Py_DECREF(descr);
3952 goto try_unpack;
3953 }
3954 }
3955 }
3956 dictptr = _PyObject_GetDictPtr(obj);
3957 if (dictptr != NULL && (dict = *dictptr) != NULL) {
3958 Py_INCREF(dict);
3959 attr = __Pyx_PyDict_GetItemStr(dict, name);
3960 if (attr != NULL) {
3961 Py_INCREF(attr);
3962 Py_DECREF(dict);
3963 Py_XDECREF(descr);
3964 goto try_unpack;
3965 }
3966 Py_DECREF(dict);
3967 }
3968 if (meth_found) {
3969 *method = descr;
3970 return 1;
3971 }
3972 if (f != NULL) {
3973 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
3974 Py_DECREF(descr);
3975 goto try_unpack;
3976 }
3977 if (descr != NULL) {
3978 *method = descr;
3979 return 0;
3980 }
3981 PyErr_Format(PyExc_AttributeError,
3982 #if PY_MAJOR_VERSION >= 3
3983 "'%.50s' object has no attribute '%U'",
3984 tp->tp_name, name);
3985 #else
3986 "'%.50s' object has no attribute '%.400s'",
3987 tp->tp_name, PyString_AS_STRING(name));
3988 #endif
3989 return 0;
3990 #else
3991 attr = __Pyx_PyObject_GetAttrStr(obj, name);
3992 goto try_unpack;
3993 #endif
3994 try_unpack:
3995 #if CYTHON_UNPACK_METHODS
3996 if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
3997 PyObject *function = PyMethod_GET_FUNCTION(attr);
3998 Py_INCREF(function);
3999 Py_DECREF(attr);
4000 *method = function;
4001 return 1;
4002 }
4003 #endif
4004 *method = attr;
4005 return 0;
4006 }
4007
4008 /* GetAwaitIter */
4009 static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
4010 #ifdef __Pyx_Coroutine_USED
4011 if (__Pyx_Coroutine_Check(o)) {
4012 return __Pyx_NewRef(o);
4013 }
4014 #endif
4015 return __Pyx__Coroutine_GetAwaitableIter(o);
4016 }
4017 static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
4018 #if PY_VERSION_HEX >= 0x030600B3 || defined(_PyErr_FormatFromCause)
4019 _PyErr_FormatFromCause(
4020 PyExc_TypeError,
4021 "'async for' received an invalid object "
4022 "from __anext__: %.100s",
4023 Py_TYPE(source)->tp_name);
4024 #elif PY_MAJOR_VERSION >= 3
4025 PyObject *exc, *val, *val2, *tb;
4026 assert(PyErr_Occurred());
4027 PyErr_Fetch(&exc, &val, &tb);
4028 PyErr_NormalizeException(&exc, &val, &tb);
4029 if (tb != NULL) {
4030 PyException_SetTraceback(val, tb);
4031 Py_DECREF(tb);
4032 }
4033 Py_DECREF(exc);
4034 assert(!PyErr_Occurred());
4035 PyErr_Format(
4036 PyExc_TypeError,
4037 "'async for' received an invalid object "
4038 "from __anext__: %.100s",
4039 Py_TYPE(source)->tp_name);
4040 PyErr_Fetch(&exc, &val2, &tb);
4041 PyErr_NormalizeException(&exc, &val2, &tb);
4042 Py_INCREF(val);
4043 PyException_SetCause(val2, val);
4044 PyException_SetContext(val2, val);
4045 PyErr_Restore(exc, val2, tb);
4046 #else
4047 source++;
4048 #endif
4049 }
4050 static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
4051 PyObject *res;
4052 #if CYTHON_USE_ASYNC_SLOTS
4053 __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
4054 if (likely(am && am->am_await)) {
4055 res = (*am->am_await)(obj);
4056 } else
4057 #endif
4058 #if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact)
4059 if (PyCoro_CheckExact(obj)) {
4060 return __Pyx_NewRef(obj);
4061 } else
4062 #endif
4063 #if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE)
4064 #if PY_VERSION_HEX >= 0x030C00A6
4065 if (PyGen_CheckExact(obj) && (PyGen_GetCode(obj)->co_flags & CO_ITERABLE_COROUTINE)) {
4066 #else
4067 if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) {
4068 #endif
4069 return __Pyx_NewRef(obj);
4070 } else
4071 #endif
4072 {
4073 PyObject *method = NULL;
4074 int is_method = __Pyx_PyObject_GetMethod(obj, __pyx_n_s_await, &method);
4075 if (likely(is_method)) {
4076 res = __Pyx_PyObject_CallOneArg(method, obj);
4077 } else if (likely(method)) {
4078 res = __Pyx_PyObject_CallNoArg(method);
4079 } else
4080 goto slot_error;
4081 Py_DECREF(method);
4082 }
4083 if (unlikely(!res)) {
4084 __Pyx_Coroutine_AwaitableIterError(obj);
4085 goto bad;
4086 }
4087 if (unlikely(!PyIter_Check(res))) {
4088 PyErr_Format(PyExc_TypeError,
4089 "__await__() returned non-iterator of type '%.100s'",
4090 Py_TYPE(res)->tp_name);
4091 Py_CLEAR(res);
4092 } else {
4093 int is_coroutine = 0;
4094 #ifdef __Pyx_Coroutine_USED
4095 is_coroutine |= __Pyx_Coroutine_Check(res);
4096 #endif
4097 #if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact)
4098 is_coroutine |= PyCoro_CheckExact(res);
4099 #endif
4100 if (unlikely(is_coroutine)) {
4101 /* __await__ must return an *iterator*, not
4102 a coroutine or another awaitable (see PEP 492) */
4103 PyErr_SetString(PyExc_TypeError,
4104 "__await__() returned a coroutine");
4105 Py_CLEAR(res);
4106 }
4107 }
4108 return res;
4109 slot_error:
4110 PyErr_Format(PyExc_TypeError,
4111 "object %.100s can't be used in 'await' expression",
4112 Py_TYPE(obj)->tp_name);
4113 bad:
4114 return NULL;
4115 }
4116
4117 /* PyObjectCallMethod0 */
4118 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
4119 PyObject *method = NULL, *result = NULL;
4120 int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
4121 if (likely(is_method)) {
4122 result = __Pyx_PyObject_CallOneArg(method, obj);
4123 Py_DECREF(method);
4124 return result;
4125 }
4126 if (unlikely(!method)) goto bad;
4127 result = __Pyx_PyObject_CallNoArg(method);
4128 Py_DECREF(method);
4129 bad:
4130 return result;
4131 }
4132
4133 /* AsyncIter */
4134 static PyObject *__Pyx_Coroutine_GetAsyncIter_Generic(PyObject *obj) {
4135 #if PY_VERSION_HEX < 0x030500B1
4136 {
4137 PyObject *iter = __Pyx_PyObject_CallMethod0(obj, __pyx_n_s_aiter);
4138 if (likely(iter))
4139 return iter;
4140 if (!PyErr_ExceptionMatches(PyExc_AttributeError))
4141 return NULL;
4142 }
4143 #else
4144 if ((0)) (void) __Pyx_PyObject_CallMethod0(obj, __pyx_n_s_aiter);
4145 #endif
4146 PyErr_Format(PyExc_TypeError, "'async for' requires an object with __aiter__ method, got %.100s",
4147 Py_TYPE(obj)->tp_name);
4148 return NULL;
4149 }
4150 static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
4151 #ifdef __Pyx_AsyncGen_USED
4152 if (__Pyx_AsyncGen_CheckExact(obj)) {
4153 return __Pyx_NewRef(obj);
4154 }
4155 #endif
4156 #if CYTHON_USE_ASYNC_SLOTS
4157 {
4158 __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
4159 if (likely(am && am->am_aiter)) {
4160 return (*am->am_aiter)(obj);
4161 }
4162 }
4163 #endif
4164 return __Pyx_Coroutine_GetAsyncIter_Generic(obj);
4165 }
4166 static PyObject *__Pyx__Coroutine_AsyncIterNext(PyObject *obj) {
4167 #if PY_VERSION_HEX < 0x030500B1
4168 {
4169 PyObject *value = __Pyx_PyObject_CallMethod0(obj, __pyx_n_s_anext);
4170 if (likely(value))
4171 return value;
4172 }
4173 if (PyErr_ExceptionMatches(PyExc_AttributeError))
4174 #endif
4175 PyErr_Format(PyExc_TypeError, "'async for' requires an object with __anext__ method, got %.100s",
4176 Py_TYPE(obj)->tp_name);
4177 return NULL;
4178 }
4179 static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
4180 #ifdef __Pyx_AsyncGen_USED
4181 if (__Pyx_AsyncGen_CheckExact(obj)) {
4182 return __Pyx_async_gen_anext(obj);
4183 }
4184 #endif
4185 #if CYTHON_USE_ASYNC_SLOTS
4186 {
4187 __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
4188 if (likely(am && am->am_anext)) {
4189 return (*am->am_anext)(obj);
4190 }
4191 }
4192 #endif
4193 return __Pyx__Coroutine_AsyncIterNext(obj);
4194 }
4195
4196 /* FetchCommonType */
4197 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
4198 PyObject* fake_module;
4199 PyTypeObject* cached_type = NULL;
4200 fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
4201 if (!fake_module) return NULL;
4202 Py_INCREF(fake_module);
4203 cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
4204 if (cached_type) {
4205 if (!PyType_Check((PyObject*)cached_type)) {
4206 PyErr_Format(PyExc_TypeError,
4207 "Shared Cython type %.200s is not a type object",
4208 type->tp_name);
4209 goto bad;
4210 }
4211 if (cached_type->tp_basicsize != type->tp_basicsize) {
4212 PyErr_Format(PyExc_TypeError,
4213 "Shared Cython type %.200s has the wrong size, try recompiling",
4214 type->tp_name);
4215 goto bad;
4216 }
4217 } else {
4218 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
4219 PyErr_Clear();
4220 if (PyType_Ready(type) < 0) goto bad;
4221 if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
4222 goto bad;
4223 Py_INCREF(type);
4224 cached_type = type;
4225 }
4226 done:
4227 Py_DECREF(fake_module);
4228 return cached_type;
4229 bad:
4230 Py_XDECREF(cached_type);
4231 cached_type = NULL;
4232 goto done;
4233 }
4234
4235 /* PyErrFetchRestore */
4236 #if CYTHON_FAST_THREAD_STATE
4237 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
4238 PyObject *tmp_type, *tmp_value, *tmp_tb;
4239 tmp_type = tstate->curexc_type;
4240 tmp_value = tstate->curexc_value;
4241 tmp_tb = tstate->curexc_traceback;
4242 tstate->curexc_type = type;
4243 tstate->curexc_value = value;
4244 tstate->curexc_traceback = tb;
4245 Py_XDECREF(tmp_type);
4246 Py_XDECREF(tmp_value);
4247 Py_XDECREF(tmp_tb);
4248 }
4249 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4250 *type = tstate->curexc_type;
4251 *value = tstate->curexc_value;
4252 *tb = tstate->curexc_traceback;
4253 tstate->curexc_type = 0;
4254 tstate->curexc_value = 0;
4255 tstate->curexc_traceback = 0;
4256 }
4257 #endif
4258
4259 /* RaiseException */
4260 #if PY_MAJOR_VERSION < 3
4261 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
4262 CYTHON_UNUSED PyObject *cause) {
4263 __Pyx_PyThreadState_declare
4264 Py_XINCREF(type);
4265 if (!value || value == Py_None)
4266 value = NULL;
4267 else
4268 Py_INCREF(value);
4269 if (!tb || tb == Py_None)
4270 tb = NULL;
4271 else {
4272 Py_INCREF(tb);
4273 if (!PyTraceBack_Check(tb)) {
4274 PyErr_SetString(PyExc_TypeError,
4275 "raise: arg 3 must be a traceback or None");
4276 goto raise_error;
4277 }
4278 }
4279 if (PyType_Check(type)) {
4280 #if CYTHON_COMPILING_IN_PYPY
4281 if (!value) {
4282 Py_INCREF(Py_None);
4283 value = Py_None;
4284 }
4285 #endif
4286 PyErr_NormalizeException(&type, &value, &tb);
4287 } else {
4288 if (value) {
4289 PyErr_SetString(PyExc_TypeError,
4290 "instance exception may not have a separate value");
4291 goto raise_error;
4292 }
4293 value = type;
4294 type = (PyObject*) Py_TYPE(type);
4295 Py_INCREF(type);
4296 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
4297 PyErr_SetString(PyExc_TypeError,
4298 "raise: exception class must be a subclass of BaseException");
4299 goto raise_error;
4300 }
4301 }
4302 __Pyx_PyThreadState_assign
4303 __Pyx_ErrRestore(type, value, tb);
4304 return;
4305 raise_error:
4306 Py_XDECREF(value);
4307 Py_XDECREF(type);
4308 Py_XDECREF(tb);
4309 return;
4310 }
4311 #else
4312 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
4313 PyObject* owned_instance = NULL;
4314 if (tb == Py_None) {
4315 tb = 0;
4316 } else if (tb && !PyTraceBack_Check(tb)) {
4317 PyErr_SetString(PyExc_TypeError,
4318 "raise: arg 3 must be a traceback or None");
4319 goto bad;
4320 }
4321 if (value == Py_None)
4322 value = 0;
4323 if (PyExceptionInstance_Check(type)) {
4324 if (value) {
4325 PyErr_SetString(PyExc_TypeError,
4326 "instance exception may not have a separate value");
4327 goto bad;
4328 }
4329 value = type;
4330 type = (PyObject*) Py_TYPE(value);
4331 } else if (PyExceptionClass_Check(type)) {
4332 PyObject *instance_class = NULL;
4333 if (value && PyExceptionInstance_Check(value)) {
4334 instance_class = (PyObject*) Py_TYPE(value);
4335 if (instance_class != type) {
4336 int is_subclass = PyObject_IsSubclass(instance_class, type);
4337 if (!is_subclass) {
4338 instance_class = NULL;
4339 } else if (unlikely(is_subclass == -1)) {
4340 goto bad;
4341 } else {
4342 type = instance_class;
4343 }
4344 }
4345 }
4346 if (!instance_class) {
4347 PyObject *args;
4348 if (!value)
4349 args = PyTuple_New(0);
4350 else if (PyTuple_Check(value)) {
4351 Py_INCREF(value);
4352 args = value;
4353 } else
4354 args = PyTuple_Pack(1, value);
4355 if (!args)
4356 goto bad;
4357 owned_instance = PyObject_Call(type, args, NULL);
4358 Py_DECREF(args);
4359 if (!owned_instance)
4360 goto bad;
4361 value = owned_instance;
4362 if (!PyExceptionInstance_Check(value)) {
4363 PyErr_Format(PyExc_TypeError,
4364 "calling %R should have returned an instance of "
4365 "BaseException, not %R",
4366 type, Py_TYPE(value));
4367 goto bad;
4368 }
4369 }
4370 } else {
4371 PyErr_SetString(PyExc_TypeError,
4372 "raise: exception class must be a subclass of BaseException");
4373 goto bad;
4374 }
4375 if (cause) {
4376 PyObject *fixed_cause;
4377 if (cause == Py_None) {
4378 fixed_cause = NULL;
4379 } else if (PyExceptionClass_Check(cause)) {
4380 fixed_cause = PyObject_CallObject(cause, NULL);
4381 if (fixed_cause == NULL)
4382 goto bad;
4383 } else if (PyExceptionInstance_Check(cause)) {
4384 fixed_cause = cause;
4385 Py_INCREF(fixed_cause);
4386 } else {
4387 PyErr_SetString(PyExc_TypeError,
4388 "exception causes must derive from "
4389 "BaseException");
4390 goto bad;
4391 }
4392 PyException_SetCause(value, fixed_cause);
4393 }
4394 PyErr_SetObject(type, value);
4395 if (tb) {
4396 #if CYTHON_FAST_THREAD_STATE
4397 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4398 PyObject* tmp_tb = tstate->curexc_traceback;
4399 if (tb != tmp_tb) {
4400 Py_INCREF(tb);
4401 tstate->curexc_traceback = tb;
4402 Py_XDECREF(tmp_tb);
4403 }
4404 #else
4405 PyObject *tmp_type, *tmp_value, *tmp_tb;
4406 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
4407 Py_INCREF(tb);
4408 PyErr_Restore(tmp_type, tmp_value, tb);
4409 Py_XDECREF(tmp_tb);
4410 #endif
4411 }
4412 bad:
4413 Py_XDECREF(owned_instance);
4414 return;
4415 }
4416 #endif
4417
4418 /* SwapException */
4419 #if CYTHON_FAST_THREAD_STATE
4420 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4421 PyObject *tmp_type, *tmp_value, *tmp_tb;
4422 #if CYTHON_USE_EXC_INFO_STACK
4423 _PyErr_StackItem *exc_info = tstate->exc_info;
4424 tmp_type = exc_info->exc_type;
4425 tmp_value = exc_info->exc_value;
4426 tmp_tb = exc_info->exc_traceback;
4427 exc_info->exc_type = *type;
4428 exc_info->exc_value = *value;
4429 exc_info->exc_traceback = *tb;
4430 #else
4431 tmp_type = tstate->exc_type;
4432 tmp_value = tstate->exc_value;
4433 tmp_tb = tstate->exc_traceback;
4434 tstate->exc_type = *type;
4435 tstate->exc_value = *value;
4436 tstate->exc_traceback = *tb;
4437 #endif
4438 *type = tmp_type;
4439 *value = tmp_value;
4440 *tb = tmp_tb;
4441 }
4442 #else
4443 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
4444 PyObject *tmp_type, *tmp_value, *tmp_tb;
4445 PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
4446 PyErr_SetExcInfo(*type, *value, *tb);
4447 *type = tmp_type;
4448 *value = tmp_value;
4449 *tb = tmp_tb;
4450 }
4451 #endif
4452
4453 /* PyObjectCallMethod1 */
4454 static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
4455 PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
4456 Py_DECREF(method);
4457 return result;
4458 }
4459 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
4460 PyObject *method = NULL, *result;
4461 int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
4462 if (likely(is_method)) {
4463 result = __Pyx_PyObject_Call2Args(method, obj, arg);
4464 Py_DECREF(method);
4465 return result;
4466 }
4467 if (unlikely(!method)) return NULL;
4468 return __Pyx__PyObject_CallMethod1(method, arg);
4469 }
4470
4471 /* CoroutineBase */
4472 #include <structmember.h>
4473 #include <frameobject.h>
4474 #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
4475 #ifndef Py_BUILD_CORE
4476 #define Py_BUILD_CORE 1
4477 #endif
4478 #include "internal/pycore_frame.h"
4479 #endif
4480 #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
4481 static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
4482 PyObject *et, *ev, *tb;
4483 PyObject *value = NULL;
4484 __Pyx_ErrFetch(&et, &ev, &tb);
4485 if (!et) {
4486 Py_XDECREF(tb);
4487 Py_XDECREF(ev);
4488 Py_INCREF(Py_None);
4489 *pvalue = Py_None;
4490 return 0;
4491 }
4492 if (likely(et == PyExc_StopIteration)) {
4493 if (!ev) {
4494 Py_INCREF(Py_None);
4495 value = Py_None;
4496 }
4497 #if PY_VERSION_HEX >= 0x030300A0
4498 else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
4499 value = ((PyStopIterationObject *)ev)->value;
4500 Py_INCREF(value);
4501 Py_DECREF(ev);
4502 }
4503 #endif
4504 else if (unlikely(PyTuple_Check(ev))) {
4505 if (PyTuple_GET_SIZE(ev) >= 1) {
4506 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4507 value = PyTuple_GET_ITEM(ev, 0);
4508 Py_INCREF(value);
4509 #else
4510 value = PySequence_ITEM(ev, 0);
4511 #endif
4512 } else {
4513 Py_INCREF(Py_None);
4514 value = Py_None;
4515 }
4516 Py_DECREF(ev);
4517 }
4518 else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
4519 value = ev;
4520 }
4521 if (likely(value)) {
4522 Py_XDECREF(tb);
4523 Py_DECREF(et);
4524 *pvalue = value;
4525 return 0;
4526 }
4527 } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
4528 __Pyx_ErrRestore(et, ev, tb);
4529 return -1;
4530 }
4531 PyErr_NormalizeException(&et, &ev, &tb);
4532 if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
4533 __Pyx_ErrRestore(et, ev, tb);
4534 return -1;
4535 }
4536 Py_XDECREF(tb);
4537 Py_DECREF(et);
4538 #if PY_VERSION_HEX >= 0x030300A0
4539 value = ((PyStopIterationObject *)ev)->value;
4540 Py_INCREF(value);
4541 Py_DECREF(ev);
4542 #else
4543 {
4544 PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
4545 Py_DECREF(ev);
4546 if (likely(args)) {
4547 value = PySequence_GetItem(args, 0);
4548 Py_DECREF(args);
4549 }
4550 if (unlikely(!value)) {
4551 __Pyx_ErrRestore(NULL, NULL, NULL);
4552 Py_INCREF(Py_None);
4553 value = Py_None;
4554 }
4555 }
4556 #endif
4557 *pvalue = value;
4558 return 0;
4559 }
4560 static CYTHON_INLINE
4561 void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
4562 PyObject *t, *v, *tb;
4563 t = exc_state->exc_type;
4564 v = exc_state->exc_value;
4565 tb = exc_state->exc_traceback;
4566 exc_state->exc_type = NULL;
4567 exc_state->exc_value = NULL;
4568 exc_state->exc_traceback = NULL;
4569 Py_XDECREF(t);
4570 Py_XDECREF(v);
4571 Py_XDECREF(tb);
4572 }
4573 #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
4574 static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
4575 const char *msg;
4576 if ((0)) {
4577 #ifdef __Pyx_Coroutine_USED
4578 } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
4579 msg = "coroutine already executing";
4580 #endif
4581 #ifdef __Pyx_AsyncGen_USED
4582 } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
4583 msg = "async generator already executing";
4584 #endif
4585 } else {
4586 msg = "generator already executing";
4587 }
4588 PyErr_SetString(PyExc_ValueError, msg);
4589 }
4590 #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
4591 static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
4592 const char *msg;
4593 if ((0)) {
4594 #ifdef __Pyx_Coroutine_USED
4595 } else if (__Pyx_Coroutine_Check(gen)) {
4596 msg = "can't send non-None value to a just-started coroutine";
4597 #endif
4598 #ifdef __Pyx_AsyncGen_USED
4599 } else if (__Pyx_AsyncGen_CheckExact(gen)) {
4600 msg = "can't send non-None value to a just-started async generator";
4601 #endif
4602 } else {
4603 msg = "can't send non-None value to a just-started generator";
4604 }
4605 PyErr_SetString(PyExc_TypeError, msg);
4606 }
4607 #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
4608 static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
4609 #ifdef __Pyx_Coroutine_USED
4610 if (!closing && __Pyx_Coroutine_Check(gen)) {
4611 PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
4612 } else
4613 #endif
4614 if (value) {
4615 #ifdef __Pyx_AsyncGen_USED
4616 if (__Pyx_AsyncGen_CheckExact(gen))
4617 PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
4618 else
4619 #endif
4620 PyErr_SetNone(PyExc_StopIteration);
4621 }
4622 }
4623 static
4624 PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
4625 __Pyx_PyThreadState_declare
4626 PyThreadState *tstate;
4627 __Pyx_ExcInfoStruct *exc_state;
4628 PyObject *retval;
4629 assert(!self->is_running);
4630 if (unlikely(self->resume_label == 0)) {
4631 if (unlikely(value && value != Py_None)) {
4632 return __Pyx_Coroutine_NotStartedError((PyObject*)self);
4633 }
4634 }
4635 if (unlikely(self->resume_label == -1)) {
4636 return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
4637 }
4638 #if CYTHON_FAST_THREAD_STATE
4639 __Pyx_PyThreadState_assign
4640 tstate = __pyx_tstate;
4641 #else
4642 tstate = __Pyx_PyThreadState_Current;
4643 #endif
4644 exc_state = &self->gi_exc_state;
4645 if (exc_state->exc_type) {
4646 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
4647 #else
4648 if (exc_state->exc_traceback) {
4649 PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
4650 PyFrameObject *f = tb->tb_frame;
4651 assert(f->f_back == NULL);
4652 #if PY_VERSION_HEX >= 0x030B00A1
4653 f->f_back = PyThreadState_GetFrame(tstate);
4654 #else
4655 Py_XINCREF(tstate->frame);
4656 f->f_back = tstate->frame;
4657 #endif
4658 }
4659 #endif
4660 }
4661 #if CYTHON_USE_EXC_INFO_STACK
4662 exc_state->previous_item = tstate->exc_info;
4663 tstate->exc_info = exc_state;
4664 #else
4665 if (exc_state->exc_type) {
4666 __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
4667 } else {
4668 __Pyx_Coroutine_ExceptionClear(exc_state);
4669 __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
4670 }
4671 #endif
4672 self->is_running = 1;
4673 retval = self->body((PyObject *) self, tstate, value);
4674 self->is_running = 0;
4675 #if CYTHON_USE_EXC_INFO_STACK
4676 exc_state = &self->gi_exc_state;
4677 tstate->exc_info = exc_state->previous_item;
4678 exc_state->previous_item = NULL;
4679 __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
4680 #endif
4681 return retval;
4682 }
4683 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
4684 PyObject *exc_tb = exc_state->exc_traceback;
4685 if (likely(exc_tb)) {
4686 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
4687 #else
4688 PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
4689 PyFrameObject *f = tb->tb_frame;
4690 Py_CLEAR(f->f_back);
4691 #endif
4692 }
4693 }
4694 static CYTHON_INLINE
4695 PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
4696 if (unlikely(!retval)) {
4697 __Pyx_PyThreadState_declare
4698 __Pyx_PyThreadState_assign
4699 if (!__Pyx_PyErr_Occurred()) {
4700 PyObject *exc = PyExc_StopIteration;
4701 #ifdef __Pyx_AsyncGen_USED
4702 if (__Pyx_AsyncGen_CheckExact(gen))
4703 exc = __Pyx_PyExc_StopAsyncIteration;
4704 #endif
4705 __Pyx_PyErr_SetNone(exc);
4706 }
4707 }
4708 return retval;
4709 }
4710 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
4711 static CYTHON_INLINE
4712 PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
4713 #if PY_VERSION_HEX <= 0x030A00A1
4714 return _PyGen_Send(gen, arg);
4715 #else
4716 PyObject *result;
4717 if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
4718 if (PyAsyncGen_CheckExact(gen)) {
4719 assert(result == Py_None);
4720 PyErr_SetNone(PyExc_StopAsyncIteration);
4721 }
4722 else if (result == Py_None) {
4723 PyErr_SetNone(PyExc_StopIteration);
4724 }
4725 else {
4726 _PyGen_SetStopIterationValue(result);
4727 }
4728 Py_CLEAR(result);
4729 }
4730 return result;
4731 #endif
4732 }
4733 #endif
4734 static CYTHON_INLINE
4735 PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
4736 PyObject *ret;
4737 PyObject *val = NULL;
4738 __Pyx_Coroutine_Undelegate(gen);
4739 __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
4740 ret = __Pyx_Coroutine_SendEx(gen, val, 0);
4741 Py_XDECREF(val);
4742 return ret;
4743 }
4744 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
4745 PyObject *retval;
4746 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
4747 PyObject *yf = gen->yieldfrom;
4748 if (unlikely(gen->is_running))
4749 return __Pyx_Coroutine_AlreadyRunningError(gen);
4750 if (yf) {
4751 PyObject *ret;
4752 gen->is_running = 1;
4753 #ifdef __Pyx_Generator_USED
4754 if (__Pyx_Generator_CheckExact(yf)) {
4755 ret = __Pyx_Coroutine_Send(yf, value);
4756 } else
4757 #endif
4758 #ifdef __Pyx_Coroutine_USED
4759 if (__Pyx_Coroutine_Check(yf)) {
4760 ret = __Pyx_Coroutine_Send(yf, value);
4761 } else
4762 #endif
4763 #ifdef __Pyx_AsyncGen_USED
4764 if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
4765 ret = __Pyx_async_gen_asend_send(yf, value);
4766 } else
4767 #endif
4768 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
4769 if (PyGen_CheckExact(yf)) {
4770 ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
4771 } else
4772 #endif
4773 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
4774 if (PyCoro_CheckExact(yf)) {
4775 ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
4776 } else
4777 #endif
4778 {
4779 if (value == Py_None)
4780 ret = Py_TYPE(yf)->tp_iternext(yf);
4781 else
4782 ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
4783 }
4784 gen->is_running = 0;
4785 if (likely(ret)) {
4786 return ret;
4787 }
4788 retval = __Pyx_Coroutine_FinishDelegation(gen);
4789 } else {
4790 retval = __Pyx_Coroutine_SendEx(gen, value, 0);
4791 }
4792 return __Pyx_Coroutine_MethodReturn(self, retval);
4793 }
4794 static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
4795 PyObject *retval = NULL;
4796 int err = 0;
4797 #ifdef __Pyx_Generator_USED
4798 if (__Pyx_Generator_CheckExact(yf)) {
4799 retval = __Pyx_Coroutine_Close(yf);
4800 if (!retval)
4801 return -1;
4802 } else
4803 #endif
4804 #ifdef __Pyx_Coroutine_USED
4805 if (__Pyx_Coroutine_Check(yf)) {
4806 retval = __Pyx_Coroutine_Close(yf);
4807 if (!retval)
4808 return -1;
4809 } else
4810 if (__Pyx_CoroutineAwait_CheckExact(yf)) {
4811 retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
4812 if (!retval)
4813 return -1;
4814 } else
4815 #endif
4816 #ifdef __Pyx_AsyncGen_USED
4817 if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
4818 retval = __Pyx_async_gen_asend_close(yf, NULL);
4819 } else
4820 if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
4821 retval = __Pyx_async_gen_athrow_close(yf, NULL);
4822 } else
4823 #endif
4824 {
4825 PyObject *meth;
4826 gen->is_running = 1;
4827 meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
4828 if (unlikely(!meth)) {
4829 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
4830 PyErr_WriteUnraisable(yf);
4831 }
4832 PyErr_Clear();
4833 } else {
4834 retval = PyObject_CallFunction(meth, NULL);
4835 Py_DECREF(meth);
4836 if (!retval)
4837 err = -1;
4838 }
4839 gen->is_running = 0;
4840 }
4841 Py_XDECREF(retval);
4842 return err;
4843 }
4844 static PyObject *__Pyx_Generator_Next(PyObject *self) {
4845 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
4846 PyObject *yf = gen->yieldfrom;
4847 if (unlikely(gen->is_running))
4848 return __Pyx_Coroutine_AlreadyRunningError(gen);
4849 if (yf) {
4850 PyObject *ret;
4851 gen->is_running = 1;
4852 #ifdef __Pyx_Generator_USED
4853 if (__Pyx_Generator_CheckExact(yf)) {
4854 ret = __Pyx_Generator_Next(yf);
4855 } else
4856 #endif
4857 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
4858 if (PyGen_CheckExact(yf)) {
4859 ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
4860 } else
4861 #endif
4862 #ifdef __Pyx_Coroutine_USED
4863 if (__Pyx_Coroutine_Check(yf)) {
4864 ret = __Pyx_Coroutine_Send(yf, Py_None);
4865 } else
4866 #endif
4867 ret = Py_TYPE(yf)->tp_iternext(yf);
4868 gen->is_running = 0;
4869 if (likely(ret)) {
4870 return ret;
4871 }
4872 return __Pyx_Coroutine_FinishDelegation(gen);
4873 }
4874 return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
4875 }
4876 static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
4877 return __Pyx_Coroutine_Close(self);
4878 }
4879 static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
4880 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
4881 PyObject *retval, *raised_exception;
4882 PyObject *yf = gen->yieldfrom;
4883 int err = 0;
4884 if (unlikely(gen->is_running))
4885 return __Pyx_Coroutine_AlreadyRunningError(gen);
4886 if (yf) {
4887 Py_INCREF(yf);
4888 err = __Pyx_Coroutine_CloseIter(gen, yf);
4889 __Pyx_Coroutine_Undelegate(gen);
4890 Py_DECREF(yf);
4891 }
4892 if (err == 0)
4893 PyErr_SetNone(PyExc_GeneratorExit);
4894 retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
4895 if (unlikely(retval)) {
4896 const char *msg;
4897 Py_DECREF(retval);
4898 if ((0)) {
4899 #ifdef __Pyx_Coroutine_USED
4900 } else if (__Pyx_Coroutine_Check(self)) {
4901 msg = "coroutine ignored GeneratorExit";
4902 #endif
4903 #ifdef __Pyx_AsyncGen_USED
4904 } else if (__Pyx_AsyncGen_CheckExact(self)) {
4905 #if PY_VERSION_HEX < 0x03060000
4906 msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
4907 #else
4908 msg = "async generator ignored GeneratorExit";
4909 #endif
4910 #endif
4911 } else {
4912 msg = "generator ignored GeneratorExit";
4913 }
4914 PyErr_SetString(PyExc_RuntimeError, msg);
4915 return NULL;
4916 }
4917 raised_exception = PyErr_Occurred();
4918 if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
4919 if (raised_exception) PyErr_Clear();
4920 Py_INCREF(Py_None);
4921 return Py_None;
4922 }
4923 return NULL;
4924 }
4925 static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
4926 PyObject *args, int close_on_genexit) {
4927 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
4928 PyObject *yf = gen->yieldfrom;
4929 if (unlikely(gen->is_running))
4930 return __Pyx_Coroutine_AlreadyRunningError(gen);
4931 if (yf) {
4932 PyObject *ret;
4933 Py_INCREF(yf);
4934 if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
4935 int err = __Pyx_Coroutine_CloseIter(gen, yf);
4936 Py_DECREF(yf);
4937 __Pyx_Coroutine_Undelegate(gen);
4938 if (err < 0)
4939 return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
4940 goto throw_here;
4941 }
4942 gen->is_running = 1;
4943 if (0
4944 #ifdef __Pyx_Generator_USED
4945 || __Pyx_Generator_CheckExact(yf)
4946 #endif
4947 #ifdef __Pyx_Coroutine_USED
4948 || __Pyx_Coroutine_Check(yf)
4949 #endif
4950 ) {
4951 ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
4952 #ifdef __Pyx_Coroutine_USED
4953 } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
4954 ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
4955 #endif
4956 } else {
4957 PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
4958 if (unlikely(!meth)) {
4959 Py_DECREF(yf);
4960 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
4961 gen->is_running = 0;
4962 return NULL;
4963 }
4964 PyErr_Clear();
4965 __Pyx_Coroutine_Undelegate(gen);
4966 gen->is_running = 0;
4967 goto throw_here;
4968 }
4969 if (likely(args)) {
4970 ret = PyObject_CallObject(meth, args);
4971 } else {
4972 ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
4973 }
4974 Py_DECREF(meth);
4975 }
4976 gen->is_running = 0;
4977 Py_DECREF(yf);
4978 if (!ret) {
4979 ret = __Pyx_Coroutine_FinishDelegation(gen);
4980 }
4981 return __Pyx_Coroutine_MethodReturn(self, ret);
4982 }
4983 throw_here:
4984 __Pyx_Raise(typ, val, tb, NULL);
4985 return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
4986 }
4987 static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
4988 PyObject *typ;
4989 PyObject *val = NULL;
4990 PyObject *tb = NULL;
4991 if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
4992 return NULL;
4993 return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
4994 }
4995 static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
4996 Py_VISIT(exc_state->exc_type);
4997 Py_VISIT(exc_state->exc_value);
4998 Py_VISIT(exc_state->exc_traceback);
4999 return 0;
5000 }
5001 static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
5002 Py_VISIT(gen->closure);
5003 Py_VISIT(gen->classobj);
5004 Py_VISIT(gen->yieldfrom);
5005 return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
5006 }
5007 static int __Pyx_Coroutine_clear(PyObject *self) {
5008 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
5009 Py_CLEAR(gen->closure);
5010 Py_CLEAR(gen->classobj);
5011 Py_CLEAR(gen->yieldfrom);
5012 __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
5013 #ifdef __Pyx_AsyncGen_USED
5014 if (__Pyx_AsyncGen_CheckExact(self)) {
5015 Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
5016 }
5017 #endif
5018 Py_CLEAR(gen->gi_code);
5019 Py_CLEAR(gen->gi_frame);
5020 Py_CLEAR(gen->gi_name);
5021 Py_CLEAR(gen->gi_qualname);
5022 Py_CLEAR(gen->gi_modulename);
5023 return 0;
5024 }
5025 static void __Pyx_Coroutine_dealloc(PyObject *self) {
5026 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
5027 PyObject_GC_UnTrack(gen);
5028 if (gen->gi_weakreflist != NULL)
5029 PyObject_ClearWeakRefs(self);
5030 if (gen->resume_label >= 0) {
5031 PyObject_GC_Track(self);
5032 #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
5033 if (PyObject_CallFinalizerFromDealloc(self))
5034 #else
5035 Py_TYPE(gen)->tp_del(self);
5036 if (Py_REFCNT(self) > 0)
5037 #endif
5038 {
5039 return;
5040 }
5041 PyObject_GC_UnTrack(self);
5042 }
5043 #ifdef __Pyx_AsyncGen_USED
5044 if (__Pyx_AsyncGen_CheckExact(self)) {
5045 /* We have to handle this case for asynchronous generators
5046 right here, because this code has to be between UNTRACK
5047 and GC_Del. */
5048 Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
5049 }
5050 #endif
5051 __Pyx_Coroutine_clear(self);
5052 PyObject_GC_Del(gen);
5053 }
5054 static void __Pyx_Coroutine_del(PyObject *self) {
5055 PyObject *error_type, *error_value, *error_traceback;
5056 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
5057 __Pyx_PyThreadState_declare
5058 if (gen->resume_label < 0) {
5059 return;
5060 }
5061 #if !CYTHON_USE_TP_FINALIZE
5062 assert(self->ob_refcnt == 0);
5063 __Pyx_SET_REFCNT(self, 1);
5064 #endif
5065 __Pyx_PyThreadState_assign
5066 __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
5067 #ifdef __Pyx_AsyncGen_USED
5068 if (__Pyx_AsyncGen_CheckExact(self)) {
5069 __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
5070 PyObject *finalizer = agen->ag_finalizer;
5071 if (finalizer && !agen->ag_closed) {
5072 PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
5073 if (unlikely(!res)) {
5074 PyErr_WriteUnraisable(self);
5075 } else {
5076 Py_DECREF(res);
5077 }
5078 __Pyx_ErrRestore(error_type, error_value, error_traceback);
5079 return;
5080 }
5081 }
5082 #endif
5083 if (unlikely(gen->resume_label == 0 && !error_value)) {
5084 #ifdef __Pyx_Coroutine_USED
5085 #ifdef __Pyx_Generator_USED
5086 if (!__Pyx_Generator_CheckExact(self))
5087 #endif
5088 {
5089 PyObject_GC_UnTrack(self);
5090 #if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat)
5091 if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
5092 PyErr_WriteUnraisable(self);
5093 #else
5094 {PyObject *msg;
5095 char *cmsg;
5096 #if CYTHON_COMPILING_IN_PYPY
5097 msg = NULL;
5098 cmsg = (char*) "coroutine was never awaited";
5099 #else
5100 char *cname;
5101 PyObject *qualname;
5102 qualname = gen->gi_qualname;
5103 cname = PyString_AS_STRING(qualname);
5104 msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
5105 if (unlikely(!msg)) {
5106 PyErr_Clear();
5107 cmsg = (char*) "coroutine was never awaited";
5108 } else {
5109 cmsg = PyString_AS_STRING(msg);
5110 }
5111 #endif
5112 if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
5113 PyErr_WriteUnraisable(self);
5114 Py_XDECREF(msg);}
5115 #endif
5116 PyObject_GC_Track(self);
5117 }
5118 #endif
5119 } else {
5120 PyObject *res = __Pyx_Coroutine_Close(self);
5121 if (unlikely(!res)) {
5122 if (PyErr_Occurred())
5123 PyErr_WriteUnraisable(self);
5124 } else {
5125 Py_DECREF(res);
5126 }
5127 }
5128 __Pyx_ErrRestore(error_type, error_value, error_traceback);
5129 #if !CYTHON_USE_TP_FINALIZE
5130 assert(Py_REFCNT(self) > 0);
5131 if (--self->ob_refcnt == 0) {
5132 return;
5133 }
5134 {
5135 Py_ssize_t refcnt = Py_REFCNT(self);
5136 _Py_NewReference(self);
5137 __Pyx_SET_REFCNT(self, refcnt);
5138 }
5139 #if CYTHON_COMPILING_IN_CPYTHON
5140 assert(PyType_IS_GC(Py_TYPE(self)) &&
5141 _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
5142 _Py_DEC_REFTOTAL;
5143 #endif
5144 #ifdef COUNT_ALLOCS
5145 --Py_TYPE(self)->tp_frees;
5146 --Py_TYPE(self)->tp_allocs;
5147 #endif
5148 #endif
5149 }
5150 static PyObject *
5151 __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
5152 {
5153 PyObject *name = self->gi_name;
5154 if (unlikely(!name)) name = Py_None;
5155 Py_INCREF(name);
5156 return name;
5157 }
5158 static int
5159 __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
5160 {
5161 PyObject *tmp;
5162 #if PY_MAJOR_VERSION >= 3
5163 if (unlikely(value == NULL || !PyUnicode_Check(value)))
5164 #else
5165 if (unlikely(value == NULL || !PyString_Check(value)))
5166 #endif
5167 {
5168 PyErr_SetString(PyExc_TypeError,
5169 "__name__ must be set to a string object");
5170 return -1;
5171 }
5172 tmp = self->gi_name;
5173 Py_INCREF(value);
5174 self->gi_name = value;
5175 Py_XDECREF(tmp);
5176 return 0;
5177 }
5178 static PyObject *
5179 __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
5180 {
5181 PyObject *name = self->gi_qualname;
5182 if (unlikely(!name)) name = Py_None;
5183 Py_INCREF(name);
5184 return name;
5185 }
5186 static int
5187 __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
5188 {
5189 PyObject *tmp;
5190 #if PY_MAJOR_VERSION >= 3
5191 if (unlikely(value == NULL || !PyUnicode_Check(value)))
5192 #else
5193 if (unlikely(value == NULL || !PyString_Check(value)))
5194 #endif
5195 {
5196 PyErr_SetString(PyExc_TypeError,
5197 "__qualname__ must be set to a string object");
5198 return -1;
5199 }
5200 tmp = self->gi_qualname;
5201 Py_INCREF(value);
5202 self->gi_qualname = value;
5203 Py_XDECREF(tmp);
5204 return 0;
5205 }
5206 static PyObject *
5207 __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
5208 {
5209 PyObject *frame = self->gi_frame;
5210 if (!frame) {
5211 if (unlikely(!self->gi_code)) {
5212 Py_RETURN_NONE;
5213 }
5214 frame = (PyObject *) PyFrame_New(
5215 PyThreadState_Get(), /*PyThreadState *tstate,*/
5216 (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/
5217 __pyx_d, /*PyObject *globals,*/
5218 0 /*PyObject *locals*/
5219 );
5220 if (unlikely(!frame))
5221 return NULL;
5222 self->gi_frame = frame;
5223 }
5224 Py_INCREF(frame);
5225 return frame;
5226 }
5227 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
5228 PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
5229 PyObject *name, PyObject *qualname, PyObject *module_name) {
5230 __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
5231 if (unlikely(!gen))
5232 return NULL;
5233 return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
5234 }
5235 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
5236 __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
5237 PyObject *name, PyObject *qualname, PyObject *module_name) {
5238 gen->body = body;
5239 gen->closure = closure;
5240 Py_XINCREF(closure);
5241 gen->is_running = 0;
5242 gen->resume_label = 0;
5243 gen->classobj = NULL;
5244 gen->yieldfrom = NULL;
5245 gen->gi_exc_state.exc_type = NULL;
5246 gen->gi_exc_state.exc_value = NULL;
5247 gen->gi_exc_state.exc_traceback = NULL;
5248 #if CYTHON_USE_EXC_INFO_STACK
5249 gen->gi_exc_state.previous_item = NULL;
5250 #endif
5251 gen->gi_weakreflist = NULL;
5252 Py_XINCREF(qualname);
5253 gen->gi_qualname = qualname;
5254 Py_XINCREF(name);
5255 gen->gi_name = name;
5256 Py_XINCREF(module_name);
5257 gen->gi_modulename = module_name;
5258 Py_XINCREF(code);
5259 gen->gi_code = code;
5260 gen->gi_frame = NULL;
5261 PyObject_GC_Track(gen);
5262 return gen;
5263 }
5264
5265 /* PyObject_GenericGetAttrNoDict */
5266 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
5267 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
5268 PyErr_Format(PyExc_AttributeError,
5269 #if PY_MAJOR_VERSION >= 3
5270 "'%.50s' object has no attribute '%U'",
5271 tp->tp_name, attr_name);
5272 #else
5273 "'%.50s' object has no attribute '%.400s'",
5274 tp->tp_name, PyString_AS_STRING(attr_name));
5275 #endif
5276 return NULL;
5277 }
5278 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
5279 PyObject *descr;
5280 PyTypeObject *tp = Py_TYPE(obj);
5281 if (unlikely(!PyString_Check(attr_name))) {
5282 return PyObject_GenericGetAttr(obj, attr_name);
5283 }
5284 assert(!tp->tp_dictoffset);
5285 descr = _PyType_Lookup(tp, attr_name);
5286 if (unlikely(!descr)) {
5287 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
5288 }
5289 Py_INCREF(descr);
5290 #if PY_MAJOR_VERSION < 3
5291 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
5292 #endif
5293 {
5294 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
5295 if (unlikely(f)) {
5296 PyObject *res = f(descr, obj, (PyObject *)tp);
5297 Py_DECREF(descr);
5298 return res;
5299 }
5300 }
5301 return descr;
5302 }
5303 #endif
5304
5305 /* PatchModuleWithCoroutine */
5306 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
5307 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
5308 int result;
5309 PyObject *globals, *result_obj;
5310 globals = PyDict_New(); if (unlikely(!globals)) goto ignore;
5311 result = PyDict_SetItemString(globals, "_cython_coroutine_type",
5312 #ifdef __Pyx_Coroutine_USED
5313 (PyObject*)__pyx_CoroutineType);
5314 #else
5315 Py_None);
5316 #endif
5317 if (unlikely(result < 0)) goto ignore;
5318 result = PyDict_SetItemString(globals, "_cython_generator_type",
5319 #ifdef __Pyx_Generator_USED
5320 (PyObject*)__pyx_GeneratorType);
5321 #else
5322 Py_None);
5323 #endif
5324 if (unlikely(result < 0)) goto ignore;
5325 if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
5326 if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
5327 result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
5328 if (unlikely(!result_obj)) goto ignore;
5329 Py_DECREF(result_obj);
5330 Py_DECREF(globals);
5331 return module;
5332 ignore:
5333 Py_XDECREF(globals);
5334 PyErr_WriteUnraisable(module);
5335 if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
5336 Py_DECREF(module);
5337 module = NULL;
5338 }
5339 #else
5340 py_code++;
5341 #endif
5342 return module;
5343 }
5344
5345 /* PatchGeneratorABC */
5346 #ifndef CYTHON_REGISTER_ABCS
5347 #define CYTHON_REGISTER_ABCS 1
5348 #endif
5349 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
5350 static PyObject* __Pyx_patch_abc_module(PyObject *module);
5351 static PyObject* __Pyx_patch_abc_module(PyObject *module) {
5352 module = __Pyx_Coroutine_patch_module(
5353 module, ""
5354 "if _cython_generator_type is not None:\n"
5355 " try: Generator = _module.Generator\n"
5356 " except AttributeError: pass\n"
5357 " else: Generator.register(_cython_generator_type)\n"
5358 "if _cython_coroutine_type is not None:\n"
5359 " try: Coroutine = _module.Coroutine\n"
5360 " except AttributeError: pass\n"
5361 " else: Coroutine.register(_cython_coroutine_type)\n"
5362 );
5363 return module;
5364 }
5365 #endif
5366 static int __Pyx_patch_abc(void) {
5367 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
5368 static int abc_patched = 0;
5369 if (CYTHON_REGISTER_ABCS && !abc_patched) {
5370 PyObject *module;
5371 module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
5372 if (!module) {
5373 PyErr_WriteUnraisable(NULL);
5374 if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
5375 ((PY_MAJOR_VERSION >= 3) ?
5376 "Cython module failed to register with collections.abc module" :
5377 "Cython module failed to register with collections module"), 1) < 0)) {
5378 return -1;
5379 }
5380 } else {
5381 module = __Pyx_patch_abc_module(module);
5382 abc_patched = 1;
5383 if (unlikely(!module))
5384 return -1;
5385 Py_DECREF(module);
5386 }
5387 module = PyImport_ImportModule("backports_abc");
5388 if (module) {
5389 module = __Pyx_patch_abc_module(module);
5390 Py_XDECREF(module);
5391 }
5392 if (!module) {
5393 PyErr_Clear();
5394 }
5395 }
5396 #else
5397 if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
5398 #endif
5399 return 0;
5400 }
5401
5402 /* Coroutine */
5403 static void __Pyx_CoroutineAwait_dealloc(PyObject *self) {
5404 PyObject_GC_UnTrack(self);
5405 Py_CLEAR(((__pyx_CoroutineAwaitObject*)self)->coroutine);
5406 PyObject_GC_Del(self);
5407 }
5408 static int __Pyx_CoroutineAwait_traverse(__pyx_CoroutineAwaitObject *self, visitproc visit, void *arg) {
5409 Py_VISIT(self->coroutine);
5410 return 0;
5411 }
5412 static int __Pyx_CoroutineAwait_clear(__pyx_CoroutineAwaitObject *self) {
5413 Py_CLEAR(self->coroutine);
5414 return 0;
5415 }
5416 static PyObject *__Pyx_CoroutineAwait_Next(__pyx_CoroutineAwaitObject *self) {
5417 return __Pyx_Generator_Next(self->coroutine);
5418 }
5419 static PyObject *__Pyx_CoroutineAwait_Send(__pyx_CoroutineAwaitObject *self, PyObject *value) {
5420 return __Pyx_Coroutine_Send(self->coroutine, value);
5421 }
5422 static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args) {
5423 return __Pyx_Coroutine_Throw(self->coroutine, args);
5424 }
5425 static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self, CYTHON_UNUSED PyObject *arg) {
5426 return __Pyx_Coroutine_Close(self->coroutine);
5427 }
5428 static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) {
5429 Py_INCREF(self);
5430 return self;
5431 }
5432 #if !CYTHON_COMPILING_IN_PYPY
5433 static PyObject *__Pyx_CoroutineAwait_no_new(CYTHON_UNUSED PyTypeObject *type, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwargs) {
5434 PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead");
5435 return NULL;
5436 }
5437 #endif
5438 static PyMethodDef __pyx_CoroutineAwait_methods[] = {
5439 {"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O,
5440 (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next yielded value or raise StopIteration.")},
5441 {"throw", (PyCFunction) __Pyx_CoroutineAwait_Throw, METH_VARARGS,
5442 (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next yielded value or raise StopIteration.")},
5443 {"close", (PyCFunction) __Pyx_CoroutineAwait_Close, METH_NOARGS,
5444 (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
5445 {0, 0, 0, 0}
5446 };
5447 static PyTypeObject __pyx_CoroutineAwaitType_type = {
5448 PyVarObject_HEAD_INIT(0, 0)
5449 "coroutine_wrapper",
5450 sizeof(__pyx_CoroutineAwaitObject),
5451 0,
5452 (destructor) __Pyx_CoroutineAwait_dealloc,
5453 0,
5454 0,
5455 0,
5456 0,
5457 0,
5458 0,
5459 0,
5460 0,
5461 0,
5462 0,
5463 0,
5464 0,
5465 0,
5466 0,
5467 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
5468 PyDoc_STR("A wrapper object implementing __await__ for coroutines."),
5469 (traverseproc) __Pyx_CoroutineAwait_traverse,
5470 (inquiry) __Pyx_CoroutineAwait_clear,
5471 0,
5472 0,
5473 __Pyx_CoroutineAwait_self,
5474 (iternextfunc) __Pyx_CoroutineAwait_Next,
5475 __pyx_CoroutineAwait_methods,
5476 0 ,
5477 0 ,
5478 0,
5479 0,
5480 0,
5481 0,
5482 0,
5483 0,
5484 0,
5485 #if !CYTHON_COMPILING_IN_PYPY
5486 __Pyx_CoroutineAwait_no_new,
5487 #else
5488 0,
5489 #endif
5490 0,
5491 0,
5492 0,
5493 0,
5494 0,
5495 0,
5496 0,
5497 0,
5498 0,
5499 #if PY_VERSION_HEX >= 0x030400a1
5500 0,
5501 #endif
5502 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
5503 0,
5504 #endif
5505 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
5506 0,
5507 #endif
5508 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
5509 0,
5510 #endif
5511 };
5512 #if PY_VERSION_HEX < 0x030500B1 || defined(__Pyx_IterableCoroutine_USED) || CYTHON_USE_ASYNC_SLOTS
5513 static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) {
5514 __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_CoroutineAwaitType);
5515 if (unlikely(!await)) return NULL;
5516 Py_INCREF(coroutine);
5517 await->coroutine = coroutine;
5518 PyObject_GC_Track(await);
5519 return (PyObject*)await;
5520 }
5521 #endif
5522 #if PY_VERSION_HEX < 0x030500B1
5523 static PyObject *__Pyx_Coroutine_await_method(PyObject *coroutine, CYTHON_UNUSED PyObject *arg) {
5524 return __Pyx__Coroutine_await(coroutine);
5525 }
5526 #endif
5527 #if defined(__Pyx_IterableCoroutine_USED) || CYTHON_USE_ASYNC_SLOTS
5528 static PyObject *__Pyx_Coroutine_await(PyObject *coroutine) {
5529 if (unlikely(!coroutine || !__Pyx_Coroutine_Check(coroutine))) {
5530 PyErr_SetString(PyExc_TypeError, "invalid input, expected coroutine");
5531 return NULL;
5532 }
5533 return __Pyx__Coroutine_await(coroutine);
5534 }
5535 #endif
5536 #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
5537 static PyObject *__Pyx_Coroutine_compare(PyObject *obj, PyObject *other, int op) {
5538 PyObject* result;
5539 switch (op) {
5540 case Py_EQ: result = (other == obj) ? Py_True : Py_False; break;
5541 case Py_NE: result = (other != obj) ? Py_True : Py_False; break;
5542 default:
5543 result = Py_NotImplemented;
5544 }
5545 Py_INCREF(result);
5546 return result;
5547 }
5548 #endif
5549 static PyMethodDef __pyx_Coroutine_methods[] = {
5550 {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
5551 (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next iterated value or raise StopIteration.")},
5552 {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
5553 (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next iterated value or raise StopIteration.")},
5554 {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
5555 (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
5556 #if PY_VERSION_HEX < 0x030500B1
5557 {"__await__", (PyCFunction) __Pyx_Coroutine_await_method, METH_NOARGS,
5558 (char*) PyDoc_STR("__await__() -> return an iterator to be used in await expression.")},
5559 #endif
5560 {0, 0, 0, 0}
5561 };
5562 static PyMemberDef __pyx_Coroutine_memberlist[] = {
5563 {(char *) "cr_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
5564 {(char*) "cr_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
5565 (char*) PyDoc_STR("object being awaited, or None")},
5566 {(char*) "cr_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
5567 {(char *) "__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), PY_WRITE_RESTRICTED, 0},
5568 {0, 0, 0, 0, 0}
5569 };
5570 static PyGetSetDef __pyx_Coroutine_getsets[] = {
5571 {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
5572 (char*) PyDoc_STR("name of the coroutine"), 0},
5573 {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
5574 (char*) PyDoc_STR("qualified name of the coroutine"), 0},
5575 {(char *) "cr_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
5576 (char*) PyDoc_STR("Frame of the coroutine"), 0},
5577 {0, 0, 0, 0, 0}
5578 };
5579 #if CYTHON_USE_ASYNC_SLOTS
5580 static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async = {
5581 __Pyx_Coroutine_await,
5582 0,
5583 0,
5584 #if PY_VERSION_HEX >= 0x030A00A3
5585 0,
5586 #endif
5587 };
5588 #endif
5589 static PyTypeObject __pyx_CoroutineType_type = {
5590 PyVarObject_HEAD_INIT(0, 0)
5591 "coroutine",
5592 sizeof(__pyx_CoroutineObject),
5593 0,
5594 (destructor) __Pyx_Coroutine_dealloc,
5595 0,
5596 0,
5597 0,
5598 #if CYTHON_USE_ASYNC_SLOTS
5599 &__pyx_Coroutine_as_async,
5600 #else
5601 0,
5602 #endif
5603 0,
5604 0,
5605 0,
5606 0,
5607 0,
5608 0,
5609 0,
5610 0,
5611 0,
5612 0,
5613 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
5614 0,
5615 (traverseproc) __Pyx_Coroutine_traverse,
5616 0,
5617 #if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
5618 __Pyx_Coroutine_compare,
5619 #else
5620 0,
5621 #endif
5622 offsetof(__pyx_CoroutineObject, gi_weakreflist),
5623 0,
5624 0,
5625 __pyx_Coroutine_methods,
5626 __pyx_Coroutine_memberlist,
5627 __pyx_Coroutine_getsets,
5628 0,
5629 0,
5630 0,
5631 0,
5632 0,
5633 0,
5634 0,
5635 0,
5636 0,
5637 0,
5638 0,
5639 0,
5640 0,
5641 0,
5642 0,
5643 #if CYTHON_USE_TP_FINALIZE
5644 0,
5645 #else
5646 __Pyx_Coroutine_del,
5647 #endif
5648 0,
5649 #if CYTHON_USE_TP_FINALIZE
5650 __Pyx_Coroutine_del,
5651 #elif PY_VERSION_HEX >= 0x030400a1
5652 0,
5653 #endif
5654 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
5655 0,
5656 #endif
5657 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
5658 0,
5659 #endif
5660 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
5661 0,
5662 #endif
5663 };
5664 static int __pyx_Coroutine_init(void) {
5665 __pyx_CoroutineType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
5666 __pyx_CoroutineType = __Pyx_FetchCommonType(&__pyx_CoroutineType_type);
5667 if (unlikely(!__pyx_CoroutineType))
5668 return -1;
5669 #ifdef __Pyx_IterableCoroutine_USED
5670 if (unlikely(__pyx_IterableCoroutine_init() == -1))
5671 return -1;
5672 #endif
5673 __pyx_CoroutineAwaitType = __Pyx_FetchCommonType(&__pyx_CoroutineAwaitType_type);
5674 if (unlikely(!__pyx_CoroutineAwaitType))
5675 return -1;
5676 return 0;
5677 }
5678
5679 /* CoroutineYieldFrom */
5680 static PyObject* __Pyx__Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen, PyObject *source) {
5681 PyObject *retval;
5682 PyObject *source_gen = __Pyx__Coroutine_GetAwaitableIter(source);
5683 if (unlikely(!source_gen)) {
5684 return NULL;
5685 }
5686 if (__Pyx_Coroutine_Check(source_gen)) {
5687 retval = __Pyx_Generator_Next(source_gen);
5688 } else {
5689 #if CYTHON_USE_TYPE_SLOTS
5690 retval = Py_TYPE(source_gen)->tp_iternext(source_gen);
5691 #else
5692 retval = PyIter_Next(source_gen);
5693 #endif
5694 }
5695 if (retval) {
5696 gen->yieldfrom = source_gen;
5697 return retval;
5698 }
5699 Py_DECREF(source_gen);
5700 return NULL;
5701 }
5702 static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source) {
5703 PyObject *retval;
5704 if (__Pyx_Coroutine_Check(source)) {
5705 if (unlikely(((__pyx_CoroutineObject*)source)->yieldfrom)) {
5706 PyErr_SetString(
5707 PyExc_RuntimeError,
5708 "coroutine is being awaited already");
5709 return NULL;
5710 }
5711 retval = __Pyx_Generator_Next(source);
5712 #ifdef __Pyx_AsyncGen_USED
5713 } else if (__pyx_PyAsyncGenASend_CheckExact(source)) {
5714 retval = __Pyx_async_gen_asend_iternext(source);
5715 #endif
5716 } else {
5717 return __Pyx__Coroutine_Yield_From_Generic(gen, source);
5718 }
5719 if (retval) {
5720 Py_INCREF(source);
5721 gen->yieldfrom = source;
5722 }
5723 return retval;
5724 }
5725
5726 /* ReturnWithStopIteration */
5727 static void __Pyx__ReturnWithStopIteration(PyObject* value) {
5728 PyObject *exc, *args;
5729 #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_PYSTON
5730 __Pyx_PyThreadState_declare
5731 if ((PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030500B1)
5732 || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
5733 args = PyTuple_New(1);
5734 if (unlikely(!args)) return;
5735 Py_INCREF(value);
5736 PyTuple_SET_ITEM(args, 0, value);
5737 exc = PyType_Type.tp_call(PyExc_StopIteration, args, NULL);
5738 Py_DECREF(args);
5739 if (!exc) return;
5740 } else {
5741 Py_INCREF(value);
5742 exc = value;
5743 }
5744 #if CYTHON_FAST_THREAD_STATE
5745 __Pyx_PyThreadState_assign
5746 #if CYTHON_USE_EXC_INFO_STACK
5747 if (!__pyx_tstate->exc_info->exc_type)
5748 #else
5749 if (!__pyx_tstate->exc_type)
5750 #endif
5751 {
5752 Py_INCREF(PyExc_StopIteration);
5753 __Pyx_ErrRestore(PyExc_StopIteration, exc, NULL);
5754 return;
5755 }
5756 #endif
5757 #else
5758 args = PyTuple_Pack(1, value);
5759 if (unlikely(!args)) return;
5760 exc = PyObject_Call(PyExc_StopIteration, args, NULL);
5761 Py_DECREF(args);
5762 if (unlikely(!exc)) return;
5763 #endif
5764 PyErr_SetObject(PyExc_StopIteration, exc);
5765 Py_DECREF(exc);
5766 }
5767
5768 /* CythonFunctionShared */
5769 #include <structmember.h>
5770 static PyObject *
5771 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
5772 {
5773 if (unlikely(op->func_doc == NULL)) {
5774 if (op->func.m_ml->ml_doc) {
5775 #if PY_MAJOR_VERSION >= 3
5776 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
5777 #else
5778 op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
5779 #endif
5780 if (unlikely(op->func_doc == NULL))
5781 return NULL;
5782 } else {
5783 Py_INCREF(Py_None);
5784 return Py_None;
5785 }
5786 }
5787 Py_INCREF(op->func_doc);
5788 return op->func_doc;
5789 }
5790 static int
5791 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
5792 {
5793 PyObject *tmp = op->func_doc;
5794 if (value == NULL) {
5795 value = Py_None;
5796 }
5797 Py_INCREF(value);
5798 op->func_doc = value;
5799 Py_XDECREF(tmp);
5800 return 0;
5801 }
5802 static PyObject *
5803 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
5804 {
5805 if (unlikely(op->func_name == NULL)) {
5806 #if PY_MAJOR_VERSION >= 3
5807 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
5808 #else
5809 op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
5810 #endif
5811 if (unlikely(op->func_name == NULL))
5812 return NULL;
5813 }
5814 Py_INCREF(op->func_name);
5815 return op->func_name;
5816 }
5817 static int
5818 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
5819 {
5820 PyObject *tmp;
5821 #if PY_MAJOR_VERSION >= 3
5822 if (unlikely(value == NULL || !PyUnicode_Check(value)))
5823 #else
5824 if (unlikely(value == NULL || !PyString_Check(value)))
5825 #endif
5826 {
5827 PyErr_SetString(PyExc_TypeError,
5828 "__name__ must be set to a string object");
5829 return -1;
5830 }
5831 tmp = op->func_name;
5832 Py_INCREF(value);
5833 op->func_name = value;
5834 Py_XDECREF(tmp);
5835 return 0;
5836 }
5837 static PyObject *
5838 __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
5839 {
5840 Py_INCREF(op->func_qualname);
5841 return op->func_qualname;
5842 }
5843 static int
5844 __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
5845 {
5846 PyObject *tmp;
5847 #if PY_MAJOR_VERSION >= 3
5848 if (unlikely(value == NULL || !PyUnicode_Check(value)))
5849 #else
5850 if (unlikely(value == NULL || !PyString_Check(value)))
5851 #endif
5852 {
5853 PyErr_SetString(PyExc_TypeError,
5854 "__qualname__ must be set to a string object");
5855 return -1;
5856 }
5857 tmp = op->func_qualname;
5858 Py_INCREF(value);
5859 op->func_qualname = value;
5860 Py_XDECREF(tmp);
5861 return 0;
5862 }
5863 static PyObject *
5864 __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
5865 {
5866 PyObject *self;
5867 self = m->func_closure;
5868 if (self == NULL)
5869 self = Py_None;
5870 Py_INCREF(self);
5871 return self;
5872 }
5873 static PyObject *
5874 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
5875 {
5876 if (unlikely(op->func_dict == NULL)) {
5877 op->func_dict = PyDict_New();
5878 if (unlikely(op->func_dict == NULL))
5879 return NULL;
5880 }
5881 Py_INCREF(op->func_dict);
5882 return op->func_dict;
5883 }
5884 static int
5885 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
5886 {
5887 PyObject *tmp;
5888 if (unlikely(value == NULL)) {
5889 PyErr_SetString(PyExc_TypeError,
5890 "function's dictionary may not be deleted");
5891 return -1;
5892 }
5893 if (unlikely(!PyDict_Check(value))) {
5894 PyErr_SetString(PyExc_TypeError,
5895 "setting function's dictionary to a non-dict");
5896 return -1;
5897 }
5898 tmp = op->func_dict;
5899 Py_INCREF(value);
5900 op->func_dict = value;
5901 Py_XDECREF(tmp);
5902 return 0;
5903 }
5904 static PyObject *
5905 __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
5906 {
5907 Py_INCREF(op->func_globals);
5908 return op->func_globals;
5909 }
5910 static PyObject *
5911 __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
5912 {
5913 Py_INCREF(Py_None);
5914 return Py_None;
5915 }
5916 static PyObject *
5917 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
5918 {
5919 PyObject* result = (op->func_code) ? op->func_code : Py_None;
5920 Py_INCREF(result);
5921 return result;
5922 }
5923 static int
5924 __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
5925 int result = 0;
5926 PyObject *res = op->defaults_getter((PyObject *) op);
5927 if (unlikely(!res))
5928 return -1;
5929 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5930 op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
5931 Py_INCREF(op->defaults_tuple);
5932 op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
5933 Py_INCREF(op->defaults_kwdict);
5934 #else
5935 op->defaults_tuple = PySequence_ITEM(res, 0);
5936 if (unlikely(!op->defaults_tuple)) result = -1;
5937 else {
5938 op->defaults_kwdict = PySequence_ITEM(res, 1);
5939 if (unlikely(!op->defaults_kwdict)) result = -1;
5940 }
5941 #endif
5942 Py_DECREF(res);
5943 return result;
5944 }
5945 static int
5946 __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
5947 PyObject* tmp;
5948 if (!value) {
5949 value = Py_None;
5950 } else if (value != Py_None && !PyTuple_Check(value)) {
5951 PyErr_SetString(PyExc_TypeError,
5952 "__defaults__ must be set to a tuple object");
5953 return -1;
5954 }
5955 Py_INCREF(value);
5956 tmp = op->defaults_tuple;
5957 op->defaults_tuple = value;
5958 Py_XDECREF(tmp);
5959 return 0;
5960 }
5961 static PyObject *
5962 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
5963 PyObject* result = op->defaults_tuple;
5964 if (unlikely(!result)) {
5965 if (op->defaults_getter) {
5966 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
5967 result = op->defaults_tuple;
5968 } else {
5969 result = Py_None;
5970 }
5971 }
5972 Py_INCREF(result);
5973 return result;
5974 }
5975 static int
5976 __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
5977 PyObject* tmp;
5978 if (!value) {
5979 value = Py_None;
5980 } else if (value != Py_None && !PyDict_Check(value)) {
5981 PyErr_SetString(PyExc_TypeError,
5982 "__kwdefaults__ must be set to a dict object");
5983 return -1;
5984 }
5985 Py_INCREF(value);
5986 tmp = op->defaults_kwdict;
5987 op->defaults_kwdict = value;
5988 Py_XDECREF(tmp);
5989 return 0;
5990 }
5991 static PyObject *
5992 __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
5993 PyObject* result = op->defaults_kwdict;
5994 if (unlikely(!result)) {
5995 if (op->defaults_getter) {
5996 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
5997 result = op->defaults_kwdict;
5998 } else {
5999 result = Py_None;
6000 }
6001 }
6002 Py_INCREF(result);
6003 return result;
6004 }
6005 static int
6006 __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
6007 PyObject* tmp;
6008 if (!value || value == Py_None) {
6009 value = NULL;
6010 } else if (!PyDict_Check(value)) {
6011 PyErr_SetString(PyExc_TypeError,
6012 "__annotations__ must be set to a dict object");
6013 return -1;
6014 }
6015 Py_XINCREF(value);
6016 tmp = op->func_annotations;
6017 op->func_annotations = value;
6018 Py_XDECREF(tmp);
6019 return 0;
6020 }
6021 static PyObject *
6022 __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
6023 PyObject* result = op->func_annotations;
6024 if (unlikely(!result)) {
6025 result = PyDict_New();
6026 if (unlikely(!result)) return NULL;
6027 op->func_annotations = result;
6028 }
6029 Py_INCREF(result);
6030 return result;
6031 }
6032 static PyGetSetDef __pyx_CyFunction_getsets[] = {
6033 {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
6034 {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
6035 {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
6036 {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
6037 {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
6038 {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
6039 {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
6040 {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
6041 {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
6042 {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
6043 {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
6044 {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
6045 {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
6046 {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
6047 {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
6048 {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
6049 {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
6050 {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
6051 {0, 0, 0, 0, 0}
6052 };
6053 static PyMemberDef __pyx_CyFunction_members[] = {
6054 {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
6055 {0, 0, 0, 0, 0}
6056 };
6057 static PyObject *
6058 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
6059 {
6060 #if PY_MAJOR_VERSION >= 3
6061 Py_INCREF(m->func_qualname);
6062 return m->func_qualname;
6063 #else
6064 return PyString_FromString(m->func.m_ml->ml_name);
6065 #endif
6066 }
6067 static PyMethodDef __pyx_CyFunction_methods[] = {
6068 {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
6069 {0, 0, 0, 0}
6070 };
6071 #if PY_VERSION_HEX < 0x030500A0
6072 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
6073 #else
6074 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
6075 #endif
6076 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
6077 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
6078 if (unlikely(op == NULL))
6079 return NULL;
6080 op->flags = flags;
6081 __Pyx_CyFunction_weakreflist(op) = NULL;
6082 op->func.m_ml = ml;
6083 op->func.m_self = (PyObject *) op;
6084 Py_XINCREF(closure);
6085 op->func_closure = closure;
6086 Py_XINCREF(module);
6087 op->func.m_module = module;
6088 op->func_dict = NULL;
6089 op->func_name = NULL;
6090 Py_INCREF(qualname);
6091 op->func_qualname = qualname;
6092 op->func_doc = NULL;
6093 op->func_classobj = NULL;
6094 op->func_globals = globals;
6095 Py_INCREF(op->func_globals);
6096 Py_XINCREF(code);
6097 op->func_code = code;
6098 op->defaults_pyobjects = 0;
6099 op->defaults_size = 0;
6100 op->defaults = NULL;
6101 op->defaults_tuple = NULL;
6102 op->defaults_kwdict = NULL;
6103 op->defaults_getter = NULL;
6104 op->func_annotations = NULL;
6105 return (PyObject *) op;
6106 }
6107 static int
6108 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
6109 {
6110 Py_CLEAR(m->func_closure);
6111 Py_CLEAR(m->func.m_module);
6112 Py_CLEAR(m->func_dict);
6113 Py_CLEAR(m->func_name);
6114 Py_CLEAR(m->func_qualname);
6115 Py_CLEAR(m->func_doc);
6116 Py_CLEAR(m->func_globals);
6117 Py_CLEAR(m->func_code);
6118 Py_CLEAR(m->func_classobj);
6119 Py_CLEAR(m->defaults_tuple);
6120 Py_CLEAR(m->defaults_kwdict);
6121 Py_CLEAR(m->func_annotations);
6122 if (m->defaults) {
6123 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
6124 int i;
6125 for (i = 0; i < m->defaults_pyobjects; i++)
6126 Py_XDECREF(pydefaults[i]);
6127 PyObject_Free(m->defaults);
6128 m->defaults = NULL;
6129 }
6130 return 0;
6131 }
6132 static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
6133 {
6134 if (__Pyx_CyFunction_weakreflist(m) != NULL)
6135 PyObject_ClearWeakRefs((PyObject *) m);
6136 __Pyx_CyFunction_clear(m);
6137 PyObject_GC_Del(m);
6138 }
6139 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
6140 {
6141 PyObject_GC_UnTrack(m);
6142 __Pyx__CyFunction_dealloc(m);
6143 }
6144 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
6145 {
6146 Py_VISIT(m->func_closure);
6147 Py_VISIT(m->func.m_module);
6148 Py_VISIT(m->func_dict);
6149 Py_VISIT(m->func_name);
6150 Py_VISIT(m->func_qualname);
6151 Py_VISIT(m->func_doc);
6152 Py_VISIT(m->func_globals);
6153 Py_VISIT(m->func_code);
6154 Py_VISIT(m->func_classobj);
6155 Py_VISIT(m->defaults_tuple);
6156 Py_VISIT(m->defaults_kwdict);
6157 if (m->defaults) {
6158 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
6159 int i;
6160 for (i = 0; i < m->defaults_pyobjects; i++)
6161 Py_VISIT(pydefaults[i]);
6162 }
6163 return 0;
6164 }
6165 static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
6166 {
6167 #if PY_MAJOR_VERSION < 3
6168 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6169 if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
6170 Py_INCREF(func);
6171 return func;
6172 }
6173 if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
6174 if (type == NULL)
6175 type = (PyObject *)(Py_TYPE(obj));
6176 return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
6177 }
6178 if (obj == Py_None)
6179 obj = NULL;
6180 #endif
6181 return __Pyx_PyMethod_New(func, obj, type);
6182 }
6183 static PyObject*
6184 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
6185 {
6186 #if PY_MAJOR_VERSION >= 3
6187 return PyUnicode_FromFormat("<cyfunction %U at %p>",
6188 op->func_qualname, (void *)op);
6189 #else
6190 return PyString_FromFormat("<cyfunction %s at %p>",
6191 PyString_AsString(op->func_qualname), (void *)op);
6192 #endif
6193 }
6194 static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
6195 PyCFunctionObject* f = (PyCFunctionObject*)func;
6196 PyCFunction meth = f->m_ml->ml_meth;
6197 Py_ssize_t size;
6198 switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
6199 case METH_VARARGS:
6200 if (likely(kw == NULL || PyDict_Size(kw) == 0))
6201 return (*meth)(self, arg);
6202 break;
6203 case METH_VARARGS | METH_KEYWORDS:
6204 return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
6205 case METH_NOARGS:
6206 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
6207 size = PyTuple_GET_SIZE(arg);
6208 if (likely(size == 0))
6209 return (*meth)(self, NULL);
6210 PyErr_Format(PyExc_TypeError,
6211 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
6212 f->m_ml->ml_name, size);
6213 return NULL;
6214 }
6215 break;
6216 case METH_O:
6217 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
6218 size = PyTuple_GET_SIZE(arg);
6219 if (likely(size == 1)) {
6220 PyObject *result, *arg0;
6221 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6222 arg0 = PyTuple_GET_ITEM(arg, 0);
6223 #else
6224 arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
6225 #endif
6226 result = (*meth)(self, arg0);
6227 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
6228 Py_DECREF(arg0);
6229 #endif
6230 return result;
6231 }
6232 PyErr_Format(PyExc_TypeError,
6233 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
6234 f->m_ml->ml_name, size);
6235 return NULL;
6236 }
6237 break;
6238 default:
6239 PyErr_SetString(PyExc_SystemError, "Bad call flags in "
6240 "__Pyx_CyFunction_Call. METH_OLDARGS is no "
6241 "longer supported!");
6242 return NULL;
6243 }
6244 PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
6245 f->m_ml->ml_name);
6246 return NULL;
6247 }
6248 static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
6249 return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
6250 }
6251 static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
6252 PyObject *result;
6253 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
6254 if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
6255 Py_ssize_t argc;
6256 PyObject *new_args;
6257 PyObject *self;
6258 argc = PyTuple_GET_SIZE(args);
6259 new_args = PyTuple_GetSlice(args, 1, argc);
6260 if (unlikely(!new_args))
6261 return NULL;
6262 self = PyTuple_GetItem(args, 0);
6263 if (unlikely(!self)) {
6264 Py_DECREF(new_args);
6265 #if PY_MAJOR_VERSION > 2
6266 PyErr_Format(PyExc_TypeError,
6267 "unbound method %.200S() needs an argument",
6268 cyfunc->func_qualname);
6269 #else
6270 PyErr_SetString(PyExc_TypeError,
6271 "unbound method needs an argument");
6272 #endif
6273 return NULL;
6274 }
6275 result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
6276 Py_DECREF(new_args);
6277 } else {
6278 result = __Pyx_CyFunction_Call(func, args, kw);
6279 }
6280 return result;
6281 }
6282 static PyTypeObject __pyx_CyFunctionType_type = {
6283 PyVarObject_HEAD_INIT(0, 0)
6284 "cython_function_or_method",
6285 sizeof(__pyx_CyFunctionObject),
6286 0,
6287 (destructor) __Pyx_CyFunction_dealloc,
6288 0,
6289 0,
6290 0,
6291 #if PY_MAJOR_VERSION < 3
6292 0,
6293 #else
6294 0,
6295 #endif
6296 (reprfunc) __Pyx_CyFunction_repr,
6297 0,
6298 0,
6299 0,
6300 0,
6301 __Pyx_CyFunction_CallAsMethod,
6302 0,
6303 0,
6304 0,
6305 0,
6306 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
6307 0,
6308 (traverseproc) __Pyx_CyFunction_traverse,
6309 (inquiry) __Pyx_CyFunction_clear,
6310 0,
6311 #if PY_VERSION_HEX < 0x030500A0
6312 offsetof(__pyx_CyFunctionObject, func_weakreflist),
6313 #else
6314 offsetof(PyCFunctionObject, m_weakreflist),
6315 #endif
6316 0,
6317 0,
6318 __pyx_CyFunction_methods,
6319 __pyx_CyFunction_members,
6320 __pyx_CyFunction_getsets,
6321 0,
6322 0,
6323 __Pyx_CyFunction_descr_get,
6324 0,
6325 offsetof(__pyx_CyFunctionObject, func_dict),
6326 0,
6327 0,
6328 0,
6329 0,
6330 0,
6331 0,
6332 0,
6333 0,
6334 0,
6335 0,
6336 0,
6337 0,
6338 #if PY_VERSION_HEX >= 0x030400a1
6339 0,
6340 #endif
6341 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
6342 0,
6343 #endif
6344 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
6345 0,
6346 #endif
6347 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
6348 0,
6349 #endif
6350 };
6351 static int __pyx_CyFunction_init(void) {
6352 __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
6353 if (unlikely(__pyx_CyFunctionType == NULL)) {
6354 return -1;
6355 }
6356 return 0;
6357 }
6358 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
6359 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6360 m->defaults = PyObject_Malloc(size);
6361 if (unlikely(!m->defaults))
6362 return PyErr_NoMemory();
6363 memset(m->defaults, 0, size);
6364 m->defaults_pyobjects = pyobjects;
6365 m->defaults_size = size;
6366 return m->defaults;
6367 }
6368 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
6369 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6370 m->defaults_tuple = tuple;
6371 Py_INCREF(tuple);
6372 }
6373 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
6374 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6375 m->defaults_kwdict = dict;
6376 Py_INCREF(dict);
6377 }
6378 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
6379 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6380 m->func_annotations = dict;
6381 Py_INCREF(dict);
6382 }
6383
6384 /* CythonFunction */
6385 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
6386 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
6387 PyObject *op = __Pyx_CyFunction_Init(
6388 PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
6389 ml, flags, qualname, closure, module, globals, code
6390 );
6391 if (likely(op)) {
6392 PyObject_GC_Track(op);
6393 }
6394 return op;
6395 }
6396
6397 /* PyDictVersioning */
6398 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
6399 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
6400 PyObject *dict = Py_TYPE(obj)->tp_dict;
6401 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
6402 }
6403 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
6404 PyObject **dictptr = NULL;
6405 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
6406 if (offset) {
6407 #if CYTHON_COMPILING_IN_CPYTHON
6408 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
6409 #else
6410 dictptr = _PyObject_GetDictPtr(obj);
6411 #endif
6412 }
6413 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
6414 }
6415 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
6416 PyObject *dict = Py_TYPE(obj)->tp_dict;
6417 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
6418 return 0;
6419 return obj_dict_version == __Pyx_get_object_dict_version(obj);
6420 }
6421 #endif
6422
6423 /* GetModuleGlobalName */
6424 #if CYTHON_USE_DICT_VERSIONS
6425 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
6426 #else
6427 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
6428 #endif
6429 {
6430 PyObject *result;
6431 #if !CYTHON_AVOID_BORROWED_REFS
6432 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
6433 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
6434 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
6435 if (likely(result)) {
6436 return __Pyx_NewRef(result);
6437 } else if (unlikely(PyErr_Occurred())) {
6438 return NULL;
6439 }
6440 #else
6441 result = PyDict_GetItem(__pyx_d, name);
6442 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
6443 if (likely(result)) {
6444 return __Pyx_NewRef(result);
6445 }
6446 #endif
6447 #else
6448 result = PyObject_GetItem(__pyx_d, name);
6449 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
6450 if (likely(result)) {
6451 return __Pyx_NewRef(result);
6452 }
6453 PyErr_Clear();
6454 #endif
6455 return __Pyx_GetBuiltinName(name);
6456 }
6457
6458 /* CLineInTraceback */
6459 #ifndef CYTHON_CLINE_IN_TRACEBACK
6460 static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
6461 PyObject *use_cline;
6462 PyObject *ptype, *pvalue, *ptraceback;
6463 #if CYTHON_COMPILING_IN_CPYTHON
6464 PyObject **cython_runtime_dict;
6465 #endif
6466 if (unlikely(!__pyx_cython_runtime)) {
6467 return c_line;
6468 }
6469 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
6470 #if CYTHON_COMPILING_IN_CPYTHON
6471 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
6472 if (likely(cython_runtime_dict)) {
6473 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
6474 use_cline, *cython_runtime_dict,
6475 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
6476 } else
6477 #endif
6478 {
6479 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
6480 if (use_cline_obj) {
6481 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
6482 Py_DECREF(use_cline_obj);
6483 } else {
6484 PyErr_Clear();
6485 use_cline = NULL;
6486 }
6487 }
6488 if (!use_cline) {
6489 c_line = 0;
6490 (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
6491 }
6492 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
6493 c_line = 0;
6494 }
6495 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
6496 return c_line;
6497 }
6498 #endif
6499
6500 /* CodeObjectCache */
6501 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
6502 int start = 0, mid = 0, end = count - 1;
6503 if (end >= 0 && code_line > entries[end].code_line) {
6504 return count;
6505 }
6506 while (start < end) {
6507 mid = start + (end - start) / 2;
6508 if (code_line < entries[mid].code_line) {
6509 end = mid;
6510 } else if (code_line > entries[mid].code_line) {
6511 start = mid + 1;
6512 } else {
6513 return mid;
6514 }
6515 }
6516 if (code_line <= entries[mid].code_line) {
6517 return mid;
6518 } else {
6519 return mid + 1;
6520 }
6521 }
6522 static PyCodeObject *__pyx_find_code_object(int code_line) {
6523 PyCodeObject* code_object;
6524 int pos;
6525 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
6526 return NULL;
6527 }
6528 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6529 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
6530 return NULL;
6531 }
6532 code_object = __pyx_code_cache.entries[pos].code_object;
6533 Py_INCREF(code_object);
6534 return code_object;
6535 }
6536 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
6537 int pos, i;
6538 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
6539 if (unlikely(!code_line)) {
6540 return;
6541 }
6542 if (unlikely(!entries)) {
6543 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
6544 if (likely(entries)) {
6545 __pyx_code_cache.entries = entries;
6546 __pyx_code_cache.max_count = 64;
6547 __pyx_code_cache.count = 1;
6548 entries[0].code_line = code_line;
6549 entries[0].code_object = code_object;
6550 Py_INCREF(code_object);
6551 }
6552 return;
6553 }
6554 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6555 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
6556 PyCodeObject* tmp = entries[pos].code_object;
6557 entries[pos].code_object = code_object;
6558 Py_DECREF(tmp);
6559 return;
6560 }
6561 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
6562 int new_max = __pyx_code_cache.max_count + 64;
6563 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
6564 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
6565 if (unlikely(!entries)) {
6566 return;
6567 }
6568 __pyx_code_cache.entries = entries;
6569 __pyx_code_cache.max_count = new_max;
6570 }
6571 for (i=__pyx_code_cache.count; i>pos; i--) {
6572 entries[i] = entries[i-1];
6573 }
6574 entries[pos].code_line = code_line;
6575 entries[pos].code_object = code_object;
6576 __pyx_code_cache.count++;
6577 Py_INCREF(code_object);
6578 }
6579
6580 /* AddTraceback */
6581 #include "compile.h"
6582 #include "frameobject.h"
6583 #include "traceback.h"
6584 #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
6585 #ifndef Py_BUILD_CORE
6586 #define Py_BUILD_CORE 1
6587 #endif
6588 #include "internal/pycore_frame.h"
6589 #endif
6590 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
6591 const char *funcname, int c_line,
6592 int py_line, const char *filename) {
6593 PyCodeObject *py_code = NULL;
6594 PyObject *py_funcname = NULL;
6595 #if PY_MAJOR_VERSION < 3
6596 PyObject *py_srcfile = NULL;
6597 py_srcfile = PyString_FromString(filename);
6598 if (!py_srcfile) goto bad;
6599 #endif
6600 if (c_line) {
6601 #if PY_MAJOR_VERSION < 3
6602 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6603 if (!py_funcname) goto bad;
6604 #else
6605 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6606 if (!py_funcname) goto bad;
6607 funcname = PyUnicode_AsUTF8(py_funcname);
6608 if (!funcname) goto bad;
6609 #endif
6610 }
6611 else {
6612 #if PY_MAJOR_VERSION < 3
6613 py_funcname = PyString_FromString(funcname);
6614 if (!py_funcname) goto bad;
6615 #endif
6616 }
6617 #if PY_MAJOR_VERSION < 3
6618 py_code = __Pyx_PyCode_New(
6619 0,
6620 0,
6621 0,
6622 0,
6623 0,
6624 __pyx_empty_bytes, /*PyObject *code,*/
6625 __pyx_empty_tuple, /*PyObject *consts,*/
6626 __pyx_empty_tuple, /*PyObject *names,*/
6627 __pyx_empty_tuple, /*PyObject *varnames,*/
6628 __pyx_empty_tuple, /*PyObject *freevars,*/
6629 __pyx_empty_tuple, /*PyObject *cellvars,*/
6630 py_srcfile, /*PyObject *filename,*/
6631 py_funcname, /*PyObject *name,*/
6632 py_line,
6633 __pyx_empty_bytes /*PyObject *lnotab*/
6634 );
6635 Py_DECREF(py_srcfile);
6636 #else
6637 py_code = PyCode_NewEmpty(filename, funcname, py_line);
6638 #endif
6639 Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline
6640 return py_code;
6641 bad:
6642 Py_XDECREF(py_funcname);
6643 #if PY_MAJOR_VERSION < 3
6644 Py_XDECREF(py_srcfile);
6645 #endif
6646 return NULL;
6647 }
6648 static void __Pyx_AddTraceback(const char *funcname, int c_line,
6649 int py_line, const char *filename) {
6650 PyCodeObject *py_code = 0;
6651 PyFrameObject *py_frame = 0;
6652 PyThreadState *tstate = __Pyx_PyThreadState_Current;
6653 PyObject *ptype, *pvalue, *ptraceback;
6654 if (c_line) {
6655 c_line = __Pyx_CLineForTraceback(tstate, c_line);
6656 }
6657 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
6658 if (!py_code) {
6659 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
6660 py_code = __Pyx_CreateCodeObjectForTraceback(
6661 funcname, c_line, py_line, filename);
6662 if (!py_code) {
6663 /* If the code object creation fails, then we should clear the
6664 fetched exception references and propagate the new exception */
6665 Py_XDECREF(ptype);
6666 Py_XDECREF(pvalue);
6667 Py_XDECREF(ptraceback);
6668 goto bad;
6669 }
6670 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
6671 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
6672 }
6673 py_frame = PyFrame_New(
6674 tstate, /*PyThreadState *tstate,*/
6675 py_code, /*PyCodeObject *code,*/
6676 __pyx_d, /*PyObject *globals,*/
6677 0 /*PyObject *locals*/
6678 );
6679 if (!py_frame) goto bad;
6680 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
6681 PyTraceBack_Here(py_frame);
6682 bad:
6683 Py_XDECREF(py_code);
6684 Py_XDECREF(py_frame);
6685 }
6686
6687 /* CIntToPy */
6688 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
6689 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
6690 #pragma GCC diagnostic push
6691 #pragma GCC diagnostic ignored "-Wconversion"
6692 #endif
6693 const long neg_one = (long) -1, const_zero = (long) 0;
6694 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
6695 #pragma GCC diagnostic pop
6696 #endif
6697 const int is_unsigned = neg_one > const_zero;
6698 if (is_unsigned) {
6699 if (sizeof(long) < sizeof(long)) {
6700 return PyInt_FromLong((long) value);
6701 } else if (sizeof(long) <= sizeof(unsigned long)) {
6702 return PyLong_FromUnsignedLong((unsigned long) value);
6703 #ifdef HAVE_LONG_LONG
6704 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
6705 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
6706 #endif
6707 }
6708 } else {
6709 if (sizeof(long) <= sizeof(long)) {
6710 return PyInt_FromLong((long) value);
6711 #ifdef HAVE_LONG_LONG
6712 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
6713 return PyLong_FromLongLong((PY_LONG_LONG) value);
6714 #endif
6715 }
6716 }
6717 {
6718 int one = 1; int little = (int)*(unsigned char *)&one;
6719 unsigned char *bytes = (unsigned char *)&value;
6720 return _PyLong_FromByteArray(bytes, sizeof(long),
6721 little, !is_unsigned);
6722 }
6723 }
6724
6725 /* CIntFromPyVerify */
6726 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
6727 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
6728 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
6729 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
6730 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
6731 {\
6732 func_type value = func_value;\
6733 if (sizeof(target_type) < sizeof(func_type)) {\
6734 if (unlikely(value != (func_type) (target_type) value)) {\
6735 func_type zero = 0;\
6736 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
6737 return (target_type) -1;\
6738 if (is_unsigned && unlikely(value < zero))\
6739 goto raise_neg_overflow;\
6740 else\
6741 goto raise_overflow;\
6742 }\
6743 }\
6744 return (target_type) value;\
6745 }
6746
6747 /* CIntFromPy */
6748 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
6749 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
6750 #pragma GCC diagnostic push
6751 #pragma GCC diagnostic ignored "-Wconversion"
6752 #endif
6753 const long neg_one = (long) -1, const_zero = (long) 0;
6754 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
6755 #pragma GCC diagnostic pop
6756 #endif
6757 const int is_unsigned = neg_one > const_zero;
6758 #if PY_MAJOR_VERSION < 3
6759 if (likely(PyInt_Check(x))) {
6760 if (sizeof(long) < sizeof(long)) {
6761 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
6762 } else {
6763 long val = PyInt_AS_LONG(x);
6764 if (is_unsigned && unlikely(val < 0)) {
6765 goto raise_neg_overflow;
6766 }
6767 return (long) val;
6768 }
6769 } else
6770 #endif
6771 if (likely(PyLong_Check(x))) {
6772 if (is_unsigned) {
6773 #if CYTHON_USE_PYLONG_INTERNALS
6774 const digit* digits = ((PyLongObject*)x)->ob_digit;
6775 switch (Py_SIZE(x)) {
6776 case 0: return (long) 0;
6777 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
6778 case 2:
6779 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
6780 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6781 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6782 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
6783 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6784 }
6785 }
6786 break;
6787 case 3:
6788 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
6789 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6790 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6791 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
6792 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6793 }
6794 }
6795 break;
6796 case 4:
6797 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
6798 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6799 __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])))
6800 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
6801 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6802 }
6803 }
6804 break;
6805 }
6806 #endif
6807 #if CYTHON_COMPILING_IN_CPYTHON
6808 if (unlikely(Py_SIZE(x) < 0)) {
6809 goto raise_neg_overflow;
6810 }
6811 #else
6812 {
6813 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
6814 if (unlikely(result < 0))
6815 return (long) -1;
6816 if (unlikely(result == 1))
6817 goto raise_neg_overflow;
6818 }
6819 #endif
6820 if (sizeof(long) <= sizeof(unsigned long)) {
6821 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
6822 #ifdef HAVE_LONG_LONG
6823 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
6824 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
6825 #endif
6826 }
6827 } else {
6828 #if CYTHON_USE_PYLONG_INTERNALS
6829 const digit* digits = ((PyLongObject*)x)->ob_digit;
6830 switch (Py_SIZE(x)) {
6831 case 0: return (long) 0;
6832 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
6833 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
6834 case -2:
6835 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
6836 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6837 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6838 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6839 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6840 }
6841 }
6842 break;
6843 case 2:
6844 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
6845 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6846 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6847 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6848 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6849 }
6850 }
6851 break;
6852 case -3:
6853 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6854 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6855 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6856 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6857 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6858 }
6859 }
6860 break;
6861 case 3:
6862 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
6863 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6864 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6865 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6866 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6867 }
6868 }
6869 break;
6870 case -4:
6871 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6872 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6873 __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])))
6874 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6875 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6876 }
6877 }
6878 break;
6879 case 4:
6880 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
6881 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6882 __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])))
6883 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6884 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6885 }
6886 }
6887 break;
6888 }
6889 #endif
6890 if (sizeof(long) <= sizeof(long)) {
6891 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
6892 #ifdef HAVE_LONG_LONG
6893 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
6894 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
6895 #endif
6896 }
6897 }
6898 {
6899 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
6900 PyErr_SetString(PyExc_RuntimeError,
6901 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
6902 #else
6903 long val;
6904 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
6905 #if PY_MAJOR_VERSION < 3
6906 if (likely(v) && !PyLong_Check(v)) {
6907 PyObject *tmp = v;
6908 v = PyNumber_Long(tmp);
6909 Py_DECREF(tmp);
6910 }
6911 #endif
6912 if (likely(v)) {
6913 int one = 1; int is_little = (int)*(unsigned char *)&one;
6914 unsigned char *bytes = (unsigned char *)&val;
6915 int ret = _PyLong_AsByteArray((PyLongObject *)v,
6916 bytes, sizeof(val),
6917 is_little, !is_unsigned);
6918 Py_DECREF(v);
6919 if (likely(!ret))
6920 return val;
6921 }
6922 #endif
6923 return (long) -1;
6924 }
6925 } else {
6926 long val;
6927 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
6928 if (!tmp) return (long) -1;
6929 val = __Pyx_PyInt_As_long(tmp);
6930 Py_DECREF(tmp);
6931 return val;
6932 }
6933 raise_overflow:
6934 PyErr_SetString(PyExc_OverflowError,
6935 "value too large to convert to long");
6936 return (long) -1;
6937 raise_neg_overflow:
6938 PyErr_SetString(PyExc_OverflowError,
6939 "can't convert negative value to long");
6940 return (long) -1;
6941 }
6942
6943 /* CIntFromPy */
6944 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
6945 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
6946 #pragma GCC diagnostic push
6947 #pragma GCC diagnostic ignored "-Wconversion"
6948 #endif
6949 const int neg_one = (int) -1, const_zero = (int) 0;
6950 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
6951 #pragma GCC diagnostic pop
6952 #endif
6953 const int is_unsigned = neg_one > const_zero;
6954 #if PY_MAJOR_VERSION < 3
6955 if (likely(PyInt_Check(x))) {
6956 if (sizeof(int) < sizeof(long)) {
6957 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
6958 } else {
6959 long val = PyInt_AS_LONG(x);
6960 if (is_unsigned && unlikely(val < 0)) {
6961 goto raise_neg_overflow;
6962 }
6963 return (int) val;
6964 }
6965 } else
6966 #endif
6967 if (likely(PyLong_Check(x))) {
6968 if (is_unsigned) {
6969 #if CYTHON_USE_PYLONG_INTERNALS
6970 const digit* digits = ((PyLongObject*)x)->ob_digit;
6971 switch (Py_SIZE(x)) {
6972 case 0: return (int) 0;
6973 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
6974 case 2:
6975 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
6976 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6977 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6978 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
6979 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
6980 }
6981 }
6982 break;
6983 case 3:
6984 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
6985 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6986 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6987 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
6988 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
6989 }
6990 }
6991 break;
6992 case 4:
6993 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
6994 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6995 __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])))
6996 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
6997 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
6998 }
6999 }
7000 break;
7001 }
7002 #endif
7003 #if CYTHON_COMPILING_IN_CPYTHON
7004 if (unlikely(Py_SIZE(x) < 0)) {
7005 goto raise_neg_overflow;
7006 }
7007 #else
7008 {
7009 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7010 if (unlikely(result < 0))
7011 return (int) -1;
7012 if (unlikely(result == 1))
7013 goto raise_neg_overflow;
7014 }
7015 #endif
7016 if (sizeof(int) <= sizeof(unsigned long)) {
7017 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
7018 #ifdef HAVE_LONG_LONG
7019 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
7020 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7021 #endif
7022 }
7023 } else {
7024 #if CYTHON_USE_PYLONG_INTERNALS
7025 const digit* digits = ((PyLongObject*)x)->ob_digit;
7026 switch (Py_SIZE(x)) {
7027 case 0: return (int) 0;
7028 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
7029 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
7030 case -2:
7031 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
7032 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7033 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7034 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7035 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7036 }
7037 }
7038 break;
7039 case 2:
7040 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7041 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7042 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7043 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7044 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7045 }
7046 }
7047 break;
7048 case -3:
7049 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7050 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7051 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7052 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7053 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7054 }
7055 }
7056 break;
7057 case 3:
7058 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7059 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7060 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7061 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7062 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7063 }
7064 }
7065 break;
7066 case -4:
7067 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7068 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7069 __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])))
7070 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7071 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7072 }
7073 }
7074 break;
7075 case 4:
7076 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7077 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7078 __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])))
7079 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7080 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7081 }
7082 }
7083 break;
7084 }
7085 #endif
7086 if (sizeof(int) <= sizeof(long)) {
7087 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
7088 #ifdef HAVE_LONG_LONG
7089 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
7090 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
7091 #endif
7092 }
7093 }
7094 {
7095 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7096 PyErr_SetString(PyExc_RuntimeError,
7097 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7098 #else
7099 int val;
7100 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7101 #if PY_MAJOR_VERSION < 3
7102 if (likely(v) && !PyLong_Check(v)) {
7103 PyObject *tmp = v;
7104 v = PyNumber_Long(tmp);
7105 Py_DECREF(tmp);
7106 }
7107 #endif
7108 if (likely(v)) {
7109 int one = 1; int is_little = (int)*(unsigned char *)&one;
7110 unsigned char *bytes = (unsigned char *)&val;
7111 int ret = _PyLong_AsByteArray((PyLongObject *)v,
7112 bytes, sizeof(val),
7113 is_little, !is_unsigned);
7114 Py_DECREF(v);
7115 if (likely(!ret))
7116 return val;
7117 }
7118 #endif
7119 return (int) -1;
7120 }
7121 } else {
7122 int val;
7123 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7124 if (!tmp) return (int) -1;
7125 val = __Pyx_PyInt_As_int(tmp);
7126 Py_DECREF(tmp);
7127 return val;
7128 }
7129 raise_overflow:
7130 PyErr_SetString(PyExc_OverflowError,
7131 "value too large to convert to int");
7132 return (int) -1;
7133 raise_neg_overflow:
7134 PyErr_SetString(PyExc_OverflowError,
7135 "can't convert negative value to int");
7136 return (int) -1;
7137 }
7138
7139 /* FastTypeChecks */
7140 #if CYTHON_COMPILING_IN_CPYTHON
7141 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
7142 while (a) {
7143 a = a->tp_base;
7144 if (a == b)
7145 return 1;
7146 }
7147 return b == &PyBaseObject_Type;
7148 }
7149 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
7150 PyObject *mro;
7151 if (a == b) return 1;
7152 mro = a->tp_mro;
7153 if (likely(mro)) {
7154 Py_ssize_t i, n;
7155 n = PyTuple_GET_SIZE(mro);
7156 for (i = 0; i < n; i++) {
7157 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
7158 return 1;
7159 }
7160 return 0;
7161 }
7162 return __Pyx_InBases(a, b);
7163 }
7164 #if PY_MAJOR_VERSION == 2
7165 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
7166 PyObject *exception, *value, *tb;
7167 int res;
7168 __Pyx_PyThreadState_declare
7169 __Pyx_PyThreadState_assign
7170 __Pyx_ErrFetch(&exception, &value, &tb);
7171 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
7172 if (unlikely(res == -1)) {
7173 PyErr_WriteUnraisable(err);
7174 res = 0;
7175 }
7176 if (!res) {
7177 res = PyObject_IsSubclass(err, exc_type2);
7178 if (unlikely(res == -1)) {
7179 PyErr_WriteUnraisable(err);
7180 res = 0;
7181 }
7182 }
7183 __Pyx_ErrRestore(exception, value, tb);
7184 return res;
7185 }
7186 #else
7187 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
7188 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
7189 if (!res) {
7190 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
7191 }
7192 return res;
7193 }
7194 #endif
7195 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
7196 Py_ssize_t i, n;
7197 assert(PyExceptionClass_Check(exc_type));
7198 n = PyTuple_GET_SIZE(tuple);
7199 #if PY_MAJOR_VERSION >= 3
7200 for (i=0; i<n; i++) {
7201 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
7202 }
7203 #endif
7204 for (i=0; i<n; i++) {
7205 PyObject *t = PyTuple_GET_ITEM(tuple, i);
7206 #if PY_MAJOR_VERSION < 3
7207 if (likely(exc_type == t)) return 1;
7208 #endif
7209 if (likely(PyExceptionClass_Check(t))) {
7210 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
7211 } else {
7212 }
7213 }
7214 return 0;
7215 }
7216 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
7217 if (likely(err == exc_type)) return 1;
7218 if (likely(PyExceptionClass_Check(err))) {
7219 if (likely(PyExceptionClass_Check(exc_type))) {
7220 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
7221 } else if (likely(PyTuple_Check(exc_type))) {
7222 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
7223 } else {
7224 }
7225 }
7226 return PyErr_GivenExceptionMatches(err, exc_type);
7227 }
7228 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
7229 assert(PyExceptionClass_Check(exc_type1));
7230 assert(PyExceptionClass_Check(exc_type2));
7231 if (likely(err == exc_type1 || err == exc_type2)) return 1;
7232 if (likely(PyExceptionClass_Check(err))) {
7233 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
7234 }
7235 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
7236 }
7237 #endif
7238
7239 /* AsyncGeneratorInitFinalizer */
7240 #if PY_VERSION_HEX < 0x030600B0
7241 static int __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o) {
7242 #if 0
7243 PyThreadState *tstate;
7244 PyObject *finalizer;
7245 PyObject *firstiter;
7246 #endif
7247 if (likely(o->ag_hooks_inited)) {
7248 return 0;
7249 }
7250 o->ag_hooks_inited = 1;
7251 #if 0
7252 tstate = __Pyx_PyThreadState_Current;
7253 finalizer = tstate->async_gen_finalizer;
7254 if (finalizer) {
7255 Py_INCREF(finalizer);
7256 o->ag_finalizer = finalizer;
7257 }
7258 firstiter = tstate->async_gen_firstiter;
7259 if (firstiter) {
7260 PyObject *res;
7261 Py_INCREF(firstiter);
7262 res = __Pyx_PyObject_CallOneArg(firstiter, (PyObject*)o);
7263 Py_DECREF(firstiter);
7264 if (res == NULL) {
7265 return 1;
7266 }
7267 Py_DECREF(res);
7268 }
7269 #endif
7270 return 0;
7271 }
7272 #endif
7273
7274 /* AsyncGenerator */
7275 PyDoc_STRVAR(__Pyx_async_gen_send_doc,
7276 "send(arg) -> send 'arg' into generator,\n\
7277 return next yielded value or raise StopIteration.");
7278 PyDoc_STRVAR(__Pyx_async_gen_close_doc,
7279 "close() -> raise GeneratorExit inside generator.");
7280 PyDoc_STRVAR(__Pyx_async_gen_throw_doc,
7281 "throw(typ[,val[,tb]]) -> raise exception in generator,\n\
7282 return next yielded value or raise StopIteration.");
7283 PyDoc_STRVAR(__Pyx_async_gen_await_doc,
7284 "__await__() -> return a representation that can be passed into the 'await' expression.");
7285 static PyObject *__Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *, PyObject *);
7286 static PyObject *__Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *, PyObject *);
7287 static const char *__Pyx_NON_INIT_CORO_MSG = "can't send non-None value to a just-started coroutine";
7288 static const char *__Pyx_ASYNC_GEN_IGNORED_EXIT_MSG = "async generator ignored GeneratorExit";
7289 typedef enum {
7290 __PYX_AWAITABLE_STATE_INIT,
7291 __PYX_AWAITABLE_STATE_ITER,
7292 __PYX_AWAITABLE_STATE_CLOSED,
7293 } __pyx_AwaitableState;
7294 typedef struct {
7295 PyObject_HEAD
7296 __pyx_PyAsyncGenObject *ags_gen;
7297 PyObject *ags_sendval;
7298 __pyx_AwaitableState ags_state;
7299 } __pyx_PyAsyncGenASend;
7300 typedef struct {
7301 PyObject_HEAD
7302 __pyx_PyAsyncGenObject *agt_gen;
7303 PyObject *agt_args;
7304 __pyx_AwaitableState agt_state;
7305 } __pyx_PyAsyncGenAThrow;
7306 typedef struct {
7307 PyObject_HEAD
7308 PyObject *agw_val;
7309 } __pyx__PyAsyncGenWrappedValue;
7310 #ifndef _PyAsyncGen_MAXFREELIST
7311 #define _PyAsyncGen_MAXFREELIST 80
7312 #endif
7313 static __pyx__PyAsyncGenWrappedValue *__Pyx_ag_value_freelist[_PyAsyncGen_MAXFREELIST];
7314 static int __Pyx_ag_value_freelist_free = 0;
7315 static __pyx_PyAsyncGenASend *__Pyx_ag_asend_freelist[_PyAsyncGen_MAXFREELIST];
7316 static int __Pyx_ag_asend_freelist_free = 0;
7317 #define __pyx__PyAsyncGenWrappedValue_CheckExact(o)\
7318 (Py_TYPE(o) == __pyx__PyAsyncGenWrappedValueType)
7319 static int
7320 __Pyx_async_gen_traverse(__pyx_PyAsyncGenObject *gen, visitproc visit, void *arg)
7321 {
7322 Py_VISIT(gen->ag_finalizer);
7323 return __Pyx_Coroutine_traverse((__pyx_CoroutineObject*)gen, visit, arg);
7324 }
7325 static PyObject *
7326 __Pyx_async_gen_repr(__pyx_CoroutineObject *o)
7327 {
7328 return PyUnicode_FromFormat("<async_generator object %S at %p>",
7329 o->gi_qualname ? o->gi_qualname : Py_None, o);
7330 }
7331 #if PY_VERSION_HEX >= 0x030600B0
7332
7333 extern PyObject* _PyEval_GetAsyncGenFirstiter(void);
7334 extern PyObject* _PyEval_GetAsyncGenFinalizer(void);
7335
7336 static int
7337 __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o)
7338 {
7339 PyThreadState *tstate;
7340 PyObject *finalizer;
7341 PyObject *firstiter;
7342 if (o->ag_hooks_inited) {
7343 return 0;
7344 }
7345 o->ag_hooks_inited = 1;
7346 tstate = __Pyx_PyThreadState_Current;
7347 finalizer = _PyEval_GetAsyncGenFinalizer();
7348 if (finalizer) {
7349 Py_INCREF(finalizer);
7350 o->ag_finalizer = finalizer;
7351 }
7352 firstiter = _PyEval_GetAsyncGenFirstiter();
7353 if (firstiter) {
7354 PyObject *res;
7355 #if CYTHON_UNPACK_METHODS
7356 PyObject *self;
7357 #endif
7358 Py_INCREF(firstiter);
7359 #if CYTHON_UNPACK_METHODS
7360 if (likely(PyMethod_Check(firstiter)) && likely((self = PyMethod_GET_SELF(firstiter)) != NULL)) {
7361 PyObject *function = PyMethod_GET_FUNCTION(firstiter);
7362 res = __Pyx_PyObject_Call2Args(function, self, (PyObject*)o);
7363 } else
7364 #endif
7365 res = __Pyx_PyObject_CallOneArg(firstiter, (PyObject*)o);
7366 Py_DECREF(firstiter);
7367 if (unlikely(res == NULL)) {
7368 return 1;
7369 }
7370 Py_DECREF(res);
7371 }
7372 return 0;
7373 }
7374 #endif
7375 static PyObject *
7376 __Pyx_async_gen_anext(PyObject *g)
7377 {
7378 __pyx_PyAsyncGenObject *o = (__pyx_PyAsyncGenObject*) g;
7379 if (__Pyx_async_gen_init_hooks(o)) {
7380 return NULL;
7381 }
7382 return __Pyx_async_gen_asend_new(o, NULL);
7383 }
7384 static PyObject *
7385 __Pyx_async_gen_anext_method(PyObject *g, CYTHON_UNUSED PyObject *arg) {
7386 return __Pyx_async_gen_anext(g);
7387 }
7388 static PyObject *
7389 __Pyx_async_gen_asend(__pyx_PyAsyncGenObject *o, PyObject *arg)
7390 {
7391 if (__Pyx_async_gen_init_hooks(o)) {
7392 return NULL;
7393 }
7394 return __Pyx_async_gen_asend_new(o, arg);
7395 }
7396 static PyObject *
7397 __Pyx_async_gen_aclose(__pyx_PyAsyncGenObject *o, CYTHON_UNUSED PyObject *arg)
7398 {
7399 if (__Pyx_async_gen_init_hooks(o)) {
7400 return NULL;
7401 }
7402 return __Pyx_async_gen_athrow_new(o, NULL);
7403 }
7404 static PyObject *
7405 __Pyx_async_gen_athrow(__pyx_PyAsyncGenObject *o, PyObject *args)
7406 {
7407 if (__Pyx_async_gen_init_hooks(o)) {
7408 return NULL;
7409 }
7410 return __Pyx_async_gen_athrow_new(o, args);
7411 }
7412 static PyObject *
7413 __Pyx_async_gen_self_method(PyObject *g, CYTHON_UNUSED PyObject *arg) {
7414 return __Pyx_NewRef(g);
7415 }
7416 static PyGetSetDef __Pyx_async_gen_getsetlist[] = {
7417 {(char*) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
7418 (char*) PyDoc_STR("name of the async generator"), 0},
7419 {(char*) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
7420 (char*) PyDoc_STR("qualified name of the async generator"), 0},
7421 {0, 0, 0, 0, 0}
7422 };
7423 static PyMemberDef __Pyx_async_gen_memberlist[] = {
7424 {(char*) "ag_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
7425 {(char*) "ag_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
7426 (char*) PyDoc_STR("object being awaited on, or None")},
7427 {0, 0, 0, 0, 0}
7428 };
7429 PyDoc_STRVAR(__Pyx_async_aclose_doc,
7430 "aclose() -> raise GeneratorExit inside generator.");
7431 PyDoc_STRVAR(__Pyx_async_asend_doc,
7432 "asend(v) -> send 'v' in generator.");
7433 PyDoc_STRVAR(__Pyx_async_athrow_doc,
7434 "athrow(typ[,val[,tb]]) -> raise exception in generator.");
7435 PyDoc_STRVAR(__Pyx_async_aiter_doc,
7436 "__aiter__(v) -> return an asynchronous iterator.");
7437 PyDoc_STRVAR(__Pyx_async_anext_doc,
7438 "__anext__(v) -> continue asynchronous iteration and return the next element.");
7439 static PyMethodDef __Pyx_async_gen_methods[] = {
7440 {"asend", (PyCFunction)__Pyx_async_gen_asend, METH_O, __Pyx_async_asend_doc},
7441 {"athrow",(PyCFunction)__Pyx_async_gen_athrow, METH_VARARGS, __Pyx_async_athrow_doc},
7442 {"aclose", (PyCFunction)__Pyx_async_gen_aclose, METH_NOARGS, __Pyx_async_aclose_doc},
7443 {"__aiter__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_aiter_doc},
7444 {"__anext__", (PyCFunction)__Pyx_async_gen_anext_method, METH_NOARGS, __Pyx_async_anext_doc},
7445 {0, 0, 0, 0}
7446 };
7447 #if CYTHON_USE_ASYNC_SLOTS
7448 static __Pyx_PyAsyncMethodsStruct __Pyx_async_gen_as_async = {
7449 0,
7450 PyObject_SelfIter,
7451 (unaryfunc)__Pyx_async_gen_anext,
7452 #if PY_VERSION_HEX >= 0x030A00A3
7453 0,
7454 #endif
7455 };
7456 #endif
7457 static PyTypeObject __pyx_AsyncGenType_type = {
7458 PyVarObject_HEAD_INIT(0, 0)
7459 "async_generator",
7460 sizeof(__pyx_PyAsyncGenObject),
7461 0,
7462 (destructor)__Pyx_Coroutine_dealloc,
7463 0,
7464 0,
7465 0,
7466 #if CYTHON_USE_ASYNC_SLOTS
7467 &__Pyx_async_gen_as_async,
7468 #else
7469 0,
7470 #endif
7471 (reprfunc)__Pyx_async_gen_repr,
7472 0,
7473 0,
7474 0,
7475 0,
7476 0,
7477 0,
7478 0,
7479 0,
7480 0,
7481 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
7482 Py_TPFLAGS_HAVE_FINALIZE,
7483 0,
7484 (traverseproc)__Pyx_async_gen_traverse,
7485 0,
7486 #if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
7487 __Pyx_Coroutine_compare,
7488 #else
7489 0,
7490 #endif
7491 offsetof(__pyx_CoroutineObject, gi_weakreflist),
7492 0,
7493 0,
7494 __Pyx_async_gen_methods,
7495 __Pyx_async_gen_memberlist,
7496 __Pyx_async_gen_getsetlist,
7497 0,
7498 0,
7499 0,
7500 0,
7501 0,
7502 0,
7503 0,
7504 0,
7505 0,
7506 0,
7507 0,
7508 0,
7509 0,
7510 0,
7511 0,
7512 #if CYTHON_USE_TP_FINALIZE
7513 0,
7514 #else
7515 __Pyx_Coroutine_del,
7516 #endif
7517 0,
7518 #if CYTHON_USE_TP_FINALIZE
7519 __Pyx_Coroutine_del,
7520 #elif PY_VERSION_HEX >= 0x030400a1
7521 0,
7522 #endif
7523 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
7524 0,
7525 #endif
7526 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
7527 0,
7528 #endif
7529 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
7530 0,
7531 #endif
7532 };
7533 static int
7534 __Pyx_PyAsyncGen_ClearFreeLists(void)
7535 {
7536 int ret = __Pyx_ag_value_freelist_free + __Pyx_ag_asend_freelist_free;
7537 while (__Pyx_ag_value_freelist_free) {
7538 __pyx__PyAsyncGenWrappedValue *o;
7539 o = __Pyx_ag_value_freelist[--__Pyx_ag_value_freelist_free];
7540 assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o));
7541 PyObject_GC_Del(o);
7542 }
7543 while (__Pyx_ag_asend_freelist_free) {
7544 __pyx_PyAsyncGenASend *o;
7545 o = __Pyx_ag_asend_freelist[--__Pyx_ag_asend_freelist_free];
7546 assert(Py_TYPE(o) == __pyx__PyAsyncGenASendType);
7547 PyObject_GC_Del(o);
7548 }
7549 return ret;
7550 }
7551 static void
7552 __Pyx_PyAsyncGen_Fini(void)
7553 {
7554 __Pyx_PyAsyncGen_ClearFreeLists();
7555 }
7556 static PyObject *
7557 __Pyx_async_gen_unwrap_value(__pyx_PyAsyncGenObject *gen, PyObject *result)
7558 {
7559 if (result == NULL) {
7560 PyObject *exc_type = PyErr_Occurred();
7561 if (!exc_type) {
7562 PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
7563 gen->ag_closed = 1;
7564 } else if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, __Pyx_PyExc_StopAsyncIteration, PyExc_GeneratorExit)) {
7565 gen->ag_closed = 1;
7566 }
7567 return NULL;
7568 }
7569 if (__pyx__PyAsyncGenWrappedValue_CheckExact(result)) {
7570 __Pyx_ReturnWithStopIteration(((__pyx__PyAsyncGenWrappedValue*)result)->agw_val);
7571 Py_DECREF(result);
7572 return NULL;
7573 }
7574 return result;
7575 }
7576 static void
7577 __Pyx_async_gen_asend_dealloc(__pyx_PyAsyncGenASend *o)
7578 {
7579 PyObject_GC_UnTrack((PyObject *)o);
7580 Py_CLEAR(o->ags_gen);
7581 Py_CLEAR(o->ags_sendval);
7582 if (__Pyx_ag_asend_freelist_free < _PyAsyncGen_MAXFREELIST) {
7583 assert(__pyx_PyAsyncGenASend_CheckExact(o));
7584 __Pyx_ag_asend_freelist[__Pyx_ag_asend_freelist_free++] = o;
7585 } else {
7586 PyObject_GC_Del(o);
7587 }
7588 }
7589 static int
7590 __Pyx_async_gen_asend_traverse(__pyx_PyAsyncGenASend *o, visitproc visit, void *arg)
7591 {
7592 Py_VISIT(o->ags_gen);
7593 Py_VISIT(o->ags_sendval);
7594 return 0;
7595 }
7596 static PyObject *
7597 __Pyx_async_gen_asend_send(PyObject *g, PyObject *arg)
7598 {
7599 __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g;
7600 PyObject *result;
7601 if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) {
7602 PyErr_SetNone(PyExc_StopIteration);
7603 return NULL;
7604 }
7605 if (o->ags_state == __PYX_AWAITABLE_STATE_INIT) {
7606 if (arg == NULL || arg == Py_None) {
7607 arg = o->ags_sendval ? o->ags_sendval : Py_None;
7608 }
7609 o->ags_state = __PYX_AWAITABLE_STATE_ITER;
7610 }
7611 result = __Pyx_Coroutine_Send((PyObject*)o->ags_gen, arg);
7612 result = __Pyx_async_gen_unwrap_value(o->ags_gen, result);
7613 if (result == NULL) {
7614 o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
7615 }
7616 return result;
7617 }
7618 static CYTHON_INLINE PyObject *
7619 __Pyx_async_gen_asend_iternext(PyObject *o)
7620 {
7621 return __Pyx_async_gen_asend_send(o, Py_None);
7622 }
7623 static PyObject *
7624 __Pyx_async_gen_asend_throw(__pyx_PyAsyncGenASend *o, PyObject *args)
7625 {
7626 PyObject *result;
7627 if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) {
7628 PyErr_SetNone(PyExc_StopIteration);
7629 return NULL;
7630 }
7631 result = __Pyx_Coroutine_Throw((PyObject*)o->ags_gen, args);
7632 result = __Pyx_async_gen_unwrap_value(o->ags_gen, result);
7633 if (result == NULL) {
7634 o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
7635 }
7636 return result;
7637 }
7638 static PyObject *
7639 __Pyx_async_gen_asend_close(PyObject *g, CYTHON_UNUSED PyObject *args)
7640 {
7641 __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g;
7642 o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
7643 Py_RETURN_NONE;
7644 }
7645 static PyMethodDef __Pyx_async_gen_asend_methods[] = {
7646 {"send", (PyCFunction)__Pyx_async_gen_asend_send, METH_O, __Pyx_async_gen_send_doc},
7647 {"throw", (PyCFunction)__Pyx_async_gen_asend_throw, METH_VARARGS, __Pyx_async_gen_throw_doc},
7648 {"close", (PyCFunction)__Pyx_async_gen_asend_close, METH_NOARGS, __Pyx_async_gen_close_doc},
7649 {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc},
7650 {0, 0, 0, 0}
7651 };
7652 #if CYTHON_USE_ASYNC_SLOTS
7653 static __Pyx_PyAsyncMethodsStruct __Pyx_async_gen_asend_as_async = {
7654 PyObject_SelfIter,
7655 0,
7656 0,
7657 #if PY_VERSION_HEX >= 0x030A00A3
7658 0,
7659 #endif
7660 };
7661 #endif
7662 static PyTypeObject __pyx__PyAsyncGenASendType_type = {
7663 PyVarObject_HEAD_INIT(0, 0)
7664 "async_generator_asend",
7665 sizeof(__pyx_PyAsyncGenASend),
7666 0,
7667 (destructor)__Pyx_async_gen_asend_dealloc,
7668 0,
7669 0,
7670 0,
7671 #if CYTHON_USE_ASYNC_SLOTS
7672 &__Pyx_async_gen_asend_as_async,
7673 #else
7674 0,
7675 #endif
7676 0,
7677 0,
7678 0,
7679 0,
7680 0,
7681 0,
7682 0,
7683 0,
7684 0,
7685 0,
7686 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
7687 0,
7688 (traverseproc)__Pyx_async_gen_asend_traverse,
7689 0,
7690 #if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
7691 __Pyx_Coroutine_compare,
7692 #else
7693 0,
7694 #endif
7695 0,
7696 PyObject_SelfIter,
7697 (iternextfunc)__Pyx_async_gen_asend_iternext,
7698 __Pyx_async_gen_asend_methods,
7699 0,
7700 0,
7701 0,
7702 0,
7703 0,
7704 0,
7705 0,
7706 0,
7707 0,
7708 0,
7709 0,
7710 0,
7711 0,
7712 0,
7713 0,
7714 0,
7715 0,
7716 0,
7717 0,
7718 #if PY_VERSION_HEX >= 0x030400a1
7719 0,
7720 #endif
7721 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
7722 0,
7723 #endif
7724 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
7725 0,
7726 #endif
7727 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
7728 0,
7729 #endif
7730 };
7731 static PyObject *
7732 __Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *gen, PyObject *sendval)
7733 {
7734 __pyx_PyAsyncGenASend *o;
7735 if (__Pyx_ag_asend_freelist_free) {
7736 __Pyx_ag_asend_freelist_free--;
7737 o = __Pyx_ag_asend_freelist[__Pyx_ag_asend_freelist_free];
7738 _Py_NewReference((PyObject *)o);
7739 } else {
7740 o = PyObject_GC_New(__pyx_PyAsyncGenASend, __pyx__PyAsyncGenASendType);
7741 if (o == NULL) {
7742 return NULL;
7743 }
7744 }
7745 Py_INCREF(gen);
7746 o->ags_gen = gen;
7747 Py_XINCREF(sendval);
7748 o->ags_sendval = sendval;
7749 o->ags_state = __PYX_AWAITABLE_STATE_INIT;
7750 PyObject_GC_Track((PyObject*)o);
7751 return (PyObject*)o;
7752 }
7753 static void
7754 __Pyx_async_gen_wrapped_val_dealloc(__pyx__PyAsyncGenWrappedValue *o)
7755 {
7756 PyObject_GC_UnTrack((PyObject *)o);
7757 Py_CLEAR(o->agw_val);
7758 if (__Pyx_ag_value_freelist_free < _PyAsyncGen_MAXFREELIST) {
7759 assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o));
7760 __Pyx_ag_value_freelist[__Pyx_ag_value_freelist_free++] = o;
7761 } else {
7762 PyObject_GC_Del(o);
7763 }
7764 }
7765 static int
7766 __Pyx_async_gen_wrapped_val_traverse(__pyx__PyAsyncGenWrappedValue *o,
7767 visitproc visit, void *arg)
7768 {
7769 Py_VISIT(o->agw_val);
7770 return 0;
7771 }
7772 static PyTypeObject __pyx__PyAsyncGenWrappedValueType_type = {
7773 PyVarObject_HEAD_INIT(0, 0)
7774 "async_generator_wrapped_value",
7775 sizeof(__pyx__PyAsyncGenWrappedValue),
7776 0,
7777 (destructor)__Pyx_async_gen_wrapped_val_dealloc,
7778 0,
7779 0,
7780 0,
7781 0,
7782 0,
7783 0,
7784 0,
7785 0,
7786 0,
7787 0,
7788 0,
7789 0,
7790 0,
7791 0,
7792 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
7793 0,
7794 (traverseproc)__Pyx_async_gen_wrapped_val_traverse,
7795 0,
7796 0,
7797 0,
7798 0,
7799 0,
7800 0,
7801 0,
7802 0,
7803 0,
7804 0,
7805 0,
7806 0,
7807 0,
7808 0,
7809 0,
7810 0,
7811 0,
7812 0,
7813 0,
7814 0,
7815 0,
7816 0,
7817 0,
7818 0,
7819 0,
7820 #if PY_VERSION_HEX >= 0x030400a1
7821 0,
7822 #endif
7823 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
7824 0,
7825 #endif
7826 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
7827 0,
7828 #endif
7829 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
7830 0,
7831 #endif
7832 };
7833 static PyObject *
7834 __Pyx__PyAsyncGenValueWrapperNew(PyObject *val)
7835 {
7836 __pyx__PyAsyncGenWrappedValue *o;
7837 assert(val);
7838 if (__Pyx_ag_value_freelist_free) {
7839 __Pyx_ag_value_freelist_free--;
7840 o = __Pyx_ag_value_freelist[__Pyx_ag_value_freelist_free];
7841 assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o));
7842 _Py_NewReference((PyObject*)o);
7843 } else {
7844 o = PyObject_GC_New(__pyx__PyAsyncGenWrappedValue, __pyx__PyAsyncGenWrappedValueType);
7845 if (unlikely(!o)) {
7846 Py_DECREF(val);
7847 return NULL;
7848 }
7849 }
7850 o->agw_val = val;
7851 PyObject_GC_Track((PyObject*)o);
7852 return (PyObject*)o;
7853 }
7854 static void
7855 __Pyx_async_gen_athrow_dealloc(__pyx_PyAsyncGenAThrow *o)
7856 {
7857 PyObject_GC_UnTrack((PyObject *)o);
7858 Py_CLEAR(o->agt_gen);
7859 Py_CLEAR(o->agt_args);
7860 PyObject_GC_Del(o);
7861 }
7862 static int
7863 __Pyx_async_gen_athrow_traverse(__pyx_PyAsyncGenAThrow *o, visitproc visit, void *arg)
7864 {
7865 Py_VISIT(o->agt_gen);
7866 Py_VISIT(o->agt_args);
7867 return 0;
7868 }
7869 static PyObject *
7870 __Pyx_async_gen_athrow_send(__pyx_PyAsyncGenAThrow *o, PyObject *arg)
7871 {
7872 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*)o->agt_gen;
7873 PyObject *retval;
7874 if (o->agt_state == __PYX_AWAITABLE_STATE_CLOSED) {
7875 PyErr_SetNone(PyExc_StopIteration);
7876 return NULL;
7877 }
7878 if (o->agt_state == __PYX_AWAITABLE_STATE_INIT) {
7879 if (o->agt_gen->ag_closed) {
7880 PyErr_SetNone(PyExc_StopIteration);
7881 return NULL;
7882 }
7883 if (arg != Py_None) {
7884 PyErr_SetString(PyExc_RuntimeError, __Pyx_NON_INIT_CORO_MSG);
7885 return NULL;
7886 }
7887 o->agt_state = __PYX_AWAITABLE_STATE_ITER;
7888 if (o->agt_args == NULL) {
7889 o->agt_gen->ag_closed = 1;
7890 retval = __Pyx__Coroutine_Throw((PyObject*)gen,
7891 /* Do not close generator when
7892 PyExc_GeneratorExit is passed */
7893 PyExc_GeneratorExit, NULL, NULL, NULL, 0);
7894 if (retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval)) {
7895 Py_DECREF(retval);
7896 goto yield_close;
7897 }
7898 } else {
7899 PyObject *typ;
7900 PyObject *tb = NULL;
7901 PyObject *val = NULL;
7902 if (!PyArg_UnpackTuple(o->agt_args, "athrow", 1, 3,
7903 &typ, &val, &tb)) {
7904 return NULL;
7905 }
7906 retval = __Pyx__Coroutine_Throw((PyObject*)gen,
7907 typ, val, tb, o->agt_args, 0);
7908 retval = __Pyx_async_gen_unwrap_value(o->agt_gen, retval);
7909 }
7910 if (retval == NULL) {
7911 goto check_error;
7912 }
7913 return retval;
7914 }
7915 assert (o->agt_state == __PYX_AWAITABLE_STATE_ITER);
7916 retval = __Pyx_Coroutine_Send((PyObject *)gen, arg);
7917 if (o->agt_args) {
7918 return __Pyx_async_gen_unwrap_value(o->agt_gen, retval);
7919 } else {
7920 if (retval) {
7921 if (__pyx__PyAsyncGenWrappedValue_CheckExact(retval)) {
7922 Py_DECREF(retval);
7923 goto yield_close;
7924 }
7925 else {
7926 return retval;
7927 }
7928 }
7929 else {
7930 goto check_error;
7931 }
7932 }
7933 yield_close:
7934 PyErr_SetString(
7935 PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG);
7936 return NULL;
7937 check_error:
7938 if (PyErr_ExceptionMatches(__Pyx_PyExc_StopAsyncIteration)) {
7939 o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
7940 if (o->agt_args == NULL) {
7941 PyErr_Clear();
7942 PyErr_SetNone(PyExc_StopIteration);
7943 }
7944 }
7945 else if (PyErr_ExceptionMatches(PyExc_GeneratorExit)) {
7946 o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
7947 PyErr_Clear();
7948 PyErr_SetNone(PyExc_StopIteration);
7949 }
7950 return NULL;
7951 }
7952 static PyObject *
7953 __Pyx_async_gen_athrow_throw(__pyx_PyAsyncGenAThrow *o, PyObject *args)
7954 {
7955 PyObject *retval;
7956 if (o->agt_state == __PYX_AWAITABLE_STATE_INIT) {
7957 PyErr_SetString(PyExc_RuntimeError, __Pyx_NON_INIT_CORO_MSG);
7958 return NULL;
7959 }
7960 if (o->agt_state == __PYX_AWAITABLE_STATE_CLOSED) {
7961 PyErr_SetNone(PyExc_StopIteration);
7962 return NULL;
7963 }
7964 retval = __Pyx_Coroutine_Throw((PyObject*)o->agt_gen, args);
7965 if (o->agt_args) {
7966 return __Pyx_async_gen_unwrap_value(o->agt_gen, retval);
7967 } else {
7968 if (retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval)) {
7969 Py_DECREF(retval);
7970 PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG);
7971 return NULL;
7972 }
7973 return retval;
7974 }
7975 }
7976 static PyObject *
7977 __Pyx_async_gen_athrow_iternext(__pyx_PyAsyncGenAThrow *o)
7978 {
7979 return __Pyx_async_gen_athrow_send(o, Py_None);
7980 }
7981 static PyObject *
7982 __Pyx_async_gen_athrow_close(PyObject *g, CYTHON_UNUSED PyObject *args)
7983 {
7984 __pyx_PyAsyncGenAThrow *o = (__pyx_PyAsyncGenAThrow*) g;
7985 o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
7986 Py_RETURN_NONE;
7987 }
7988 static PyMethodDef __Pyx_async_gen_athrow_methods[] = {
7989 {"send", (PyCFunction)__Pyx_async_gen_athrow_send, METH_O, __Pyx_async_gen_send_doc},
7990 {"throw", (PyCFunction)__Pyx_async_gen_athrow_throw, METH_VARARGS, __Pyx_async_gen_throw_doc},
7991 {"close", (PyCFunction)__Pyx_async_gen_athrow_close, METH_NOARGS, __Pyx_async_gen_close_doc},
7992 {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc},
7993 {0, 0, 0, 0}
7994 };
7995 #if CYTHON_USE_ASYNC_SLOTS
7996 static __Pyx_PyAsyncMethodsStruct __Pyx_async_gen_athrow_as_async = {
7997 PyObject_SelfIter,
7998 0,
7999 0,
8000 #if PY_VERSION_HEX >= 0x030A00A3
8001 0,
8002 #endif
8003 };
8004 #endif
8005 static PyTypeObject __pyx__PyAsyncGenAThrowType_type = {
8006 PyVarObject_HEAD_INIT(0, 0)
8007 "async_generator_athrow",
8008 sizeof(__pyx_PyAsyncGenAThrow),
8009 0,
8010 (destructor)__Pyx_async_gen_athrow_dealloc,
8011 0,
8012 0,
8013 0,
8014 #if CYTHON_USE_ASYNC_SLOTS
8015 &__Pyx_async_gen_athrow_as_async,
8016 #else
8017 0,
8018 #endif
8019 0,
8020 0,
8021 0,
8022 0,
8023 0,
8024 0,
8025 0,
8026 0,
8027 0,
8028 0,
8029 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
8030 0,
8031 (traverseproc)__Pyx_async_gen_athrow_traverse,
8032 0,
8033 #if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
8034 __Pyx_Coroutine_compare,
8035 #else
8036 0,
8037 #endif
8038 0,
8039 PyObject_SelfIter,
8040 (iternextfunc)__Pyx_async_gen_athrow_iternext,
8041 __Pyx_async_gen_athrow_methods,
8042 0,
8043 0,
8044 0,
8045 0,
8046 0,
8047 0,
8048 0,
8049 0,
8050 0,
8051 0,
8052 0,
8053 0,
8054 0,
8055 0,
8056 0,
8057 0,
8058 0,
8059 0,
8060 0,
8061 #if PY_VERSION_HEX >= 0x030400a1
8062 0,
8063 #endif
8064 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
8065 0,
8066 #endif
8067 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
8068 0,
8069 #endif
8070 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
8071 0,
8072 #endif
8073 };
8074 static PyObject *
8075 __Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *gen, PyObject *args)
8076 {
8077 __pyx_PyAsyncGenAThrow *o;
8078 o = PyObject_GC_New(__pyx_PyAsyncGenAThrow, __pyx__PyAsyncGenAThrowType);
8079 if (o == NULL) {
8080 return NULL;
8081 }
8082 o->agt_gen = gen;
8083 o->agt_args = args;
8084 o->agt_state = __PYX_AWAITABLE_STATE_INIT;
8085 Py_INCREF(gen);
8086 Py_XINCREF(args);
8087 PyObject_GC_Track((PyObject*)o);
8088 return (PyObject*)o;
8089 }
8090 static int __pyx_AsyncGen_init(void) {
8091 __pyx_AsyncGenType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
8092 __pyx__PyAsyncGenWrappedValueType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
8093 __pyx__PyAsyncGenAThrowType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
8094 __pyx__PyAsyncGenASendType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
8095 __pyx_AsyncGenType = __Pyx_FetchCommonType(&__pyx_AsyncGenType_type);
8096 if (unlikely(!__pyx_AsyncGenType))
8097 return -1;
8098 __pyx__PyAsyncGenAThrowType = __Pyx_FetchCommonType(&__pyx__PyAsyncGenAThrowType_type);
8099 if (unlikely(!__pyx__PyAsyncGenAThrowType))
8100 return -1;
8101 __pyx__PyAsyncGenWrappedValueType = __Pyx_FetchCommonType(&__pyx__PyAsyncGenWrappedValueType_type);
8102 if (unlikely(!__pyx__PyAsyncGenWrappedValueType))
8103 return -1;
8104 __pyx__PyAsyncGenASendType = __Pyx_FetchCommonType(&__pyx__PyAsyncGenASendType_type);
8105 if (unlikely(!__pyx__PyAsyncGenASendType))
8106 return -1;
8107 return 0;
8108 }
8109
8110 /* AsyncGen */
8111
8112
8113 /* CheckBinaryVersion */
8114 static int __Pyx_check_binary_version(void) {
8115 char ctversion[5];
8116 int same=1, i, found_dot;
8117 const char* rt_from_call = Py_GetVersion();
8118 PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
8119 found_dot = 0;
8120 for (i = 0; i < 4; i++) {
8121 if (!ctversion[i]) {
8122 same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
8123 break;
8124 }
8125 if (rt_from_call[i] != ctversion[i]) {
8126 same = 0;
8127 break;
8128 }
8129 }
8130 if (!same) {
8131 char rtversion[5] = {'\0'};
8132 char message[200];
8133 for (i=0; i<4; ++i) {
8134 if (rt_from_call[i] == '.') {
8135 if (found_dot) break;
8136 found_dot = 1;
8137 } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
8138 break;
8139 }
8140 rtversion[i] = rt_from_call[i];
8141 }
8142 PyOS_snprintf(message, sizeof(message),
8143 "compiletime version %s of module '%.100s' "
8144 "does not match runtime version %s",
8145 ctversion, __Pyx_MODULE_NAME, rtversion);
8146 return PyErr_WarnEx(NULL, message, 1);
8147 }
8148 return 0;
8149 }
8150
8151 /* InitStrings */
8152 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
8153 while (t->p) {
8154 #if PY_MAJOR_VERSION < 3
8155 if (t->is_unicode) {
8156 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
8157 } else if (t->intern) {
8158 *t->p = PyString_InternFromString(t->s);
8159 } else {
8160 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
8161 }
8162 #else
8163 if (t->is_unicode | t->is_str) {
8164 if (t->intern) {
8165 *t->p = PyUnicode_InternFromString(t->s);
8166 } else if (t->encoding) {
8167 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
8168 } else {
8169 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
8170 }
8171 } else {
8172 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
8173 }
8174 #endif
8175 if (!*t->p)
8176 return -1;
8177 if (PyObject_Hash(*t->p) == -1)
8178 return -1;
8179 ++t;
8180 }
8181 return 0;
8182 }
8183
8184 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
8185 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
8186 }
8187 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
8188 Py_ssize_t ignore;
8189 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
8190 }
8191 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
8192 #if !CYTHON_PEP393_ENABLED
8193 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
8194 char* defenc_c;
8195 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
8196 if (!defenc) return NULL;
8197 defenc_c = PyBytes_AS_STRING(defenc);
8198 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
8199 {
8200 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
8201 char* c;
8202 for (c = defenc_c; c < end; c++) {
8203 if ((unsigned char) (*c) >= 128) {
8204 PyUnicode_AsASCIIString(o);
8205 return NULL;
8206 }
8207 }
8208 }
8209 #endif
8210 *length = PyBytes_GET_SIZE(defenc);
8211 return defenc_c;
8212 }
8213 #else
8214 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
8215 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
8216 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
8217 if (likely(PyUnicode_IS_ASCII(o))) {
8218 *length = PyUnicode_GET_LENGTH(o);
8219 return PyUnicode_AsUTF8(o);
8220 } else {
8221 PyUnicode_AsASCIIString(o);
8222 return NULL;
8223 }
8224 #else
8225 return PyUnicode_AsUTF8AndSize(o, length);
8226 #endif
8227 }
8228 #endif
8229 #endif
8230 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
8231 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
8232 if (
8233 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
8234 __Pyx_sys_getdefaultencoding_not_ascii &&
8235 #endif
8236 PyUnicode_Check(o)) {
8237 return __Pyx_PyUnicode_AsStringAndSize(o, length);
8238 } else
8239 #endif
8240 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
8241 if (PyByteArray_Check(o)) {
8242 *length = PyByteArray_GET_SIZE(o);
8243 return PyByteArray_AS_STRING(o);
8244 } else
8245 #endif
8246 {
8247 char* result;
8248 int r = PyBytes_AsStringAndSize(o, &result, length);
8249 if (unlikely(r < 0)) {
8250 return NULL;
8251 } else {
8252 return result;
8253 }
8254 }
8255 }
8256 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
8257 int is_true = x == Py_True;
8258 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
8259 else return PyObject_IsTrue(x);
8260 }
8261 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
8262 int retval;
8263 if (unlikely(!x)) return -1;
8264 retval = __Pyx_PyObject_IsTrue(x);
8265 Py_DECREF(x);
8266 return retval;
8267 }
8268 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
8269 #if PY_MAJOR_VERSION >= 3
8270 if (PyLong_Check(result)) {
8271 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
8272 "__int__ returned non-int (type %.200s). "
8273 "The ability to return an instance of a strict subclass of int "
8274 "is deprecated, and may be removed in a future version of Python.",
8275 Py_TYPE(result)->tp_name)) {
8276 Py_DECREF(result);
8277 return NULL;
8278 }
8279 return result;
8280 }
8281 #endif
8282 PyErr_Format(PyExc_TypeError,
8283 "__%.4s__ returned non-%.4s (type %.200s)",
8284 type_name, type_name, Py_TYPE(result)->tp_name);
8285 Py_DECREF(result);
8286 return NULL;
8287 }
8288 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
8289 #if CYTHON_USE_TYPE_SLOTS
8290 PyNumberMethods *m;
8291 #endif
8292 const char *name = NULL;
8293 PyObject *res = NULL;
8294 #if PY_MAJOR_VERSION < 3
8295 if (likely(PyInt_Check(x) || PyLong_Check(x)))
8296 #else
8297 if (likely(PyLong_Check(x)))
8298 #endif
8299 return __Pyx_NewRef(x);
8300 #if CYTHON_USE_TYPE_SLOTS
8301 m = Py_TYPE(x)->tp_as_number;
8302 #if PY_MAJOR_VERSION < 3
8303 if (m && m->nb_int) {
8304 name = "int";
8305 res = m->nb_int(x);
8306 }
8307 else if (m && m->nb_long) {
8308 name = "long";
8309 res = m->nb_long(x);
8310 }
8311 #else
8312 if (likely(m && m->nb_int)) {
8313 name = "int";
8314 res = m->nb_int(x);
8315 }
8316 #endif
8317 #else
8318 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
8319 res = PyNumber_Int(x);
8320 }
8321 #endif
8322 if (likely(res)) {
8323 #if PY_MAJOR_VERSION < 3
8324 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
8325 #else
8326 if (unlikely(!PyLong_CheckExact(res))) {
8327 #endif
8328 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
8329 }
8330 }
8331 else if (!PyErr_Occurred()) {
8332 PyErr_SetString(PyExc_TypeError,
8333 "an integer is required");
8334 }
8335 return res;
8336 }
8337 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
8338 Py_ssize_t ival;
8339 PyObject *x;
8340 #if PY_MAJOR_VERSION < 3
8341 if (likely(PyInt_CheckExact(b))) {
8342 if (sizeof(Py_ssize_t) >= sizeof(long))
8343 return PyInt_AS_LONG(b);
8344 else
8345 return PyInt_AsSsize_t(b);
8346 }
8347 #endif
8348 if (likely(PyLong_CheckExact(b))) {
8349 #if CYTHON_USE_PYLONG_INTERNALS
8350 const digit* digits = ((PyLongObject*)b)->ob_digit;
8351 const Py_ssize_t size = Py_SIZE(b);
8352 if (likely(__Pyx_sst_abs(size) <= 1)) {
8353 ival = likely(size) ? digits[0] : 0;
8354 if (size == -1) ival = -ival;
8355 return ival;
8356 } else {
8357 switch (size) {
8358 case 2:
8359 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
8360 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8361 }
8362 break;
8363 case -2:
8364 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
8365 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8366 }
8367 break;
8368 case 3:
8369 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
8370 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8371 }
8372 break;
8373 case -3:
8374 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
8375 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8376 }
8377 break;
8378 case 4:
8379 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
8380 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]));
8381 }
8382 break;
8383 case -4:
8384 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
8385 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]));
8386 }
8387 break;
8388 }
8389 }
8390 #endif
8391 return PyLong_AsSsize_t(b);
8392 }
8393 x = PyNumber_Index(b);
8394 if (!x) return -1;
8395 ival = PyInt_AsSsize_t(x);
8396 Py_DECREF(x);
8397 return ival;
8398 }
8399 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
8400 if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
8401 return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
8402 #if PY_MAJOR_VERSION < 3
8403 } else if (likely(PyInt_CheckExact(o))) {
8404 return PyInt_AS_LONG(o);
8405 #endif
8406 } else {
8407 Py_ssize_t ival;
8408 PyObject *x;
8409 x = PyNumber_Index(o);
8410 if (!x) return -1;
8411 ival = PyInt_AsLong(x);
8412 Py_DECREF(x);
8413 return ival;
8414 }
8415 }
8416 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
8417 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
8418 }
8419 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
8420 return PyInt_FromSize_t(ival);
8421 }
8422
8423
8424 #endif /* Py_PYTHON_H */