Cython 3.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +323 -0
  4. Cython/Build/Dependencies.py +1306 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +463 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/SharedModule.py +76 -0
  9. Cython/Build/Tests/TestCyCache.py +194 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  14. Cython/Build/Tests/TestRecythonize.py +212 -0
  15. Cython/Build/Tests/TestStripLiterals.py +155 -0
  16. Cython/Build/Tests/__init__.py +1 -0
  17. Cython/Build/__init__.py +8 -0
  18. Cython/CodeWriter.py +811 -0
  19. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  20. Cython/Compiler/Annotate.py +326 -0
  21. Cython/Compiler/AutoDocTransforms.py +320 -0
  22. Cython/Compiler/Buffer.py +680 -0
  23. Cython/Compiler/Builtin.py +934 -0
  24. Cython/Compiler/CmdLine.py +259 -0
  25. Cython/Compiler/Code.pxd +148 -0
  26. Cython/Compiler/Code.py +3375 -0
  27. Cython/Compiler/CodeGeneration.py +33 -0
  28. Cython/Compiler/CythonScope.py +187 -0
  29. Cython/Compiler/Dataclass.py +868 -0
  30. Cython/Compiler/DebugFlags.py +24 -0
  31. Cython/Compiler/Errors.py +295 -0
  32. Cython/Compiler/ExprNodes.py +15267 -0
  33. Cython/Compiler/FlowControl.pxd +97 -0
  34. Cython/Compiler/FlowControl.py +1455 -0
  35. Cython/Compiler/FusedNode.py +1002 -0
  36. Cython/Compiler/Future.py +16 -0
  37. Cython/Compiler/Interpreter.py +57 -0
  38. Cython/Compiler/Lexicon.py +340 -0
  39. Cython/Compiler/LineTable.py +114 -0
  40. Cython/Compiler/Main.py +853 -0
  41. Cython/Compiler/MatchCaseNodes.py +259 -0
  42. Cython/Compiler/MemoryView.py +922 -0
  43. Cython/Compiler/ModuleNode.py +4024 -0
  44. Cython/Compiler/Naming.py +374 -0
  45. Cython/Compiler/Nodes.py +10826 -0
  46. Cython/Compiler/Optimize.py +5256 -0
  47. Cython/Compiler/Options.py +835 -0
  48. Cython/Compiler/ParseTreeTransforms.pxd +77 -0
  49. Cython/Compiler/ParseTreeTransforms.py +4509 -0
  50. Cython/Compiler/Parsing.pxd +9 -0
  51. Cython/Compiler/Parsing.py +4789 -0
  52. Cython/Compiler/Pipeline.py +439 -0
  53. Cython/Compiler/PyrexTypes.py +5762 -0
  54. Cython/Compiler/Pythran.py +232 -0
  55. Cython/Compiler/Scanning.pxd +40 -0
  56. Cython/Compiler/Scanning.py +577 -0
  57. Cython/Compiler/StringEncoding.py +347 -0
  58. Cython/Compiler/Symtab.py +3080 -0
  59. Cython/Compiler/Tests/TestBuffer.py +105 -0
  60. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  61. Cython/Compiler/Tests/TestCmdLine.py +586 -0
  62. Cython/Compiler/Tests/TestCode.py +86 -0
  63. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  64. Cython/Compiler/Tests/TestGrammar.py +202 -0
  65. Cython/Compiler/Tests/TestMemView.py +71 -0
  66. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  67. Cython/Compiler/Tests/TestScanning.py +134 -0
  68. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  69. Cython/Compiler/Tests/TestStringEncoding.py +33 -0
  70. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  71. Cython/Compiler/Tests/TestTreePath.py +103 -0
  72. Cython/Compiler/Tests/TestTypes.py +75 -0
  73. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  74. Cython/Compiler/Tests/TestVisitor.py +61 -0
  75. Cython/Compiler/Tests/Utils.py +36 -0
  76. Cython/Compiler/Tests/__init__.py +1 -0
  77. Cython/Compiler/TreeFragment.py +278 -0
  78. Cython/Compiler/TreePath.py +303 -0
  79. Cython/Compiler/TypeInference.py +584 -0
  80. Cython/Compiler/TypeSlots.py +1181 -0
  81. Cython/Compiler/UFuncs.py +311 -0
  82. Cython/Compiler/UtilNodes.py +389 -0
  83. Cython/Compiler/UtilityCode.py +344 -0
  84. Cython/Compiler/Version.py +8 -0
  85. Cython/Compiler/Visitor.pxd +53 -0
  86. Cython/Compiler/Visitor.py +861 -0
  87. Cython/Compiler/__init__.py +1 -0
  88. Cython/Coverage.py +448 -0
  89. Cython/Debugger/Cygdb.py +175 -0
  90. Cython/Debugger/DebugWriter.py +82 -0
  91. Cython/Debugger/Tests/TestLibCython.py +275 -0
  92. Cython/Debugger/Tests/__init__.py +1 -0
  93. Cython/Debugger/Tests/cfuncs.c +8 -0
  94. Cython/Debugger/Tests/codefile +49 -0
  95. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  96. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  97. Cython/Debugger/__init__.py +1 -0
  98. Cython/Debugger/libcython.py +1548 -0
  99. Cython/Debugger/libpython.py +2821 -0
  100. Cython/Debugging.py +20 -0
  101. Cython/Distutils/__init__.py +2 -0
  102. Cython/Distutils/build_ext.py +139 -0
  103. Cython/Distutils/extension.py +96 -0
  104. Cython/Distutils/old_build_ext.py +351 -0
  105. Cython/Includes/cpython/__init__.pxd +173 -0
  106. Cython/Includes/cpython/array.pxd +174 -0
  107. Cython/Includes/cpython/bool.pxd +37 -0
  108. Cython/Includes/cpython/buffer.pxd +112 -0
  109. Cython/Includes/cpython/bytearray.pxd +33 -0
  110. Cython/Includes/cpython/bytes.pxd +200 -0
  111. Cython/Includes/cpython/cellobject.pxd +35 -0
  112. Cython/Includes/cpython/ceval.pxd +8 -0
  113. Cython/Includes/cpython/codecs.pxd +121 -0
  114. Cython/Includes/cpython/complex.pxd +60 -0
  115. Cython/Includes/cpython/contextvars.pxd +145 -0
  116. Cython/Includes/cpython/conversion.pxd +36 -0
  117. Cython/Includes/cpython/datetime.pxd +395 -0
  118. Cython/Includes/cpython/descr.pxd +26 -0
  119. Cython/Includes/cpython/dict.pxd +187 -0
  120. Cython/Includes/cpython/exc.pxd +263 -0
  121. Cython/Includes/cpython/fileobject.pxd +57 -0
  122. Cython/Includes/cpython/float.pxd +47 -0
  123. Cython/Includes/cpython/function.pxd +65 -0
  124. Cython/Includes/cpython/genobject.pxd +25 -0
  125. Cython/Includes/cpython/getargs.pxd +12 -0
  126. Cython/Includes/cpython/instance.pxd +25 -0
  127. Cython/Includes/cpython/iterator.pxd +36 -0
  128. Cython/Includes/cpython/iterobject.pxd +24 -0
  129. Cython/Includes/cpython/list.pxd +92 -0
  130. Cython/Includes/cpython/long.pxd +149 -0
  131. Cython/Includes/cpython/longintrepr.pxd +14 -0
  132. Cython/Includes/cpython/mapping.pxd +63 -0
  133. Cython/Includes/cpython/marshal.pxd +66 -0
  134. Cython/Includes/cpython/mem.pxd +120 -0
  135. Cython/Includes/cpython/memoryview.pxd +50 -0
  136. Cython/Includes/cpython/method.pxd +49 -0
  137. Cython/Includes/cpython/module.pxd +208 -0
  138. Cython/Includes/cpython/number.pxd +258 -0
  139. Cython/Includes/cpython/object.pxd +433 -0
  140. Cython/Includes/cpython/pycapsule.pxd +143 -0
  141. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  142. Cython/Includes/cpython/pyport.pxd +8 -0
  143. Cython/Includes/cpython/pystate.pxd +95 -0
  144. Cython/Includes/cpython/pythread.pxd +53 -0
  145. Cython/Includes/cpython/ref.pxd +67 -0
  146. Cython/Includes/cpython/sequence.pxd +134 -0
  147. Cython/Includes/cpython/set.pxd +119 -0
  148. Cython/Includes/cpython/slice.pxd +70 -0
  149. Cython/Includes/cpython/time.pxd +129 -0
  150. Cython/Includes/cpython/tuple.pxd +72 -0
  151. Cython/Includes/cpython/type.pxd +53 -0
  152. Cython/Includes/cpython/unicode.pxd +639 -0
  153. Cython/Includes/cpython/version.pxd +32 -0
  154. Cython/Includes/cpython/weakref.pxd +78 -0
  155. Cython/Includes/libc/__init__.pxd +1 -0
  156. Cython/Includes/libc/complex.pxd +35 -0
  157. Cython/Includes/libc/errno.pxd +127 -0
  158. Cython/Includes/libc/float.pxd +43 -0
  159. Cython/Includes/libc/limits.pxd +28 -0
  160. Cython/Includes/libc/locale.pxd +46 -0
  161. Cython/Includes/libc/math.pxd +209 -0
  162. Cython/Includes/libc/setjmp.pxd +10 -0
  163. Cython/Includes/libc/signal.pxd +64 -0
  164. Cython/Includes/libc/stddef.pxd +9 -0
  165. Cython/Includes/libc/stdint.pxd +105 -0
  166. Cython/Includes/libc/stdio.pxd +80 -0
  167. Cython/Includes/libc/stdlib.pxd +72 -0
  168. Cython/Includes/libc/string.pxd +50 -0
  169. Cython/Includes/libc/threads.pxd +84 -0
  170. Cython/Includes/libc/time.pxd +51 -0
  171. Cython/Includes/libcpp/__init__.pxd +4 -0
  172. Cython/Includes/libcpp/algorithm.pxd +320 -0
  173. Cython/Includes/libcpp/any.pxd +16 -0
  174. Cython/Includes/libcpp/atomic.pxd +59 -0
  175. Cython/Includes/libcpp/barrier.pxd +22 -0
  176. Cython/Includes/libcpp/bit.pxd +29 -0
  177. Cython/Includes/libcpp/cast.pxd +12 -0
  178. Cython/Includes/libcpp/cmath.pxd +518 -0
  179. Cython/Includes/libcpp/complex.pxd +106 -0
  180. Cython/Includes/libcpp/deque.pxd +165 -0
  181. Cython/Includes/libcpp/exception.pxd +86 -0
  182. Cython/Includes/libcpp/execution.pxd +15 -0
  183. Cython/Includes/libcpp/forward_list.pxd +63 -0
  184. Cython/Includes/libcpp/functional.pxd +26 -0
  185. Cython/Includes/libcpp/future.pxd +103 -0
  186. Cython/Includes/libcpp/iterator.pxd +34 -0
  187. Cython/Includes/libcpp/latch.pxd +17 -0
  188. Cython/Includes/libcpp/limits.pxd +61 -0
  189. Cython/Includes/libcpp/list.pxd +117 -0
  190. Cython/Includes/libcpp/map.pxd +252 -0
  191. Cython/Includes/libcpp/memory.pxd +115 -0
  192. Cython/Includes/libcpp/mutex.pxd +130 -0
  193. Cython/Includes/libcpp/numbers.pxd +15 -0
  194. Cython/Includes/libcpp/numeric.pxd +131 -0
  195. Cython/Includes/libcpp/optional.pxd +34 -0
  196. Cython/Includes/libcpp/pair.pxd +1 -0
  197. Cython/Includes/libcpp/queue.pxd +25 -0
  198. Cython/Includes/libcpp/random.pxd +166 -0
  199. Cython/Includes/libcpp/semaphore.pxd +44 -0
  200. Cython/Includes/libcpp/set.pxd +228 -0
  201. Cython/Includes/libcpp/shared_mutex.pxd +72 -0
  202. Cython/Includes/libcpp/span.pxd +87 -0
  203. Cython/Includes/libcpp/stack.pxd +11 -0
  204. Cython/Includes/libcpp/stop_token.pxd +105 -0
  205. Cython/Includes/libcpp/string.pxd +355 -0
  206. Cython/Includes/libcpp/string_view.pxd +181 -0
  207. Cython/Includes/libcpp/typeindex.pxd +15 -0
  208. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  209. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  210. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  211. Cython/Includes/libcpp/utility.pxd +30 -0
  212. Cython/Includes/libcpp/vector.pxd +186 -0
  213. Cython/Includes/openmp.pxd +50 -0
  214. Cython/Includes/posix/__init__.pxd +1 -0
  215. Cython/Includes/posix/dlfcn.pxd +14 -0
  216. Cython/Includes/posix/fcntl.pxd +86 -0
  217. Cython/Includes/posix/ioctl.pxd +4 -0
  218. Cython/Includes/posix/mman.pxd +101 -0
  219. Cython/Includes/posix/resource.pxd +57 -0
  220. Cython/Includes/posix/select.pxd +21 -0
  221. Cython/Includes/posix/signal.pxd +73 -0
  222. Cython/Includes/posix/stat.pxd +98 -0
  223. Cython/Includes/posix/stdio.pxd +37 -0
  224. Cython/Includes/posix/stdlib.pxd +29 -0
  225. Cython/Includes/posix/strings.pxd +9 -0
  226. Cython/Includes/posix/time.pxd +71 -0
  227. Cython/Includes/posix/types.pxd +30 -0
  228. Cython/Includes/posix/uio.pxd +26 -0
  229. Cython/Includes/posix/unistd.pxd +271 -0
  230. Cython/Includes/posix/wait.pxd +38 -0
  231. Cython/Plex/Actions.pxd +24 -0
  232. Cython/Plex/Actions.py +119 -0
  233. Cython/Plex/DFA.pxd +14 -0
  234. Cython/Plex/DFA.py +164 -0
  235. Cython/Plex/Errors.py +48 -0
  236. Cython/Plex/Lexicons.py +178 -0
  237. Cython/Plex/Machines.pxd +36 -0
  238. Cython/Plex/Machines.py +238 -0
  239. Cython/Plex/Regexps.py +539 -0
  240. Cython/Plex/Scanners.pxd +47 -0
  241. Cython/Plex/Scanners.py +360 -0
  242. Cython/Plex/Transitions.pxd +14 -0
  243. Cython/Plex/Transitions.py +239 -0
  244. Cython/Plex/__init__.py +34 -0
  245. Cython/Runtime/__init__.py +1 -0
  246. Cython/Runtime/refnanny.pyx +237 -0
  247. Cython/Shadow.py +690 -0
  248. Cython/Shadow.pyi +521 -0
  249. Cython/StringIOTree.py +170 -0
  250. Cython/Tempita/__init__.py +4 -0
  251. Cython/Tempita/_looper.py +154 -0
  252. Cython/Tempita/_tempita.py +1091 -0
  253. Cython/TestUtils.py +410 -0
  254. Cython/Tests/TestCodeWriter.py +128 -0
  255. Cython/Tests/TestCythonUtils.py +202 -0
  256. Cython/Tests/TestJediTyper.py +223 -0
  257. Cython/Tests/TestShadow.py +114 -0
  258. Cython/Tests/TestStringIOTree.py +67 -0
  259. Cython/Tests/TestTestUtils.py +90 -0
  260. Cython/Tests/__init__.py +1 -0
  261. Cython/Tests/xmlrunner.py +390 -0
  262. Cython/Utility/AsyncGen.c +1002 -0
  263. Cython/Utility/Buffer.c +875 -0
  264. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  265. Cython/Utility/Builtins.c +776 -0
  266. Cython/Utility/CConvert.pyx +134 -0
  267. Cython/Utility/CMath.c +104 -0
  268. Cython/Utility/CommonStructures.c +118 -0
  269. Cython/Utility/Complex.c +378 -0
  270. Cython/Utility/Coroutine.c +2206 -0
  271. Cython/Utility/CpdefEnums.pyx +103 -0
  272. Cython/Utility/CppConvert.pyx +279 -0
  273. Cython/Utility/CppSupport.cpp +143 -0
  274. Cython/Utility/CythonFunction.c +1794 -0
  275. Cython/Utility/Dataclasses.c +185 -0
  276. Cython/Utility/Dataclasses.py +112 -0
  277. Cython/Utility/Embed.c +125 -0
  278. Cython/Utility/Exceptions.c +1012 -0
  279. Cython/Utility/ExtensionTypes.c +809 -0
  280. Cython/Utility/FunctionArguments.c +965 -0
  281. Cython/Utility/ImportExport.c +987 -0
  282. Cython/Utility/Lock.c +136 -0
  283. Cython/Utility/MemoryView.pxd +187 -0
  284. Cython/Utility/MemoryView.pyx +1481 -0
  285. Cython/Utility/MemoryView_C.c +1046 -0
  286. Cython/Utility/ModuleSetupCode.c +3059 -0
  287. Cython/Utility/NumpyImportArray.c +46 -0
  288. Cython/Utility/ObjectHandling.c +3342 -0
  289. Cython/Utility/Optimize.c +1589 -0
  290. Cython/Utility/Overflow.c +404 -0
  291. Cython/Utility/Printing.c +86 -0
  292. Cython/Utility/Profile.c +709 -0
  293. Cython/Utility/StringTools.c +1259 -0
  294. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  295. Cython/Utility/TestCythonScope.pyx +75 -0
  296. Cython/Utility/TestUtilityLoader.c +12 -0
  297. Cython/Utility/TypeConversion.c +1284 -0
  298. Cython/Utility/UFuncs.pyx +50 -0
  299. Cython/Utility/UFuncs_C.c +89 -0
  300. Cython/Utility/__init__.py +28 -0
  301. Cython/Utility/arrayarray.h +148 -0
  302. Cython/Utils.py +687 -0
  303. Cython/__init__.py +10 -0
  304. Cython/__init__.pyi +7 -0
  305. Cython/py.typed +0 -0
  306. cython-3.1.0.dist-info/COPYING.txt +19 -0
  307. cython-3.1.0.dist-info/LICENSE.txt +176 -0
  308. cython-3.1.0.dist-info/METADATA +636 -0
  309. cython-3.1.0.dist-info/RECORD +316 -0
  310. cython-3.1.0.dist-info/WHEEL +5 -0
  311. cython-3.1.0.dist-info/entry_points.txt +4 -0
  312. cython-3.1.0.dist-info/top_level.txt +3 -0
  313. cython.py +29 -0
  314. pyximport/__init__.py +4 -0
  315. pyximport/pyxbuild.py +160 -0
  316. pyximport/pyximport.py +482 -0
@@ -0,0 +1,1002 @@
1
+ // This is copied from genobject.c in CPython 3.6.
2
+ // Try to keep it in sync by doing this from time to time:
3
+ // sed -e 's|__pyx_||ig' Cython/Utility/AsyncGen.c | diff -udw - cpython/Objects/genobject.c | less
4
+
5
+ //////////////////// AsyncGenerator.module_state_decls ////////////////////
6
+
7
+ PyTypeObject *__pyx__PyAsyncGenWrappedValueType;
8
+ PyTypeObject *__pyx__PyAsyncGenASendType;
9
+ PyTypeObject *__pyx__PyAsyncGenAThrowType;
10
+ PyTypeObject *__pyx_AsyncGenType;
11
+
12
+ // Freelists boost performance 6-10%; they also reduce memory
13
+ // fragmentation, as _PyAsyncGenWrappedValue and PyAsyncGenASend
14
+ // are short-living objects that are instantiated for every
15
+ // __anext__ call.
16
+
17
+ #if CYTHON_USE_FREELISTS
18
+ struct __pyx__PyAsyncGenWrappedValue *__Pyx_ag_value_freelist[_PyAsyncGen_MAXFREELIST];
19
+ int __Pyx_ag_value_freelist_free;
20
+
21
+ struct __pyx_PyAsyncGenASend *__Pyx_ag_asend_freelist[_PyAsyncGen_MAXFREELIST];
22
+ int __Pyx_ag_asend_freelist_free;
23
+ #endif
24
+
25
+ //////////////////// AsyncGenerator.proto ////////////////////
26
+ //@requires: Coroutine.c::Coroutine
27
+
28
+ #define __Pyx_AsyncGen_USED
29
+ typedef struct {
30
+ __pyx_CoroutineObject coro;
31
+ PyObject *ag_finalizer;
32
+ int ag_hooks_inited;
33
+ int ag_closed;
34
+ int ag_running_async;
35
+ } __pyx_PyAsyncGenObject;
36
+
37
+ #define __Pyx_AsyncGen_CheckExact(obj) __Pyx_IS_TYPE(obj, CGLOBAL(__pyx_AsyncGenType))
38
+ #define __pyx_PyAsyncGenASend_CheckExact(o) \
39
+ __Pyx_IS_TYPE(o, CGLOBAL(__pyx__PyAsyncGenASendType))
40
+ #define __pyx_PyAsyncGenAThrow_CheckExact(o) \
41
+ __Pyx_IS_TYPE(o, CGLOBAL(__pyx__PyAsyncGenAThrowType))
42
+
43
+ static PyObject *__Pyx_async_gen_anext(PyObject *o);
44
+ static CYTHON_INLINE PyObject *__Pyx_async_gen_asend_iternext(PyObject *o);
45
+ static PyObject *__Pyx_async_gen_asend_send(PyObject *g, PyObject *arg);
46
+ static PyObject *__Pyx_async_gen_asend_close(PyObject *o, PyObject *args);
47
+ static PyObject *__Pyx_async_gen_athrow_close(PyObject *o, PyObject *args);
48
+
49
+ static PyObject *__Pyx__PyAsyncGenValueWrapperNew(PyObject *val);
50
+
51
+
52
+ static __pyx_CoroutineObject *__Pyx_AsyncGen_New(
53
+ __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
54
+ PyObject *name, PyObject *qualname, PyObject *module_name);
55
+
56
+ static int __pyx_AsyncGen_init(PyObject *module);
57
+ static void __Pyx_PyAsyncGen_Fini(void);
58
+
59
+ #if CYTHON_USE_FREELISTS && !defined(_PyAsyncGen_MAXFREELIST)
60
+ #define _PyAsyncGen_MAXFREELIST 80
61
+ #endif
62
+
63
+ struct __pyx__PyAsyncGenWrappedValue;
64
+ struct __pyx_PyAsyncGenASend;
65
+
66
+ //////////////////// AsyncGenerator.cleanup ////////////////////
67
+
68
+ __Pyx_PyAsyncGen_Fini();
69
+
70
+ //////////////////// AsyncGenerator ////////////////////
71
+ //@substitute: naming
72
+ //@requires: Coroutine.c::Coroutine
73
+ //@requires: Coroutine.c::ReturnWithStopIteration
74
+ //@requires: ObjectHandling.c::PyObjectCall2Args
75
+ //@requires: ExtensionTypes.c::CallTypeTraverse
76
+
77
+ PyDoc_STRVAR(__Pyx_async_gen_send_doc,
78
+ "send(arg) -> send 'arg' into generator,\n\
79
+ return next yielded value or raise StopIteration.");
80
+
81
+ PyDoc_STRVAR(__Pyx_async_gen_close_doc,
82
+ "close() -> raise GeneratorExit inside generator.");
83
+
84
+ PyDoc_STRVAR(__Pyx_async_gen_throw_doc,
85
+ "throw(typ[,val[,tb]]) -> raise exception in generator,\n\
86
+ return next yielded value or raise StopIteration.");
87
+
88
+ PyDoc_STRVAR(__Pyx_async_gen_await_doc,
89
+ "__await__() -> return a representation that can be passed into the 'await' expression.");
90
+
91
+ static __pyx_CoroutineObject *__Pyx_AsyncGen_New(
92
+ __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
93
+ PyObject *name, PyObject *qualname, PyObject *module_name) {
94
+ __pyx_PyAsyncGenObject *gen = PyObject_GC_New(__pyx_PyAsyncGenObject, CGLOBAL(__pyx_AsyncGenType));
95
+ if (unlikely(!gen))
96
+ return NULL;
97
+ gen->ag_finalizer = NULL;
98
+ gen->ag_closed = 0;
99
+ gen->ag_hooks_inited = 0;
100
+ gen->ag_running_async = 0;
101
+ return __Pyx__Coroutine_NewInit((__pyx_CoroutineObject*)gen, body, code, closure, name, qualname, module_name);
102
+ }
103
+
104
+ // COPY STARTS HERE:
105
+
106
+ static PyObject *__Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *, PyObject *);
107
+ static PyObject *__Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *, PyObject *);
108
+
109
+ static const char *__Pyx_NON_INIT_CORO_MSG = "can't send non-None value to a just-started coroutine";
110
+ static const char *__Pyx_ASYNC_GEN_IGNORED_EXIT_MSG = "async generator ignored GeneratorExit";
111
+ static const char *__Pyx_ASYNC_GEN_CANNOT_REUSE_SEND_MSG = "cannot reuse already awaited __anext__()/asend()";
112
+ static const char *__Pyx_ASYNC_GEN_CANNOT_REUSE_CLOSE_MSG = "cannot reuse already awaited aclose()/athrow()";
113
+
114
+ typedef enum {
115
+ __PYX_AWAITABLE_STATE_INIT, /* new awaitable, has not yet been iterated */
116
+ __PYX_AWAITABLE_STATE_ITER, /* being iterated */
117
+ __PYX_AWAITABLE_STATE_CLOSED, /* closed */
118
+ } __pyx_AwaitableState;
119
+
120
+ typedef struct __pyx_PyAsyncGenASend {
121
+ PyObject_HEAD
122
+ __pyx_PyAsyncGenObject *ags_gen;
123
+
124
+ /* Can be NULL, when in the __anext__() mode (equivalent of "asend(None)") */
125
+ PyObject *ags_sendval;
126
+
127
+ __pyx_AwaitableState ags_state;
128
+ } __pyx_PyAsyncGenASend;
129
+
130
+
131
+ typedef struct {
132
+ PyObject_HEAD
133
+ __pyx_PyAsyncGenObject *agt_gen;
134
+
135
+ /* Can be NULL, when in the "aclose()" mode (equivalent of "athrow(GeneratorExit)") */
136
+ PyObject *agt_args;
137
+
138
+ __pyx_AwaitableState agt_state;
139
+ } __pyx_PyAsyncGenAThrow;
140
+
141
+
142
+ typedef struct __pyx__PyAsyncGenWrappedValue {
143
+ PyObject_HEAD
144
+ PyObject *agw_val;
145
+ } __pyx__PyAsyncGenWrappedValue;
146
+
147
+ #define __pyx__PyAsyncGenWrappedValue_CheckExact(o) \
148
+ __Pyx_IS_TYPE(o, CGLOBAL(__pyx__PyAsyncGenWrappedValueType))
149
+
150
+
151
+ static int
152
+ __Pyx_async_gen_traverse(__pyx_PyAsyncGenObject *gen, visitproc visit, void *arg)
153
+ {
154
+ // visiting the type is handled in the base if needed
155
+ Py_VISIT(gen->ag_finalizer);
156
+ return __Pyx_Coroutine_traverse((__pyx_CoroutineObject*)gen, visit, arg);
157
+ }
158
+
159
+
160
+ static PyObject *
161
+ __Pyx_async_gen_repr(__pyx_CoroutineObject *o)
162
+ {
163
+ // avoid NULL pointer dereference for qualname during garbage collection
164
+ return PyUnicode_FromFormat("<async_generator object %S at %p>",
165
+ o->gi_qualname ? o->gi_qualname : Py_None, o);
166
+ }
167
+
168
+
169
+ static int
170
+ __Pyx_async_gen_init_hooks_firstiter(__pyx_PyAsyncGenObject *o, PyObject *firstiter)
171
+ {
172
+ PyObject *res;
173
+ // at least asyncio stores methods here => optimise the call
174
+ #if CYTHON_UNPACK_METHODS
175
+ PyObject *self;
176
+ if (likely(PyMethod_Check(firstiter)) && likely((self = PyMethod_GET_SELF(firstiter)) != NULL)) {
177
+ PyObject *function = PyMethod_GET_FUNCTION(firstiter);
178
+ res = __Pyx_PyObject_Call2Args(function, self, (PyObject*)o);
179
+ } else
180
+ #endif
181
+ res = __Pyx_PyObject_CallOneArg(firstiter, (PyObject*)o);
182
+
183
+ Py_DECREF(firstiter);
184
+
185
+ if (unlikely(res == NULL))
186
+ return 1;
187
+
188
+ Py_DECREF(res);
189
+ return 0;
190
+ }
191
+
192
+
193
+ static CYTHON_INLINE int
194
+ __Pyx_async_gen_init_hooks_done(__pyx_PyAsyncGenObject *o) {
195
+ return o->ag_hooks_inited != 0;
196
+ }
197
+
198
+ static int
199
+ __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o)
200
+ {
201
+ #if !CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API
202
+ PyThreadState *tstate;
203
+ #endif
204
+ PyObject *finalizer;
205
+ PyObject *firstiter;
206
+
207
+ assert (!__Pyx_async_gen_init_hooks_done(o));
208
+ o->ag_hooks_inited = 1;
209
+
210
+ #if CYTHON_COMPILING_IN_LIMITED_API
211
+ {
212
+ PyObject *hooks_func = PySys_GetObject("get_asyncgen_hooks");
213
+ if (unlikely(!hooks_func)) {
214
+ PyErr_SetString(
215
+ PyExc_AttributeError,
216
+ "Failed to get 'get_asyncgen_hooks' from sys"
217
+ );
218
+ return 1;
219
+ }
220
+ PyObject *async_gen_hooks = PyObject_CallFunctionObjArgs(hooks_func, NULL);
221
+ if (unlikely(!async_gen_hooks)) return 1;
222
+ firstiter = PySequence_GetItem(async_gen_hooks, 0);
223
+ if (unlikely(!firstiter)) {
224
+ Py_DECREF(async_gen_hooks);
225
+ return 1;
226
+ }
227
+ if (firstiter == Py_None) {
228
+ Py_CLEAR(firstiter);
229
+ }
230
+
231
+ finalizer = PySequence_GetItem(async_gen_hooks, 1);
232
+ Py_DECREF(async_gen_hooks);
233
+
234
+ if (unlikely(!finalizer)) {
235
+ Py_XDECREF(firstiter);
236
+ return 1;
237
+ }
238
+ if (finalizer == Py_None) {
239
+ Py_CLEAR(finalizer);
240
+ }
241
+ }
242
+ #endif
243
+
244
+ #if CYTHON_COMPILING_IN_PYPY
245
+ finalizer = _PyEval_GetAsyncGenFinalizer();
246
+ #elif !CYTHON_COMPILING_IN_LIMITED_API
247
+ tstate = __Pyx_PyThreadState_Current;
248
+ finalizer = tstate->async_gen_finalizer;
249
+ #endif
250
+ if (finalizer) {
251
+ #if !CYTHON_COMPILING_IN_LIMITED_API
252
+ Py_INCREF(finalizer);
253
+ #endif
254
+ o->ag_finalizer = finalizer;
255
+ }
256
+
257
+ #if CYTHON_COMPILING_IN_PYPY
258
+ firstiter = _PyEval_GetAsyncGenFirstiter();
259
+ #elif !CYTHON_COMPILING_IN_LIMITED_API
260
+ firstiter = tstate->async_gen_firstiter;
261
+ #endif
262
+ if (firstiter) {
263
+ #if !CYTHON_COMPILING_IN_LIMITED_API
264
+ Py_INCREF(firstiter);
265
+ #endif
266
+ // Transfers the reference.
267
+ if (unlikely(__Pyx_async_gen_init_hooks_firstiter(o, firstiter)))
268
+ return 1;
269
+ }
270
+
271
+ return 0;
272
+ }
273
+
274
+
275
+ static PyObject *
276
+ __Pyx_async_gen_anext(PyObject *g)
277
+ {
278
+ __pyx_PyAsyncGenObject *o = (__pyx_PyAsyncGenObject*) g;
279
+ if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
280
+ return NULL;
281
+ }
282
+ return __Pyx_async_gen_asend_new(o, NULL);
283
+ }
284
+
285
+ static PyObject *
286
+ __Pyx_async_gen_anext_method(PyObject *g, PyObject *arg) {
287
+ CYTHON_UNUSED_VAR(arg);
288
+ return __Pyx_async_gen_anext(g);
289
+ }
290
+
291
+
292
+ static PyObject *
293
+ __Pyx_async_gen_asend(__pyx_PyAsyncGenObject *o, PyObject *arg)
294
+ {
295
+ if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
296
+ return NULL;
297
+ }
298
+ return __Pyx_async_gen_asend_new(o, arg);
299
+ }
300
+
301
+
302
+ static PyObject *
303
+ __Pyx_async_gen_aclose(__pyx_PyAsyncGenObject *o, PyObject *arg)
304
+ {
305
+ CYTHON_UNUSED_VAR(arg);
306
+ if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
307
+ return NULL;
308
+ }
309
+ return __Pyx_async_gen_athrow_new(o, NULL);
310
+ }
311
+
312
+
313
+ static PyObject *
314
+ __Pyx_async_gen_athrow(__pyx_PyAsyncGenObject *o, PyObject *args)
315
+ {
316
+ if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
317
+ return NULL;
318
+ }
319
+ return __Pyx_async_gen_athrow_new(o, args);
320
+ }
321
+
322
+
323
+ static PyObject *
324
+ __Pyx_async_gen_self_method(PyObject *g, PyObject *arg) {
325
+ CYTHON_UNUSED_VAR(arg);
326
+ return __Pyx_NewRef(g);
327
+ }
328
+
329
+
330
+ static PyGetSetDef __Pyx_async_gen_getsetlist[] = {
331
+ {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
332
+ PyDoc_STR("name of the async generator"), 0},
333
+ {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
334
+ PyDoc_STR("qualified name of the async generator"), 0},
335
+ //REMOVED: {(char*) "ag_await", (getter)coro_get_cr_await, NULL,
336
+ //REMOVED: (char*) PyDoc_STR("object being awaited on, or None")},
337
+ {0, 0, 0, 0, 0} /* Sentinel */
338
+ };
339
+
340
+ static PyMemberDef __Pyx_async_gen_memberlist[] = {
341
+ //REMOVED: {(char*) "ag_frame", T_OBJECT, offsetof(__pyx_PyAsyncGenObject, ag_frame), READONLY},
342
+ {"ag_running", T_BOOL, offsetof(__pyx_PyAsyncGenObject, ag_running_async), READONLY, NULL},
343
+ //REMOVED: {(char*) "ag_code", T_OBJECT, offsetof(__pyx_PyAsyncGenObject, ag_code), READONLY},
344
+ //ADDED: "ag_await"
345
+ {"ag_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
346
+ PyDoc_STR("object being awaited on, or None")},
347
+ {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
348
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
349
+ {0, 0, 0, 0, 0} /* Sentinel */
350
+ };
351
+
352
+ PyDoc_STRVAR(__Pyx_async_aclose_doc,
353
+ "aclose() -> raise GeneratorExit inside generator.");
354
+
355
+ PyDoc_STRVAR(__Pyx_async_asend_doc,
356
+ "asend(v) -> send 'v' in generator.");
357
+
358
+ PyDoc_STRVAR(__Pyx_async_athrow_doc,
359
+ "athrow(typ[,val[,tb]]) -> raise exception in generator.");
360
+
361
+ PyDoc_STRVAR(__Pyx_async_aiter_doc,
362
+ "__aiter__(v) -> return an asynchronous iterator.");
363
+
364
+ PyDoc_STRVAR(__Pyx_async_anext_doc,
365
+ "__anext__(v) -> continue asynchronous iteration and return the next element.");
366
+
367
+ static PyMethodDef __Pyx_async_gen_methods[] = {
368
+ {"asend", (PyCFunction)__Pyx_async_gen_asend, METH_O, __Pyx_async_asend_doc},
369
+ {"athrow",(PyCFunction)__Pyx_async_gen_athrow, METH_VARARGS, __Pyx_async_athrow_doc},
370
+ {"aclose", (PyCFunction)__Pyx_async_gen_aclose, METH_NOARGS, __Pyx_async_aclose_doc},
371
+ {"__aiter__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_aiter_doc},
372
+ {"__anext__", (PyCFunction)__Pyx_async_gen_anext_method, METH_NOARGS, __Pyx_async_anext_doc},
373
+ {0, 0, 0, 0} /* Sentinel */
374
+ };
375
+
376
+
377
+ static PyType_Slot __pyx_AsyncGenType_slots[] = {
378
+ {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
379
+ {Py_am_aiter, (void *)PyObject_SelfIter},
380
+ {Py_am_anext, (void *)__Pyx_async_gen_anext},
381
+ {Py_tp_repr, (void *)__Pyx_async_gen_repr},
382
+ {Py_tp_traverse, (void *)__Pyx_async_gen_traverse},
383
+ {Py_tp_methods, (void *)__Pyx_async_gen_methods},
384
+ {Py_tp_members, (void *)__Pyx_async_gen_memberlist},
385
+ {Py_tp_getset, (void *)__Pyx_async_gen_getsetlist},
386
+ #if CYTHON_USE_TP_FINALIZE
387
+ {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
388
+ #endif
389
+ {0, 0},
390
+ };
391
+
392
+ static PyType_Spec __pyx_AsyncGenType_spec = {
393
+ __PYX_TYPE_MODULE_PREFIX "async_generator",
394
+ sizeof(__pyx_PyAsyncGenObject),
395
+ 0,
396
+ #if PY_VERSION_HEX >= 0x030A0000
397
+ Py_TPFLAGS_IMMUTABLETYPE |
398
+ #endif
399
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/
400
+ __pyx_AsyncGenType_slots
401
+ };
402
+
403
+
404
+ static int
405
+ __Pyx_PyAsyncGen_ClearFreeLists(void)
406
+ {
407
+ #if CYTHON_USE_FREELISTS
408
+ int ret = CGLOBAL(__Pyx_ag_value_freelist_free) + CGLOBAL(__Pyx_ag_asend_freelist_free);
409
+
410
+ while (CGLOBAL(__Pyx_ag_value_freelist_free)) {
411
+ __pyx__PyAsyncGenWrappedValue *o;
412
+ o = CGLOBAL(__Pyx_ag_value_freelist)[--CGLOBAL(__Pyx_ag_value_freelist_free]);
413
+ assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o));
414
+ __Pyx_PyHeapTypeObject_GC_Del(o);
415
+ }
416
+
417
+ while (CGLOBAL(__Pyx_ag_asend_freelist_free)) {
418
+ __pyx_PyAsyncGenASend *o;
419
+ o = CGLOBAL(__Pyx_ag_asend_freelist)[--CGLOBAL(__Pyx_ag_asend_freelist_free)];
420
+ assert(__Pyx_IS_TYPE(o, CGLOBAL(__pyx__PyAsyncGenASendType)));
421
+ __Pyx_PyHeapTypeObject_GC_Del(o);
422
+ }
423
+
424
+ return ret;
425
+ #else
426
+ return 0;
427
+ #endif
428
+ }
429
+
430
+ static void
431
+ __Pyx_PyAsyncGen_Fini(void)
432
+ {
433
+ __Pyx_PyAsyncGen_ClearFreeLists();
434
+ }
435
+
436
+
437
+ static PyObject *
438
+ __Pyx_async_gen_unwrap_value(__pyx_PyAsyncGenObject *gen, PyObject *result, int iternext)
439
+ {
440
+ if (result == NULL) {
441
+ PyObject *exc_type = PyErr_Occurred();
442
+ if (!exc_type) {
443
+ PyErr_SetNone(PyExc_StopAsyncIteration);
444
+ gen->ag_closed = 1;
445
+ } else if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, PyExc_StopAsyncIteration, PyExc_GeneratorExit)) {
446
+ gen->ag_closed = 1;
447
+ }
448
+
449
+ gen->ag_running_async = 0;
450
+ return NULL;
451
+ }
452
+
453
+ if (__pyx__PyAsyncGenWrappedValue_CheckExact(result)) {
454
+ /* async yield */
455
+ __Pyx_ReturnWithStopIteration(((__pyx__PyAsyncGenWrappedValue*)result)->agw_val, 0, iternext);
456
+ Py_DECREF(result);
457
+ gen->ag_running_async = 0;
458
+ return NULL;
459
+ }
460
+
461
+ return result;
462
+ }
463
+
464
+
465
+ /* ---------- Async Generator ASend Awaitable ------------ */
466
+
467
+
468
+ static void
469
+ __Pyx_async_gen_asend_dealloc(__pyx_PyAsyncGenASend *o)
470
+ {
471
+ PyObject_GC_UnTrack((PyObject *)o);
472
+ Py_CLEAR(o->ags_gen);
473
+ Py_CLEAR(o->ags_sendval);
474
+ #if CYTHON_USE_FREELISTS
475
+ if (likely(CGLOBAL(__Pyx_ag_asend_freelist_free) < _PyAsyncGen_MAXFREELIST)) {
476
+ assert(__pyx_PyAsyncGenASend_CheckExact(o));
477
+ CGLOBAL(__Pyx_ag_asend_freelist)[CGLOBAL(__Pyx_ag_asend_freelist_free)++] = o;
478
+ } else
479
+ #endif
480
+ {
481
+ __Pyx_PyHeapTypeObject_GC_Del(o);
482
+ }
483
+ }
484
+
485
+ static int
486
+ __Pyx_async_gen_asend_traverse(__pyx_PyAsyncGenASend *o, visitproc visit, void *arg)
487
+ {
488
+ {
489
+ int e = __Pyx_call_type_traverse((PyObject*)o, 1, visit, arg);
490
+ if (e) return e;
491
+ }
492
+ Py_VISIT(o->ags_gen);
493
+ Py_VISIT(o->ags_sendval);
494
+ return 0;
495
+ }
496
+
497
+ static PyObject *
498
+ __Pyx_async_gen_asend_send_impl(PyObject *g, PyObject *arg, int iternext)
499
+ {
500
+ __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g;
501
+ PyObject *retval;
502
+
503
+ if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) {
504
+ PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_SEND_MSG);
505
+ return NULL;
506
+ }
507
+
508
+ if (o->ags_state == __PYX_AWAITABLE_STATE_INIT) {
509
+ if (unlikely(o->ags_gen->ag_running_async)) {
510
+ PyErr_SetString(
511
+ PyExc_RuntimeError,
512
+ "anext(): asynchronous generator is already running");
513
+ return NULL;
514
+ }
515
+
516
+ if (arg == NULL || arg == Py_None) {
517
+ arg = o->ags_sendval ? o->ags_sendval : Py_None;
518
+ }
519
+ o->ags_state = __PYX_AWAITABLE_STATE_ITER;
520
+ }
521
+
522
+ o->ags_gen->ag_running_async = 1;
523
+ retval = __Pyx_Coroutine_Send((PyObject*)o->ags_gen, arg);
524
+ retval = __Pyx_async_gen_unwrap_value(o->ags_gen, retval, iternext);
525
+
526
+ if (!retval) {
527
+ o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
528
+ }
529
+
530
+ return retval;
531
+ }
532
+
533
+ static PyObject *
534
+ __Pyx_async_gen_asend_send(PyObject *g, PyObject *arg)
535
+ {
536
+ return __Pyx_async_gen_asend_send_impl(g, arg, 0);
537
+ }
538
+
539
+
540
+ static CYTHON_INLINE PyObject *
541
+ __Pyx_async_gen_asend_iternext(PyObject *o)
542
+ {
543
+ return __Pyx_async_gen_asend_send_impl(o, Py_None, 1);
544
+ }
545
+
546
+
547
+ static PyObject *
548
+ __Pyx_async_gen_asend_throw(__pyx_PyAsyncGenASend *o, PyObject *args)
549
+ {
550
+ PyObject *result;
551
+
552
+ if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) {
553
+ PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_SEND_MSG);
554
+ return NULL;
555
+ }
556
+
557
+ result = __Pyx_Coroutine_Throw((PyObject*)o->ags_gen, args);
558
+ result = __Pyx_async_gen_unwrap_value(o->ags_gen, result, 0);
559
+
560
+ if (result == NULL) {
561
+ o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
562
+ }
563
+
564
+ return result;
565
+ }
566
+
567
+
568
+ static PyObject *
569
+ __Pyx_async_gen_asend_close(PyObject *g, PyObject *args)
570
+ {
571
+ __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g;
572
+ CYTHON_UNUSED_VAR(args);
573
+ o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
574
+ Py_RETURN_NONE;
575
+ }
576
+
577
+
578
+ static PyMethodDef __Pyx_async_gen_asend_methods[] = {
579
+ {"send", (PyCFunction)__Pyx_async_gen_asend_send, METH_O, __Pyx_async_gen_send_doc},
580
+ {"throw", (PyCFunction)__Pyx_async_gen_asend_throw, METH_VARARGS, __Pyx_async_gen_throw_doc},
581
+ {"close", (PyCFunction)__Pyx_async_gen_asend_close, METH_NOARGS, __Pyx_async_gen_close_doc},
582
+ {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc},
583
+ {0, 0, 0, 0} /* Sentinel */
584
+ };
585
+
586
+
587
+ static PyType_Slot __pyx__PyAsyncGenASendType_slots[] = {
588
+ {Py_tp_dealloc, (void *)__Pyx_async_gen_asend_dealloc},
589
+ {Py_am_await, (void *)PyObject_SelfIter},
590
+ {Py_tp_traverse, (void *)__Pyx_async_gen_asend_traverse},
591
+ {Py_tp_methods, (void *)__Pyx_async_gen_asend_methods},
592
+ {Py_tp_iter, (void *)PyObject_SelfIter},
593
+ {Py_tp_iternext, (void *)__Pyx_async_gen_asend_iternext},
594
+ {0, 0},
595
+ };
596
+
597
+ static PyType_Spec __pyx__PyAsyncGenASendType_spec = {
598
+ __PYX_TYPE_MODULE_PREFIX "async_generator_asend",
599
+ sizeof(__pyx_PyAsyncGenASend),
600
+ 0,
601
+ #if PY_VERSION_HEX >= 0x030A0000
602
+ Py_TPFLAGS_IMMUTABLETYPE |
603
+ #endif
604
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
605
+ __pyx__PyAsyncGenASendType_slots
606
+ };
607
+
608
+
609
+ static PyObject *
610
+ __Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *gen, PyObject *sendval)
611
+ {
612
+ __pyx_PyAsyncGenASend *o;
613
+ #if CYTHON_USE_FREELISTS
614
+ if (likely(CGLOBAL(__Pyx_ag_asend_freelist_free))) {
615
+ CGLOBAL(__Pyx_ag_asend_freelist_free)--;
616
+ o = CGLOBAL(__Pyx_ag_asend_freelist)[CGLOBAL(__Pyx_ag_asend_freelist_free)];
617
+ _Py_NewReference((PyObject *)o);
618
+ } else
619
+ #endif
620
+ {
621
+ o = PyObject_GC_New(__pyx_PyAsyncGenASend, CGLOBAL(__pyx__PyAsyncGenASendType));
622
+ if (unlikely(o == NULL)) {
623
+ return NULL;
624
+ }
625
+ }
626
+
627
+ Py_INCREF((PyObject*)gen);
628
+ o->ags_gen = gen;
629
+
630
+ Py_XINCREF(sendval);
631
+ o->ags_sendval = sendval;
632
+
633
+ o->ags_state = __PYX_AWAITABLE_STATE_INIT;
634
+
635
+ PyObject_GC_Track((PyObject*)o);
636
+ return (PyObject*)o;
637
+ }
638
+
639
+
640
+ /* ---------- Async Generator Value Wrapper ------------ */
641
+
642
+
643
+ static void
644
+ __Pyx_async_gen_wrapped_val_dealloc(__pyx__PyAsyncGenWrappedValue *o)
645
+ {
646
+ PyObject_GC_UnTrack((PyObject *)o);
647
+ Py_CLEAR(o->agw_val);
648
+ #if CYTHON_USE_FREELISTS
649
+ if (likely(CGLOBAL(__Pyx_ag_value_freelist_free) < _PyAsyncGen_MAXFREELIST)) {
650
+ assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o));
651
+ CGLOBAL(__Pyx_ag_value_freelist)[CGLOBAL(__Pyx_ag_value_freelist_free)++] = o;
652
+ } else
653
+ #endif
654
+ {
655
+ __Pyx_PyHeapTypeObject_GC_Del(o);
656
+ }
657
+ }
658
+
659
+
660
+ static int
661
+ __Pyx_async_gen_wrapped_val_traverse(__pyx__PyAsyncGenWrappedValue *o,
662
+ visitproc visit, void *arg)
663
+ {
664
+ {
665
+ int e = __Pyx_call_type_traverse((PyObject*)o, 1, visit, arg);
666
+ if (e) return e;
667
+ }
668
+ Py_VISIT(o->agw_val);
669
+ return 0;
670
+ }
671
+
672
+
673
+ static PyType_Slot __pyx__PyAsyncGenWrappedValueType_slots[] = {
674
+ {Py_tp_dealloc, (void *)__Pyx_async_gen_wrapped_val_dealloc},
675
+ {Py_tp_traverse, (void *)__Pyx_async_gen_wrapped_val_traverse},
676
+ {0, 0},
677
+ };
678
+
679
+ static PyType_Spec __pyx__PyAsyncGenWrappedValueType_spec = {
680
+ __PYX_TYPE_MODULE_PREFIX "async_generator_wrapped_value",
681
+ sizeof(__pyx__PyAsyncGenWrappedValue),
682
+ 0,
683
+ #if PY_VERSION_HEX >= 0x030A0000
684
+ Py_TPFLAGS_IMMUTABLETYPE |
685
+ #endif
686
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
687
+ __pyx__PyAsyncGenWrappedValueType_slots
688
+ };
689
+
690
+
691
+ static PyObject *
692
+ __Pyx__PyAsyncGenValueWrapperNew(PyObject *val)
693
+ {
694
+ // NOTE: steals a reference to val !
695
+ __pyx__PyAsyncGenWrappedValue *o;
696
+ assert(val);
697
+
698
+ #if CYTHON_USE_FREELISTS
699
+ if (likely(CGLOBAL(__Pyx_ag_value_freelist_free))) {
700
+ CGLOBAL(__Pyx_ag_value_freelist_free)--;
701
+ o = CGLOBAL(__Pyx_ag_value_freelist)[CGLOBAL(__Pyx_ag_value_freelist_free)];
702
+ assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o));
703
+ _Py_NewReference((PyObject*)o);
704
+ } else
705
+ #endif
706
+ {
707
+ o = PyObject_GC_New(__pyx__PyAsyncGenWrappedValue, CGLOBAL(__pyx__PyAsyncGenWrappedValueType));
708
+ if (unlikely(!o)) {
709
+ Py_DECREF(val);
710
+ return NULL;
711
+ }
712
+ }
713
+ o->agw_val = val;
714
+ // no Py_INCREF(val) - steals reference!
715
+ PyObject_GC_Track((PyObject*)o);
716
+ return (PyObject*)o;
717
+ }
718
+
719
+
720
+ /* ---------- Async Generator AThrow awaitable ------------ */
721
+
722
+
723
+ static void
724
+ __Pyx_async_gen_athrow_dealloc(__pyx_PyAsyncGenAThrow *o)
725
+ {
726
+ PyObject_GC_UnTrack((PyObject *)o);
727
+ Py_CLEAR(o->agt_gen);
728
+ Py_CLEAR(o->agt_args);
729
+ __Pyx_PyHeapTypeObject_GC_Del(o);
730
+ }
731
+
732
+
733
+ static int
734
+ __Pyx_async_gen_athrow_traverse(__pyx_PyAsyncGenAThrow *o, visitproc visit, void *arg)
735
+ {
736
+ {
737
+ int e = __Pyx_call_type_traverse((PyObject*)o, 1, visit, arg);
738
+ if (e) return e;
739
+ }
740
+ Py_VISIT(o->agt_gen);
741
+ Py_VISIT(o->agt_args);
742
+ return 0;
743
+ }
744
+
745
+
746
+ static PyObject *
747
+ __Pyx_async_gen_athrow_send_impl(__pyx_PyAsyncGenAThrow *o, PyObject *arg, int iternext)
748
+ {
749
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*)o->agt_gen;
750
+ PyObject *retval, *exc_type;
751
+
752
+ if (unlikely(o->agt_state == __PYX_AWAITABLE_STATE_CLOSED)) {
753
+ PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_CLOSE_MSG);
754
+ return NULL;
755
+ }
756
+
757
+ if (unlikely(gen->resume_label == -1)) {
758
+ // already run past the end
759
+ o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
760
+ PyErr_SetNone(PyExc_StopIteration);
761
+ return NULL;
762
+ }
763
+
764
+ if (o->agt_state == __PYX_AWAITABLE_STATE_INIT) {
765
+ if (unlikely(o->agt_gen->ag_running_async)) {
766
+ o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
767
+ if (o->agt_args == NULL) {
768
+ PyErr_SetString(
769
+ PyExc_RuntimeError,
770
+ "aclose(): asynchronous generator is already running");
771
+ } else {
772
+ PyErr_SetString(
773
+ PyExc_RuntimeError,
774
+ "athrow(): asynchronous generator is already running");
775
+ }
776
+ return NULL;
777
+ }
778
+
779
+ if (unlikely(o->agt_gen->ag_closed)) {
780
+ o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
781
+ PyErr_SetNone(PyExc_StopAsyncIteration);
782
+ return NULL;
783
+ }
784
+
785
+ if (unlikely(arg != Py_None)) {
786
+ PyErr_SetString(PyExc_RuntimeError, __Pyx_NON_INIT_CORO_MSG);
787
+ return NULL;
788
+ }
789
+
790
+ o->agt_state = __PYX_AWAITABLE_STATE_ITER;
791
+ o->agt_gen->ag_running_async = 1;
792
+
793
+ if (o->agt_args == NULL) {
794
+ /* aclose() mode */
795
+ o->agt_gen->ag_closed = 1;
796
+
797
+ retval = __Pyx__Coroutine_Throw((PyObject*)gen,
798
+ /* Do not close generator when PyExc_GeneratorExit is passed */
799
+ PyExc_GeneratorExit, NULL, NULL, NULL, 0);
800
+
801
+ if (retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval)) {
802
+ Py_DECREF(retval);
803
+ goto yield_close;
804
+ }
805
+ } else {
806
+ PyObject *typ;
807
+ PyObject *tb = NULL;
808
+ PyObject *val = NULL;
809
+
810
+ if (unlikely(!PyArg_UnpackTuple(o->agt_args, "athrow", 1, 3, &typ, &val, &tb))) {
811
+ return NULL;
812
+ }
813
+
814
+ retval = __Pyx__Coroutine_Throw((PyObject*)gen,
815
+ /* Do not close generator when PyExc_GeneratorExit is passed */
816
+ typ, val, tb, o->agt_args, 0);
817
+ retval = __Pyx_async_gen_unwrap_value(o->agt_gen, retval, iternext);
818
+ }
819
+ if (retval == NULL) {
820
+ goto check_error;
821
+ }
822
+ return retval;
823
+ }
824
+
825
+ assert (o->agt_state == __PYX_AWAITABLE_STATE_ITER);
826
+
827
+ retval = __Pyx_Coroutine_Send((PyObject *)gen, arg);
828
+ if (o->agt_args) {
829
+ return __Pyx_async_gen_unwrap_value(o->agt_gen, retval, iternext);
830
+ } else {
831
+ /* aclose() mode */
832
+ if (retval) {
833
+ if (unlikely(__pyx__PyAsyncGenWrappedValue_CheckExact(retval))) {
834
+ Py_DECREF(retval);
835
+ goto yield_close;
836
+ }
837
+ else {
838
+ return retval;
839
+ }
840
+ }
841
+ else {
842
+ goto check_error;
843
+ }
844
+ }
845
+
846
+ yield_close:
847
+ o->agt_gen->ag_running_async = 0;
848
+ o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
849
+ PyErr_SetString(
850
+ PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG);
851
+ return NULL;
852
+
853
+ check_error:
854
+ o->agt_gen->ag_running_async = 0;
855
+ o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
856
+ exc_type = PyErr_Occurred();
857
+ if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, PyExc_StopAsyncIteration, PyExc_GeneratorExit)) {
858
+ if (o->agt_args == NULL) {
859
+ // when aclose() is called we don't want to propagate
860
+ // StopAsyncIteration or GeneratorExit; just raise
861
+ // StopIteration, signalling that this 'aclose()' await
862
+ // is done.
863
+ PyErr_Clear();
864
+ PyErr_SetNone(PyExc_StopIteration);
865
+ }
866
+ }
867
+ return NULL;
868
+ }
869
+
870
+ static PyObject *
871
+ __Pyx_async_gen_athrow_send(__pyx_PyAsyncGenAThrow *o, PyObject *arg)
872
+ {
873
+ return __Pyx_async_gen_athrow_send_impl(o, arg, 0);
874
+ }
875
+
876
+
877
+ static PyObject *
878
+ __Pyx_async_gen_athrow_throw(__pyx_PyAsyncGenAThrow *o, PyObject *args)
879
+ {
880
+ PyObject *retval;
881
+
882
+ if (unlikely(o->agt_state == __PYX_AWAITABLE_STATE_CLOSED)) {
883
+ PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_CLOSE_MSG);
884
+ return NULL;
885
+ }
886
+
887
+ retval = __Pyx_Coroutine_Throw((PyObject*)o->agt_gen, args);
888
+ if (o->agt_args) {
889
+ return __Pyx_async_gen_unwrap_value(o->agt_gen, retval, 0);
890
+ } else {
891
+ // aclose() mode
892
+ PyObject *exc_type;
893
+ if (unlikely(retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval))) {
894
+ o->agt_gen->ag_running_async = 0;
895
+ o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
896
+ Py_DECREF(retval);
897
+ PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG);
898
+ return NULL;
899
+ }
900
+ exc_type = PyErr_Occurred();
901
+ if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, PyExc_StopAsyncIteration, PyExc_GeneratorExit)) {
902
+ // when aclose() is called we don't want to propagate
903
+ // StopAsyncIteration or GeneratorExit; just raise
904
+ // StopIteration, signalling that this 'aclose()' await
905
+ // is done.
906
+ PyErr_Clear();
907
+ PyErr_SetNone(PyExc_StopIteration);
908
+ }
909
+ return retval;
910
+ }
911
+ }
912
+
913
+
914
+ static PyObject *
915
+ __Pyx_async_gen_athrow_iternext(__pyx_PyAsyncGenAThrow *o)
916
+ {
917
+ return __Pyx_async_gen_athrow_send_impl(o, Py_None, 1);
918
+ }
919
+
920
+
921
+ static PyObject *
922
+ __Pyx_async_gen_athrow_close(PyObject *g, PyObject *args)
923
+ {
924
+ __pyx_PyAsyncGenAThrow *o = (__pyx_PyAsyncGenAThrow*) g;
925
+ CYTHON_UNUSED_VAR(args);
926
+ o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
927
+ Py_RETURN_NONE;
928
+ }
929
+
930
+
931
+ static PyMethodDef __Pyx_async_gen_athrow_methods[] = {
932
+ {"send", (PyCFunction)__Pyx_async_gen_athrow_send, METH_O, __Pyx_async_gen_send_doc},
933
+ {"throw", (PyCFunction)__Pyx_async_gen_athrow_throw, METH_VARARGS, __Pyx_async_gen_throw_doc},
934
+ {"close", (PyCFunction)__Pyx_async_gen_athrow_close, METH_NOARGS, __Pyx_async_gen_close_doc},
935
+ {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc},
936
+ {0, 0, 0, 0} /* Sentinel */
937
+ };
938
+
939
+
940
+ static PyType_Slot __pyx__PyAsyncGenAThrowType_slots[] = {
941
+ {Py_tp_dealloc, (void *)__Pyx_async_gen_athrow_dealloc},
942
+ {Py_am_await, (void *)PyObject_SelfIter},
943
+ {Py_tp_traverse, (void *)__Pyx_async_gen_athrow_traverse},
944
+ {Py_tp_iter, (void *)PyObject_SelfIter},
945
+ {Py_tp_iternext, (void *)__Pyx_async_gen_athrow_iternext},
946
+ {Py_tp_methods, (void *)__Pyx_async_gen_athrow_methods},
947
+ {Py_tp_getattro, (void *)PyObject_GenericGetAttr},
948
+ {0, 0},
949
+ };
950
+
951
+ static PyType_Spec __pyx__PyAsyncGenAThrowType_spec = {
952
+ __PYX_TYPE_MODULE_PREFIX "async_generator_athrow",
953
+ sizeof(__pyx_PyAsyncGenAThrow),
954
+ 0,
955
+ #if PY_VERSION_HEX >= 0x030A0000
956
+ Py_TPFLAGS_IMMUTABLETYPE |
957
+ #endif
958
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
959
+ __pyx__PyAsyncGenAThrowType_slots
960
+ };
961
+
962
+
963
+ static PyObject *
964
+ __Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *gen, PyObject *args)
965
+ {
966
+ __pyx_PyAsyncGenAThrow *o;
967
+ o = PyObject_GC_New(__pyx_PyAsyncGenAThrow, CGLOBAL(__pyx__PyAsyncGenAThrowType));
968
+ if (unlikely(o == NULL)) {
969
+ return NULL;
970
+ }
971
+ o->agt_gen = gen;
972
+ o->agt_args = args;
973
+ o->agt_state = __PYX_AWAITABLE_STATE_INIT;
974
+ Py_INCREF((PyObject*)gen);
975
+ Py_XINCREF(args);
976
+ PyObject_GC_Track((PyObject*)o);
977
+ return (PyObject*)o;
978
+ }
979
+
980
+
981
+ /* ---------- global type sharing ------------ */
982
+
983
+ static int __pyx_AsyncGen_init(PyObject *module) {
984
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
985
+ mstate->__pyx_AsyncGenType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_AsyncGenType_spec, NULL);
986
+ if (unlikely(!mstate->__pyx_AsyncGenType))
987
+ return -1;
988
+
989
+ mstate->__pyx__PyAsyncGenAThrowType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx__PyAsyncGenAThrowType_spec, NULL);
990
+ if (unlikely(!mstate->__pyx__PyAsyncGenAThrowType))
991
+ return -1;
992
+
993
+ mstate->__pyx__PyAsyncGenWrappedValueType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx__PyAsyncGenWrappedValueType_spec, NULL);
994
+ if (unlikely(!mstate->__pyx__PyAsyncGenWrappedValueType))
995
+ return -1;
996
+
997
+ mstate->__pyx__PyAsyncGenASendType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx__PyAsyncGenASendType_spec, NULL);
998
+ if (unlikely(!mstate->__pyx__PyAsyncGenASendType))
999
+ return -1;
1000
+
1001
+ return 0;
1002
+ }