Cython 3.3.0__cp315-cp315-win_amd64.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 (339) hide show
  1. Cython/Build/BuildExecutable.py +156 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +349 -0
  4. Cython/Build/Dependencies.py +1281 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +467 -0
  7. Cython/Build/IpythonMagic.py +559 -0
  8. Cython/Build/SharedModule.py +165 -0
  9. Cython/Build/Tests/TestCyCache.py +195 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +480 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +303 -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 +11 -0
  18. Cython/CodeWriter.py +825 -0
  19. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  20. Cython/Compiler/Annotate.py +328 -0
  21. Cython/Compiler/AutoDocTransforms.py +320 -0
  22. Cython/Compiler/Buffer.py +679 -0
  23. Cython/Compiler/Builtin.py +1102 -0
  24. Cython/Compiler/CmdLine.py +373 -0
  25. Cython/Compiler/Code.cp315-win_amd64.pyd +0 -0
  26. Cython/Compiler/Code.pxd +154 -0
  27. Cython/Compiler/Code.py +3760 -0
  28. Cython/Compiler/CodeGeneration.py +33 -0
  29. Cython/Compiler/CythonScope.py +208 -0
  30. Cython/Compiler/Dataclass.py +890 -0
  31. Cython/Compiler/DebugFlags.py +24 -0
  32. Cython/Compiler/Errors.py +310 -0
  33. Cython/Compiler/ExprNodes.py +16273 -0
  34. Cython/Compiler/FlowControl.cp315-win_amd64.pyd +0 -0
  35. Cython/Compiler/FlowControl.pxd +112 -0
  36. Cython/Compiler/FlowControl.py +1573 -0
  37. Cython/Compiler/FusedNode.cp315-win_amd64.pyd +0 -0
  38. Cython/Compiler/FusedNode.py +978 -0
  39. Cython/Compiler/Future.py +16 -0
  40. Cython/Compiler/Interpreter.py +57 -0
  41. Cython/Compiler/Lexicon.py +422 -0
  42. Cython/Compiler/LineTable.cp315-win_amd64.pyd +0 -0
  43. Cython/Compiler/LineTable.py +114 -0
  44. Cython/Compiler/Main.py +856 -0
  45. Cython/Compiler/MatchCaseNodes.py +2200 -0
  46. Cython/Compiler/MemoryView.py +930 -0
  47. Cython/Compiler/ModuleNode.py +4548 -0
  48. Cython/Compiler/Naming.py +370 -0
  49. Cython/Compiler/Nodes.py +11304 -0
  50. Cython/Compiler/Optimize.py +5564 -0
  51. Cython/Compiler/Options.py +840 -0
  52. Cython/Compiler/ParseTreeTransforms.pxd +80 -0
  53. Cython/Compiler/ParseTreeTransforms.py +4808 -0
  54. Cython/Compiler/Parsing.cp315-win_amd64.pyd +0 -0
  55. Cython/Compiler/Parsing.pxd +9 -0
  56. Cython/Compiler/Parsing.py +4809 -0
  57. Cython/Compiler/Pipeline.py +439 -0
  58. Cython/Compiler/PyrexTypes.py +6588 -0
  59. Cython/Compiler/Pythran.py +232 -0
  60. Cython/Compiler/Scanning.cp315-win_amd64.pyd +0 -0
  61. Cython/Compiler/Scanning.pxd +70 -0
  62. Cython/Compiler/Scanning.py +720 -0
  63. Cython/Compiler/StringEncoding.cp315-win_amd64.pyd +0 -0
  64. Cython/Compiler/StringEncoding.py +354 -0
  65. Cython/Compiler/Symtab.py +3121 -0
  66. Cython/Compiler/Tests/TestBuffer.py +105 -0
  67. Cython/Compiler/Tests/TestBuiltin.py +196 -0
  68. Cython/Compiler/Tests/TestCmdLine.py +652 -0
  69. Cython/Compiler/Tests/TestCode.py +145 -0
  70. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  71. Cython/Compiler/Tests/TestGrammar.py +202 -0
  72. Cython/Compiler/Tests/TestMemView.py +71 -0
  73. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  74. Cython/Compiler/Tests/TestScanning.py +132 -0
  75. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  76. Cython/Compiler/Tests/TestStringEncoding.py +20 -0
  77. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  78. Cython/Compiler/Tests/TestTreePath.py +103 -0
  79. Cython/Compiler/Tests/TestTypes.py +119 -0
  80. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  81. Cython/Compiler/Tests/TestVisitor.py +119 -0
  82. Cython/Compiler/Tests/Utils.py +36 -0
  83. Cython/Compiler/Tests/__init__.py +1 -0
  84. Cython/Compiler/TreeFragment.py +279 -0
  85. Cython/Compiler/TreePath.py +303 -0
  86. Cython/Compiler/TypeInference.py +611 -0
  87. Cython/Compiler/TypeSlots.py +1329 -0
  88. Cython/Compiler/UFuncs.py +317 -0
  89. Cython/Compiler/UtilNodes.py +389 -0
  90. Cython/Compiler/UtilityCode.py +354 -0
  91. Cython/Compiler/Version.py +8 -0
  92. Cython/Compiler/Visitor.cp315-win_amd64.pyd +0 -0
  93. Cython/Compiler/Visitor.pxd +52 -0
  94. Cython/Compiler/Visitor.py +914 -0
  95. Cython/Compiler/__init__.py +1 -0
  96. Cython/Coverage.py +448 -0
  97. Cython/Debugger/Cygdb.py +214 -0
  98. Cython/Debugger/DebugWriter.py +82 -0
  99. Cython/Debugger/Tests/TestLibCython.py +280 -0
  100. Cython/Debugger/Tests/__init__.py +1 -0
  101. Cython/Debugger/Tests/cfuncs.c +8 -0
  102. Cython/Debugger/Tests/codefile +49 -0
  103. Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
  104. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  105. Cython/Debugger/__init__.py +1 -0
  106. Cython/Debugger/libcython.py +1548 -0
  107. Cython/Debugger/libpython.py +2821 -0
  108. Cython/Debugging.py +20 -0
  109. Cython/Distutils/__init__.py +2 -0
  110. Cython/Distutils/build_ext.py +143 -0
  111. Cython/Distutils/extension.py +96 -0
  112. Cython/Distutils/old_build_ext.py +351 -0
  113. Cython/Includes/cpython/__init__.pxd +173 -0
  114. Cython/Includes/cpython/array.pxd +152 -0
  115. Cython/Includes/cpython/bool.pxd +37 -0
  116. Cython/Includes/cpython/buffer.pxd +112 -0
  117. Cython/Includes/cpython/bytearray.pxd +33 -0
  118. Cython/Includes/cpython/bytes.pxd +200 -0
  119. Cython/Includes/cpython/cellobject.pxd +35 -0
  120. Cython/Includes/cpython/ceval.pxd +8 -0
  121. Cython/Includes/cpython/codecs.pxd +121 -0
  122. Cython/Includes/cpython/complex.pxd +60 -0
  123. Cython/Includes/cpython/contextvars.pxd +145 -0
  124. Cython/Includes/cpython/conversion.pxd +36 -0
  125. Cython/Includes/cpython/datetime.pxd +395 -0
  126. Cython/Includes/cpython/descr.pxd +26 -0
  127. Cython/Includes/cpython/dict.pxd +268 -0
  128. Cython/Includes/cpython/exc.pxd +263 -0
  129. Cython/Includes/cpython/fileobject.pxd +57 -0
  130. Cython/Includes/cpython/float.pxd +56 -0
  131. Cython/Includes/cpython/frozendict.pxd +37 -0
  132. Cython/Includes/cpython/function.pxd +65 -0
  133. Cython/Includes/cpython/genobject.pxd +25 -0
  134. Cython/Includes/cpython/getargs.pxd +12 -0
  135. Cython/Includes/cpython/instance.pxd +25 -0
  136. Cython/Includes/cpython/iterator.pxd +36 -0
  137. Cython/Includes/cpython/iterobject.pxd +24 -0
  138. Cython/Includes/cpython/list.pxd +144 -0
  139. Cython/Includes/cpython/long.pxd +180 -0
  140. Cython/Includes/cpython/longintrepr.pxd +14 -0
  141. Cython/Includes/cpython/mapping.pxd +63 -0
  142. Cython/Includes/cpython/marshal.pxd +66 -0
  143. Cython/Includes/cpython/mem.pxd +120 -0
  144. Cython/Includes/cpython/memoryview.pxd +50 -0
  145. Cython/Includes/cpython/method.pxd +49 -0
  146. Cython/Includes/cpython/module.pxd +208 -0
  147. Cython/Includes/cpython/number.pxd +258 -0
  148. Cython/Includes/cpython/object.pxd +430 -0
  149. Cython/Includes/cpython/pycapsule.pxd +143 -0
  150. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  151. Cython/Includes/cpython/pyport.pxd +8 -0
  152. Cython/Includes/cpython/pystate.pxd +95 -0
  153. Cython/Includes/cpython/pythread.pxd +53 -0
  154. Cython/Includes/cpython/ref.pxd +141 -0
  155. Cython/Includes/cpython/sentinel.pxd +17 -0
  156. Cython/Includes/cpython/sequence.pxd +134 -0
  157. Cython/Includes/cpython/set.pxd +119 -0
  158. Cython/Includes/cpython/slice.pxd +70 -0
  159. Cython/Includes/cpython/time.pxd +129 -0
  160. Cython/Includes/cpython/tuple.pxd +72 -0
  161. Cython/Includes/cpython/type.pxd +146 -0
  162. Cython/Includes/cpython/unicode.pxd +639 -0
  163. Cython/Includes/cpython/version.pxd +32 -0
  164. Cython/Includes/cpython/weakref.pxd +78 -0
  165. Cython/Includes/libc/__init__.pxd +1 -0
  166. Cython/Includes/libc/complex.pxd +35 -0
  167. Cython/Includes/libc/errno.pxd +127 -0
  168. Cython/Includes/libc/float.pxd +43 -0
  169. Cython/Includes/libc/limits.pxd +28 -0
  170. Cython/Includes/libc/locale.pxd +46 -0
  171. Cython/Includes/libc/math.pxd +209 -0
  172. Cython/Includes/libc/setjmp.pxd +10 -0
  173. Cython/Includes/libc/signal.pxd +64 -0
  174. Cython/Includes/libc/stddef.pxd +9 -0
  175. Cython/Includes/libc/stdint.pxd +105 -0
  176. Cython/Includes/libc/stdio.pxd +80 -0
  177. Cython/Includes/libc/stdlib.pxd +72 -0
  178. Cython/Includes/libc/string.pxd +50 -0
  179. Cython/Includes/libc/threads.pxd +234 -0
  180. Cython/Includes/libc/time.pxd +52 -0
  181. Cython/Includes/libcpp/__init__.pxd +4 -0
  182. Cython/Includes/libcpp/algorithm.pxd +320 -0
  183. Cython/Includes/libcpp/any.pxd +16 -0
  184. Cython/Includes/libcpp/atomic.pxd +59 -0
  185. Cython/Includes/libcpp/barrier.pxd +22 -0
  186. Cython/Includes/libcpp/bit.pxd +29 -0
  187. Cython/Includes/libcpp/cast.pxd +12 -0
  188. Cython/Includes/libcpp/cmath.pxd +518 -0
  189. Cython/Includes/libcpp/complex.pxd +106 -0
  190. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  191. Cython/Includes/libcpp/deque.pxd +165 -0
  192. Cython/Includes/libcpp/exception.pxd +216 -0
  193. Cython/Includes/libcpp/execution.pxd +15 -0
  194. Cython/Includes/libcpp/forward_list.pxd +63 -0
  195. Cython/Includes/libcpp/functional.pxd +26 -0
  196. Cython/Includes/libcpp/future.pxd +103 -0
  197. Cython/Includes/libcpp/iterator.pxd +34 -0
  198. Cython/Includes/libcpp/latch.pxd +17 -0
  199. Cython/Includes/libcpp/limits.pxd +61 -0
  200. Cython/Includes/libcpp/list.pxd +117 -0
  201. Cython/Includes/libcpp/map.pxd +252 -0
  202. Cython/Includes/libcpp/memory.pxd +115 -0
  203. Cython/Includes/libcpp/mutex.pxd +387 -0
  204. Cython/Includes/libcpp/numbers.pxd +15 -0
  205. Cython/Includes/libcpp/numeric.pxd +131 -0
  206. Cython/Includes/libcpp/optional.pxd +34 -0
  207. Cython/Includes/libcpp/pair.pxd +1 -0
  208. Cython/Includes/libcpp/queue.pxd +25 -0
  209. Cython/Includes/libcpp/random.pxd +166 -0
  210. Cython/Includes/libcpp/semaphore.pxd +43 -0
  211. Cython/Includes/libcpp/set.pxd +228 -0
  212. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  213. Cython/Includes/libcpp/span.pxd +87 -0
  214. Cython/Includes/libcpp/stack.pxd +11 -0
  215. Cython/Includes/libcpp/stop_token.pxd +117 -0
  216. Cython/Includes/libcpp/string.pxd +355 -0
  217. Cython/Includes/libcpp/string_view.pxd +183 -0
  218. Cython/Includes/libcpp/typeindex.pxd +15 -0
  219. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  220. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  221. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  222. Cython/Includes/libcpp/utility.pxd +30 -0
  223. Cython/Includes/libcpp/vector.pxd +186 -0
  224. Cython/Includes/numpy/math.pxd +150 -0
  225. Cython/Includes/openmp.pxd +50 -0
  226. Cython/Includes/posix/__init__.pxd +1 -0
  227. Cython/Includes/posix/dlfcn.pxd +14 -0
  228. Cython/Includes/posix/fcntl.pxd +86 -0
  229. Cython/Includes/posix/ioctl.pxd +4 -0
  230. Cython/Includes/posix/mman.pxd +101 -0
  231. Cython/Includes/posix/resource.pxd +57 -0
  232. Cython/Includes/posix/select.pxd +21 -0
  233. Cython/Includes/posix/signal.pxd +73 -0
  234. Cython/Includes/posix/stat.pxd +98 -0
  235. Cython/Includes/posix/stdio.pxd +37 -0
  236. Cython/Includes/posix/stdlib.pxd +29 -0
  237. Cython/Includes/posix/strings.pxd +9 -0
  238. Cython/Includes/posix/time.pxd +71 -0
  239. Cython/Includes/posix/types.pxd +30 -0
  240. Cython/Includes/posix/uio.pxd +26 -0
  241. Cython/Includes/posix/unistd.pxd +271 -0
  242. Cython/Includes/posix/wait.pxd +38 -0
  243. Cython/LZSS.cp315-win_amd64.pyd +0 -0
  244. Cython/LZSS.py +184 -0
  245. Cython/Plex/Actions.cp315-win_amd64.pyd +0 -0
  246. Cython/Plex/Actions.pxd +24 -0
  247. Cython/Plex/Actions.py +119 -0
  248. Cython/Plex/DFA.cp315-win_amd64.pyd +0 -0
  249. Cython/Plex/DFA.pxd +14 -0
  250. Cython/Plex/DFA.py +164 -0
  251. Cython/Plex/Errors.py +48 -0
  252. Cython/Plex/Lexicons.py +178 -0
  253. Cython/Plex/Machines.cp315-win_amd64.pyd +0 -0
  254. Cython/Plex/Machines.pxd +36 -0
  255. Cython/Plex/Machines.py +238 -0
  256. Cython/Plex/Regexps.py +535 -0
  257. Cython/Plex/Scanners.cp315-win_amd64.pyd +0 -0
  258. Cython/Plex/Scanners.pxd +45 -0
  259. Cython/Plex/Scanners.py +328 -0
  260. Cython/Plex/Transitions.cp315-win_amd64.pyd +0 -0
  261. Cython/Plex/Transitions.pxd +14 -0
  262. Cython/Plex/Transitions.py +239 -0
  263. Cython/Plex/__init__.py +34 -0
  264. Cython/Runtime/__init__.py +1 -0
  265. Cython/Runtime/refnanny.cp315-win_amd64.pyd +0 -0
  266. Cython/Runtime/refnanny.pyx +237 -0
  267. Cython/Shadow.py +1174 -0
  268. Cython/StringIOTree.cp315-win_amd64.pyd +0 -0
  269. Cython/StringIOTree.py +169 -0
  270. Cython/Tempita/__init__.py +4 -0
  271. Cython/Tempita/_looper.py +154 -0
  272. Cython/Tempita/_tempita.cp315-win_amd64.pyd +0 -0
  273. Cython/Tempita/_tempita.py +1087 -0
  274. Cython/TestUtils.py +472 -0
  275. Cython/Tests/TestCodeWriter.py +128 -0
  276. Cython/Tests/TestCythonUtils.py +202 -0
  277. Cython/Tests/TestJediTyper.py +223 -0
  278. Cython/Tests/TestShadow.py +125 -0
  279. Cython/Tests/TestStringIOTree.py +68 -0
  280. Cython/Tests/TestTestUtils.py +89 -0
  281. Cython/Tests/__init__.py +1 -0
  282. Cython/Tests/xmlrunner.py +390 -0
  283. Cython/Utility/AsyncGen.c +1152 -0
  284. Cython/Utility/Buffer.c +866 -0
  285. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  286. Cython/Utility/Builtins.c +1068 -0
  287. Cython/Utility/CConvert.pyx +153 -0
  288. Cython/Utility/CMath.c +104 -0
  289. Cython/Utility/CommonStructures.c +244 -0
  290. Cython/Utility/Complex.c +378 -0
  291. Cython/Utility/Coroutine.c +2344 -0
  292. Cython/Utility/CpdefEnums.pyx +119 -0
  293. Cython/Utility/CppConvert.pyx +282 -0
  294. Cython/Utility/CppSupport.cpp +151 -0
  295. Cython/Utility/CythonFunction.c +2185 -0
  296. Cython/Utility/Dataclasses.c +101 -0
  297. Cython/Utility/Embed.c +129 -0
  298. Cython/Utility/Exceptions.c +1331 -0
  299. Cython/Utility/Exceptions_Cy.pyx +109 -0
  300. Cython/Utility/ExtensionTypes.c +1199 -0
  301. Cython/Utility/FunctionArguments.c +1052 -0
  302. Cython/Utility/FusedFunction.pyx +44 -0
  303. Cython/Utility/ImportExport.c +972 -0
  304. Cython/Utility/MatchCase.c +981 -0
  305. Cython/Utility/MatchCase_Cy.pyx +12 -0
  306. Cython/Utility/MemoryView.pxd +108 -0
  307. Cython/Utility/MemoryView.pyx +1499 -0
  308. Cython/Utility/MemoryView_C.c +1056 -0
  309. Cython/Utility/ModuleSetupCode.c +3319 -0
  310. Cython/Utility/NumpyImportArray.c +46 -0
  311. Cython/Utility/ObjectHandling.c +3404 -0
  312. Cython/Utility/Optimize.c +2564 -0
  313. Cython/Utility/Overflow.c +378 -0
  314. Cython/Utility/Profile.c +736 -0
  315. Cython/Utility/StringTools.c +1534 -0
  316. Cython/Utility/Synchronization.c +438 -0
  317. Cython/Utility/TString.c +369 -0
  318. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  319. Cython/Utility/TestCythonScope.pyx +75 -0
  320. Cython/Utility/TestUtilityLoader.c +12 -0
  321. Cython/Utility/TypeConversion.c +1588 -0
  322. Cython/Utility/UFuncs.pyx +50 -0
  323. Cython/Utility/UFuncs_C.c +89 -0
  324. Cython/Utility/__init__.py +28 -0
  325. Cython/Utility/arrayarray.h +172 -0
  326. Cython/Utils.cp315-win_amd64.pyd +0 -0
  327. Cython/Utils.py +680 -0
  328. Cython/__init__.py +12 -0
  329. Cython/_shared.cp315-win_amd64.pyd +0 -0
  330. Cython/py.typed +0 -0
  331. cython-3.3.0.dist-info/METADATA +555 -0
  332. cython-3.3.0.dist-info/RECORD +339 -0
  333. cython-3.3.0.dist-info/WHEEL +5 -0
  334. cython-3.3.0.dist-info/entry_points.txt +4 -0
  335. cython-3.3.0.dist-info/top_level.txt +3 -0
  336. cython.py +29 -0
  337. pyximport/__init__.py +4 -0
  338. pyximport/pyxbuild.py +160 -0
  339. pyximport/pyximport.py +482 -0
@@ -0,0 +1,2344 @@
1
+ // ### CPython revisions to investigate for potential changes:
2
+
3
+ // 2f180ce2cb6 (bpo-44530: Add co_qualname field to PyCodeObject (GH-26941))
4
+ // a4760cc32d9 (bpo-42747: Remove Py_TPFLAGS_HAVE_AM_SEND and make Py_TPFLAGS_HAVE_VERSION_TAG no-op (GH-27260))
5
+ // ae0a2b75625 (bpo-44590: Lazily allocate frame objects (GH-27077))
6
+ // 69806b9516d (bpo-46009: Do not exhaust generator when send() method raises (GH-29986))
7
+ // b04dfbbe4bd (bpo-46409: Make generators in bytecode (GH-30633) -- ".gi_suspended")
8
+ // 304197b3820 (bpo-46944: use FASTCALL calling convention in generator.throw (GH-31723))
9
+ // 8be7c2bc5ad (bpo-14911: Corrected generator.throw() documentation (GH-32207))
10
+ // 5bfb3c372bd (GH-90997: Wrap yield from/await in a virtual try/except StopIteration (GH-96010))
11
+ // 83a3de4e063 (gh-96348: Deprecate the 3-arg signature of coroutine.throw and generator.throw (GH-96428))
12
+ // f4adb975061 (GH-96793: Implement PEP 479 in bytecode. (GH-99006))
13
+ // f02fa64bf2d (GH-100762: Don't call `gen.throw()` in `gen.close()`, unless necessary. (GH-101013))
14
+ // 11a2c6ce516 (gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Objects/) (#102218))
15
+ // ced13c96a4e (gh-79940: add introspection API for asynchronous generators to `inspect` module (#11590) -- ".ag_suspended")
16
+ // d56c933992c (gh-104770: Let generator.close() return value (#104771))
17
+ // 7fc542c88dc (GH-89091: raise `RuntimeWarning` for unawaited async generator methods (#104611))
18
+ // 0d30a5a4096 (GH-100964: Break cycles involving exception state when returning from generator (GH-107563))
19
+ // 7d369d471cf (GH-117536: GH-117894: fix athrow().throw(...) unawaited warning (GH-117851))
20
+ // fc7e1aa3c00 (GH-117881: fix athrow().throw()/asend().throw() concurrent access (GH-117882))
21
+ // e5c699280de (GH-117714: implement athrow().close() and asend().close() using throw (GH-117906))
22
+ // 2c7209a3bdf (gh-114091: Reword error message for unawaitable types (#114090))
23
+
24
+
25
+ //////////////////// CoroutineSetYieldFrom ////////////////////
26
+
27
+ static void
28
+ __Pyx_Coroutine_Set_Owned_Yield_From(__pyx_CoroutineObject *gen, PyObject *yf) {
29
+ // NOTE: steals a reference to yf by transferring it to 'gen->yieldfrom' !
30
+ assert (!gen->yieldfrom);
31
+ #if CYTHON_USE_AM_SEND
32
+ assert (!gen->yieldfrom_am_send);
33
+ #if PY_VERSION_HEX < 0x030A00F0
34
+ if (__Pyx_PyType_HasFeature(Py_TYPE(yf), __Pyx_TPFLAGS_HAVE_AM_SEND))
35
+ #endif
36
+ {
37
+ __Pyx_pyiter_sendfunc am_send;
38
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
39
+ am_send = __Pyx_PyObject_TryGetSubSlot(yf, tp_as_async, am_send, __Pyx_pyiter_sendfunc);
40
+ #else
41
+ __Pyx_PyAsyncMethodsStruct* tp_as_async = (__Pyx_PyAsyncMethodsStruct*) Py_TYPE(yf)->tp_as_async;
42
+ am_send = tp_as_async ? tp_as_async->am_send : NULL;
43
+ #endif
44
+ if (likely(am_send)) {
45
+ // Keep a direct reference to am->am_send, if provided.
46
+ gen->yieldfrom_am_send = am_send;
47
+ }
48
+ }
49
+ #endif
50
+ gen->yieldfrom = yf;
51
+ }
52
+
53
+
54
+ //////////////////// GeneratorYieldFrom.proto ////////////////////
55
+
56
+ static CYTHON_INLINE __Pyx_PySendResult __Pyx_Generator_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval);
57
+
58
+ //////////////////// GeneratorYieldFrom ////////////////////
59
+ //@requires: Generator
60
+ //@requires: CoroutineSetYieldFrom
61
+ //@requires: ObjectHandling.c::IterNextPlain
62
+ //@requires: ObjectHandling.c::RaiseErrorWithObjectType
63
+
64
+ #if CYTHON_USE_TYPE_SLOTS
65
+ static void __Pyx_PyIter_CheckErrorAndDecref(PyObject *source) {
66
+ __Pyx_RaiseTypeErrorWithObjectType(
67
+ "iter() returned non-iterator of type '" __Pyx_FMT_TYPENAME "'", source);
68
+ Py_DECREF(source);
69
+ }
70
+ #endif
71
+
72
+ static CYTHON_INLINE __Pyx_PySendResult __Pyx_Generator_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval) {
73
+ PyObject *source_gen;
74
+ __Pyx_PySendResult result;
75
+ #ifdef __Pyx_Coroutine_USED
76
+ if (__Pyx_Coroutine_Check(source)) {
77
+ // TODO: this should only happen for types.coroutine()ed generators, but we can't determine that here
78
+ Py_INCREF(source);
79
+ source_gen = source;
80
+ result = __Pyx_Coroutine_AmSend(source, Py_None, retval);
81
+ } else
82
+ #endif
83
+ {
84
+ #if CYTHON_USE_TYPE_SLOTS
85
+ if (likely(Py_TYPE(source)->tp_iter)) {
86
+ source_gen = Py_TYPE(source)->tp_iter(source);
87
+ if (unlikely(!source_gen)) {
88
+ *retval = NULL;
89
+ return PYGEN_ERROR;
90
+ }
91
+ if (unlikely(!PyIter_Check(source_gen))) {
92
+ __Pyx_PyIter_CheckErrorAndDecref(source_gen);
93
+ *retval = NULL;
94
+ return PYGEN_ERROR;
95
+ }
96
+ } else
97
+ // CPython also allows non-iterable sequences to be iterated over
98
+ #endif
99
+ {
100
+ source_gen = PyObject_GetIter(source);
101
+ if (unlikely(!source_gen)) {
102
+ *retval = NULL;
103
+ return PYGEN_ERROR;
104
+ }
105
+ }
106
+ // source_gen is now the iterator, make the first next() call
107
+ *retval = __Pyx_PyIter_Next_Plain(source_gen);
108
+ result = __Pyx_Coroutine_status_from_result(retval);
109
+ }
110
+ if (likely(result == PYGEN_NEXT)) {
111
+ __Pyx_Coroutine_Set_Owned_Yield_From(gen, source_gen);
112
+ return PYGEN_NEXT;
113
+ }
114
+ Py_DECREF(source_gen);
115
+ return result;
116
+ }
117
+
118
+
119
+ //////////////////// CoroutineYieldFrom.proto ////////////////////
120
+
121
+ static CYTHON_INLINE __Pyx_PySendResult __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval); /*proto*/
122
+
123
+ //////////////////// CoroutineYieldFrom ////////////////////
124
+ //@requires: Coroutine
125
+ //@requires: GetAwaitIter
126
+ //@requires: CoroutineSetYieldFrom
127
+ //@requires: ObjectHandling.c::IterNextPlain
128
+
129
+ static __Pyx_PySendResult __Pyx_Coroutine_Yield_From_Coroutine(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval) {
130
+ __Pyx_PySendResult result;
131
+ if (unlikely(((__pyx_CoroutineObject*)source)->yieldfrom)) {
132
+ PyErr_SetString(
133
+ PyExc_RuntimeError,
134
+ "coroutine is being awaited already");
135
+ return PYGEN_ERROR;
136
+ }
137
+ result = __Pyx_Coroutine_AmSend(source, Py_None, retval);
138
+ if (result == PYGEN_NEXT) {
139
+ Py_INCREF(source);
140
+ __Pyx_Coroutine_Set_Owned_Yield_From(gen, source);
141
+ }
142
+ return result;
143
+ }
144
+
145
+ static __Pyx_PySendResult __Pyx_Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval) {
146
+ __Pyx_PySendResult result;
147
+ PyObject *source_gen = NULL;
148
+
149
+ source_gen = __Pyx_Coroutine_GetAwaitableIter(source);
150
+ if (unlikely(!source_gen)) return PYGEN_ERROR;
151
+
152
+ // source_gen is now the iterator, make the first next() call
153
+ if (__Pyx_Coroutine_Check(source_gen)) {
154
+ result = __Pyx_Coroutine_Yield_From_Coroutine(gen, source_gen, retval);
155
+ Py_DECREF(source_gen);
156
+ return result;
157
+ }
158
+
159
+ *retval = __Pyx_PyIter_Next_Plain(source_gen);
160
+ if (*retval) {
161
+ __Pyx_Coroutine_Set_Owned_Yield_From(gen, source_gen);
162
+ return PYGEN_NEXT;
163
+ }
164
+
165
+ result = __Pyx_Coroutine_status_from_result(retval);
166
+ Py_XDECREF(source_gen);
167
+ return result;
168
+ }
169
+
170
+ static CYTHON_INLINE __Pyx_PySendResult __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval) {
171
+ if (__Pyx_Coroutine_Check(source)) {
172
+ return __Pyx_Coroutine_Yield_From_Coroutine(gen, source, retval);
173
+ }
174
+
175
+ #ifdef __Pyx_AsyncGen_USED
176
+ // Inlined "__pyx_PyAsyncGenASend" handling to avoid the series of generic calls.
177
+ if (__pyx_PyAsyncGenASend_CheckExact(source)) {
178
+ *retval = __Pyx_async_gen_asend_iternext(source);
179
+ if (*retval) {
180
+ Py_INCREF(source);
181
+ __Pyx_Coroutine_Set_Owned_Yield_From(gen, source);
182
+ return PYGEN_NEXT;
183
+ }
184
+ return __Pyx_Coroutine_status_from_result(retval);
185
+ }
186
+ #endif
187
+
188
+ return __Pyx_Coroutine_Yield_From_Generic(gen, source, retval);
189
+ }
190
+
191
+
192
+ //////////////////// GetAwaitIter.proto ////////////////////
193
+
194
+ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o); /*proto*/
195
+ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o); /*proto*/
196
+
197
+ //////////////////// GetAwaitIter ////////////////////
198
+ //@requires: ObjectHandling.c::PyObjectGetMethod
199
+ //@requires: ObjectHandling.c::PyObjectCallNoArg
200
+ //@requires: ObjectHandling.c::PyObjectCallOneArg
201
+ //@requires: ObjectHandling.c::RaiseErrorWithObjectType
202
+ //@requires: Coro_CheckExact
203
+
204
+ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
205
+ #ifdef __Pyx_Coroutine_USED
206
+ if (__Pyx_Coroutine_Check(o)) {
207
+ return __Pyx_NewRef(o);
208
+ }
209
+ #endif
210
+ return __Pyx__Coroutine_GetAwaitableIter(o);
211
+ }
212
+
213
+
214
+ static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
215
+ #if (PY_VERSION_HEX < 0x030d0000 || defined(_PyErr_FormatFromCause)) && !CYTHON_COMPILING_IN_LIMITED_API
216
+ __Pyx_TypeName source_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(source));
217
+ _PyErr_FormatFromCause(PyExc_TypeError,
218
+ "'async for' received an invalid object from __anext__: " __Pyx_FMT_TYPENAME, source_type_name);
219
+ __Pyx_DECREF_TypeName(source_type_name);
220
+
221
+ #else
222
+ PyObject *exc, *val, *val2, *tb;
223
+ assert(PyErr_Occurred());
224
+ __Pyx_PyErr_FetchException(&exc, &val, &tb);
225
+ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
226
+ PyErr_NormalizeException(&exc, &val, &tb);
227
+ if (tb != NULL) {
228
+ PyException_SetTraceback(val, tb);
229
+ Py_DECREF(tb);
230
+ }
231
+ Py_DECREF(exc);
232
+ #endif
233
+ assert(!PyErr_Occurred());
234
+ __Pyx_RaiseTypeErrorWithObjectType(
235
+ "'async for' received an invalid object from __anext__: " __Pyx_FMT_TYPENAME, source);
236
+
237
+ __Pyx_PyErr_FetchException(&exc, &val2, &tb);
238
+ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
239
+ PyErr_NormalizeException(&exc, &val2, &tb);
240
+ #endif
241
+ Py_INCREF(val);
242
+ PyException_SetCause(val2, val);
243
+ PyException_SetContext(val2, val);
244
+ __Pyx_PyErr_RestoreException(exc, val2, tb);
245
+ #endif
246
+ }
247
+
248
+ // adapted from genobject.c in Py3.5
249
+ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
250
+ PyObject *res;
251
+ unaryfunc am_await;
252
+ am_await = __Pyx_PyObject_TryGetSubSlot(obj, tp_as_async, am_await, unaryfunc);
253
+ if (likely(am_await)) {
254
+ res = (*am_await)(obj);
255
+ } else
256
+ #if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE)
257
+ #if PY_VERSION_HEX >= 0x030C00A6
258
+ if (PyGen_CheckExact(obj) && (PyGen_GetCode((PyGenObject*)obj)->co_flags & CO_ITERABLE_COROUTINE))
259
+ #else
260
+ if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE)
261
+ #endif
262
+ {
263
+ // Python generator marked with "@types.coroutine" decorator
264
+ return __Pyx_NewRef(obj);
265
+ } else
266
+ #endif
267
+ {
268
+ #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || !CYTHON_COMPILING_IN_LIMITED_API)
269
+ PyObject *args[] = { obj };
270
+ res = PyObject_VectorcallMethod(PYIDENT("__await__"), args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
271
+ if (unlikely(!res)) {
272
+ // We need to distinguish between "doesn't have __await__" vs "__await__ failed"
273
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
274
+ PyObject *type, *value, *traceback;
275
+ __Pyx_PyErr_FetchException(&type, &value, &traceback);
276
+ int has_attr = PyObject_HasAttr(obj, PYIDENT("__await__"));
277
+ __Pyx_PyErr_RestoreException(type, value, traceback);
278
+ if (!has_attr) goto slot_error;
279
+ }
280
+ }
281
+ #else
282
+ PyObject *method = NULL;
283
+ int is_method = __Pyx_PyObject_GetMethod(obj, PYIDENT("__await__"), &method);
284
+ if (likely(is_method)) {
285
+ res = __Pyx_PyObject_CallOneArg(method, obj);
286
+ } else if (likely(method)) {
287
+ res = __Pyx_PyObject_CallNoArg(method);
288
+ } else
289
+ goto slot_error;
290
+ Py_DECREF(method);
291
+ #endif
292
+ }
293
+ if (unlikely(!res)) {
294
+ // surprisingly, CPython replaces the exception here...
295
+ __Pyx_Coroutine_AwaitableIterError(obj);
296
+ goto bad;
297
+ }
298
+ if (unlikely(!PyIter_Check(res))) {
299
+ __Pyx_RaiseTypeErrorWithObjectType(
300
+ "__await__() returned non-iterator of type '" __Pyx_FMT_TYPENAME "'", res);
301
+ Py_CLEAR(res);
302
+ } else {
303
+ int is_coroutine = 0;
304
+ #ifdef __Pyx_Coroutine_USED
305
+ is_coroutine |= __Pyx_Coroutine_Check(res);
306
+ #endif
307
+ is_coroutine |= __Pyx_PyCoro_CheckExact(res);
308
+ if (unlikely(is_coroutine)) {
309
+ /* __await__ must return an *iterator*, not
310
+ a coroutine or another awaitable (see PEP 492) */
311
+ PyErr_SetString(PyExc_TypeError,
312
+ "__await__() returned a coroutine");
313
+ Py_CLEAR(res);
314
+ }
315
+ }
316
+ return res;
317
+ slot_error:
318
+ __Pyx_RaiseTypeErrorWithObjectType(
319
+ "object " __Pyx_FMT_TYPENAME " can't be used in 'await' expression", obj);
320
+ bad:
321
+ return NULL;
322
+ }
323
+
324
+
325
+ //////////////////// AsyncIter.proto ////////////////////
326
+
327
+ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *o); /*proto*/
328
+ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*proto*/
329
+
330
+ //////////////////// AsyncIter ////////////////////
331
+ //@requires: ObjectHandling.c::RaiseErrorWithObjectType
332
+ //@requires: GetAwaitIter
333
+
334
+ static void __Pyx_Coroutine_GetAsyncIter_Fail(PyObject *obj) {
335
+ __Pyx_RaiseTypeErrorWithObjectType(
336
+ "'async for' requires an object with __aiter__ method, got " __Pyx_FMT_TYPENAME, obj);
337
+ }
338
+
339
+
340
+ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
341
+ #ifdef __Pyx_AsyncGen_USED
342
+ if (__Pyx_AsyncGen_CheckExact(obj)) {
343
+ return __Pyx_NewRef(obj);
344
+ }
345
+ #endif
346
+ {
347
+ unaryfunc am_aiter = __Pyx_PyObject_TryGetSubSlot(obj, tp_as_async, am_aiter, unaryfunc);
348
+ if (likely(am_aiter)) {
349
+ return (*am_aiter)(obj);
350
+ }
351
+ }
352
+ __Pyx_Coroutine_GetAsyncIter_Fail(obj);
353
+ return NULL;
354
+ }
355
+
356
+
357
+ static void __Pyx_Coroutine_AsyncIterNext_Fail(PyObject *obj) {
358
+ __Pyx_RaiseTypeErrorWithObjectType(
359
+ "'async for' requires an object with __anext__ method, got " __Pyx_FMT_TYPENAME, obj);
360
+ }
361
+
362
+
363
+ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
364
+ #ifdef __Pyx_AsyncGen_USED
365
+ if (__Pyx_AsyncGen_CheckExact(obj)) {
366
+ return __Pyx_async_gen_anext(obj);
367
+ }
368
+ #endif
369
+ {
370
+ unaryfunc am_anext = __Pyx_PyObject_TryGetSubSlot(obj, tp_as_async, am_anext, unaryfunc);
371
+ if (likely(am_anext)) {
372
+ return (*am_anext)(obj);
373
+ }
374
+ }
375
+ __Pyx_Coroutine_AsyncIterNext_Fail(obj);
376
+ return NULL;
377
+ }
378
+
379
+
380
+ //////////////////// pep479.proto ////////////////////
381
+
382
+ static void __Pyx_Generator_Replace_StopIteration(int in_async_gen); /*proto*/
383
+
384
+ //////////////////// pep479 ////////////////////
385
+ //@requires: Exceptions.c::GetException
386
+ //@requires: Exceptions.c::GivenExceptionMatches
387
+
388
+ static void __Pyx_Generator_Replace_StopIteration(int in_async_gen) {
389
+ PyObject *exc, *val, *tb, *cur_exc, *new_exc;
390
+ __Pyx_PyThreadState_declare
391
+ int is_async_stopiteration = 0;
392
+ CYTHON_MAYBE_UNUSED_VAR(in_async_gen);
393
+
394
+ __Pyx_PyThreadState_assign
395
+ cur_exc = __Pyx_PyErr_CurrentExceptionType();
396
+ if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) {
397
+ if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopAsyncIteration))) {
398
+ is_async_stopiteration = 1;
399
+ } else {
400
+ return;
401
+ }
402
+ }
403
+
404
+ // Explicitly chain the Stop(Async)Iteration by moving it to exc_info before creating the RuntimeError.
405
+ __Pyx_GetException(&exc, &val, &tb);
406
+ Py_XDECREF(exc);
407
+ Py_XDECREF(tb);
408
+ new_exc = PyObject_CallFunction(PyExc_RuntimeError, "s",
409
+ is_async_stopiteration ? "async generator raised StopAsyncIteration" :
410
+ in_async_gen ? "async generator raised StopIteration" :
411
+ "generator raised StopIteration");
412
+ if (!new_exc) {
413
+ Py_XDECREF(val);
414
+ return;
415
+ }
416
+ PyException_SetCause(new_exc, val); // steals ref to val
417
+ PyErr_SetObject(PyExc_RuntimeError, new_exc);
418
+ Py_DECREF(new_exc);
419
+ }
420
+
421
+
422
+ //////////////////// CoroutineBase.proto ////////////////////
423
+ //@substitute: naming
424
+
425
+ struct __pyx_CoroutineObject;
426
+ typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *);
427
+
428
+ #if CYTHON_USE_EXC_INFO_STACK
429
+ // See https://bugs.python.org/issue25612
430
+ #define __Pyx_ExcInfoStruct _PyErr_StackItem
431
+ #else
432
+ // Minimal replacement struct for Py<3.7, without the Py3.7 exception state stack.
433
+ typedef struct {
434
+ PyObject *exc_type;
435
+ PyObject *exc_value;
436
+ PyObject *exc_traceback;
437
+ } __Pyx_ExcInfoStruct;
438
+ #endif
439
+
440
+ typedef struct __pyx_CoroutineObject {
441
+ PyObject_HEAD
442
+ __pyx_coroutine_body_t body;
443
+ PyObject *closure;
444
+ __Pyx_ExcInfoStruct gi_exc_state;
445
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
446
+ PyObject *gi_weakreflist;
447
+ #endif
448
+ PyObject *classobj;
449
+ PyObject *yieldfrom;
450
+ // "yieldfrom_am_send" is always included to avoid changing the struct layout.
451
+ __Pyx_pyiter_sendfunc yieldfrom_am_send;
452
+ PyObject *gi_name;
453
+ PyObject *gi_qualname;
454
+ PyObject *gi_modulename;
455
+ PyObject *gi_code;
456
+ PyObject *gi_frame;
457
+ #if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
458
+ PyMonitoringState $monitoring_states_cname[__Pyx_MonitoringEventTypes_CyGen_count];
459
+ uint64_t $monitoring_version_cname;
460
+ #endif
461
+ int resume_label;
462
+ // is_running is the main thread-safety mechanism for coroutines, so treat it carefully
463
+ char is_running;
464
+ } __pyx_CoroutineObject;
465
+
466
+ static __pyx_CoroutineObject *__Pyx__Coroutine_New(
467
+ PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
468
+ PyObject *name, PyObject *qualname, PyObject *module_name); /*proto*/
469
+
470
+ static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
471
+ __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
472
+ PyObject *name, PyObject *qualname, PyObject *module_name); /*proto*/
473
+
474
+ static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
475
+ static int __Pyx_Coroutine_clear(PyObject *self); /*proto*/
476
+ static __Pyx_PySendResult __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval); /*proto*/
477
+ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); /*proto*/
478
+ static __Pyx_PySendResult __Pyx_Coroutine_Close(PyObject *self, PyObject **retval); /*proto*/
479
+ static PyObject *__Pyx_Coroutine_Throw(PyObject *gen,
480
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
481
+ PyObject *args
482
+ #else
483
+ PyObject *const *args, Py_ssize_t nargs
484
+ #endif
485
+ ); /*proto*/
486
+
487
+ // macros for exception state swapping instead of inline functions to make use of the local thread state context
488
+ #if CYTHON_USE_EXC_INFO_STACK
489
+ #define __Pyx_Coroutine_SwapException(self)
490
+ #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
491
+ #else
492
+ #define __Pyx_Coroutine_SwapException(self) { \
493
+ __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback); \
494
+ __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state); \
495
+ }
496
+ #define __Pyx_Coroutine_ResetAndClearException(self) { \
497
+ __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback); \
498
+ (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL; \
499
+ }
500
+ #endif
501
+
502
+ #if CYTHON_FAST_THREAD_STATE
503
+ #define __Pyx_PyGen_FetchStopIterationValue(pvalue) \
504
+ __Pyx_PyGen__FetchStopIterationValue($local_tstate_cname, pvalue)
505
+ #else
506
+ #define __Pyx_PyGen_FetchStopIterationValue(pvalue) \
507
+ __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
508
+ #endif
509
+ static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); /*proto*/
510
+ static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state); /*proto*/
511
+
512
+ static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen);
513
+ static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen);
514
+ static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen);
515
+ static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure);
516
+
517
+ #if __PYX_HAS_PY_AM_SEND == 2
518
+ static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send); /* proto */
519
+ #endif
520
+
521
+ static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg); /*proto*/
522
+
523
+ //////////////////// Coroutine.proto ////////////////////
524
+
525
+ #define __Pyx_Coroutine_USED
526
+ #define __Pyx_Coroutine_CheckExact(obj) Py_IS_TYPE(obj, CGLOBAL(__pyx_CoroutineType))
527
+ // __Pyx_Coroutine_Check(obj): see override for IterableCoroutine below
528
+ #define __Pyx_Coroutine_Check(obj) __Pyx_Coroutine_CheckExact(obj)
529
+ #define __Pyx_CoroutineAwait_CheckExact(obj) Py_IS_TYPE(obj, CGLOBAL(__pyx_CoroutineAwaitType))
530
+
531
+ #define __Pyx_Coroutine_New(body, code, closure, name, qualname, module_name) \
532
+ __Pyx__Coroutine_New(CGLOBAL(__pyx_CoroutineType), body, code, closure, name, qualname, module_name)
533
+
534
+ static int __pyx_Coroutine_init(PyObject *module); /*proto*/
535
+ static PyObject *__Pyx__Coroutine_await(PyObject *coroutine); /*proto*/
536
+
537
+ typedef struct {
538
+ PyObject_HEAD
539
+ PyObject *coroutine;
540
+ } __pyx_CoroutineAwaitObject;
541
+
542
+ static __Pyx_PySendResult __Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self); /*proto*/
543
+
544
+
545
+ //////////////////// Generator.proto ////////////////////
546
+
547
+ #define __Pyx_Generator_USED
548
+ #define __Pyx_Generator_CheckExact(obj) Py_IS_TYPE(obj, CGLOBAL(__pyx_GeneratorType))
549
+
550
+ #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name) \
551
+ __Pyx__Coroutine_New(CGLOBAL(__pyx_GeneratorType), body, code, closure, name, qualname, module_name)
552
+
553
+ static PyObject *__Pyx_Generator_Next(PyObject *self);
554
+ static int __pyx_Generator_init(PyObject *module); /*proto*/
555
+ static CYTHON_INLINE PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self); /*proto*/
556
+
557
+
558
+ //////////////////// AsyncGen ////////////////////
559
+ //@requires: AsyncGen.c::AsyncGenerator
560
+ // -> empty, only delegates to separate file
561
+
562
+
563
+ //////////////////// CoroutineBase ////////////////////
564
+ //@substitute: naming
565
+ //@requires: ReturnWithStopIteration
566
+ //@requires: Exceptions.c::PyErrFetchRestore
567
+ //@requires: Exceptions.c::PyThreadStateGet
568
+ //@requires: Exceptions.c::SwapException
569
+ //@requires: Exceptions.c::RaiseException
570
+ //@requires: Exceptions.c::SaveResetException
571
+ //@requires: Exceptions.c::GivenExceptionMatches
572
+ //@requires: ObjectHandling.c::PyObjectCallMethod1
573
+ //@requires: ObjectHandling.c::PyObjectCallNoArg
574
+ //@requires: ObjectHandling.c::PyObjectCallOneArg
575
+ //@requires: ObjectHandling.c::PyObjectFastCall
576
+ //@requires: ObjectHandling.c::PyObjectGetAttrStr
577
+ //@requires: ObjectHandling.c::PyObjectGetAttrStrNoError
578
+ //@requires: ObjectHandling.c::RaiseErrorWithObjectType
579
+ //@requires: ObjectHandling.c::IterNextPlain
580
+ //@requires: CommonStructures.c::FetchCommonType
581
+ //@requires: CommonStructures.c::CommonTypesMetaclass
582
+ //@requires: ModuleSetupCode.c::FastTypeChecks
583
+ //@requires: ModuleSetupCode.c::IncludeStructmemberH
584
+ //@requires: ExtensionTypes.c::CallTypeTraverse
585
+ //@requires: Synchronization.c::CriticalSections
586
+
587
+ #if !CYTHON_COMPILING_IN_LIMITED_API
588
+ #include <frameobject.h>
589
+ #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
590
+ #ifndef Py_BUILD_CORE
591
+ #define Py_BUILD_CORE 1
592
+ #endif
593
+ #include "internal/pycore_frame.h"
594
+ #endif
595
+ #endif // CYTHON_COMPILING_IN_LIMITED_API
596
+
597
+ static CYTHON_INLINE void
598
+ __Pyx_Coroutine_Undelegate(__pyx_CoroutineObject *gen) {
599
+ #if CYTHON_USE_AM_SEND
600
+ gen->yieldfrom_am_send = NULL;
601
+ #endif
602
+ Py_CLEAR(gen->yieldfrom);
603
+ }
604
+
605
+ // If StopIteration exception is set, fetches its 'value'
606
+ // attribute if any, otherwise sets pvalue to None.
607
+ //
608
+ // Returns 0 if no exception or StopIteration is set.
609
+ // If any other exception is set, returns -1 and leaves
610
+ // pvalue unchanged.
611
+ static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *$local_tstate_cname, PyObject **pvalue) {
612
+ PyObject *et, *ev, *tb;
613
+ PyObject *value = NULL;
614
+ CYTHON_UNUSED_VAR($local_tstate_cname);
615
+
616
+ __Pyx_ErrFetch(&et, &ev, &tb);
617
+
618
+ if (!et) {
619
+ Py_XDECREF(tb);
620
+ Py_XDECREF(ev);
621
+ Py_INCREF(Py_None);
622
+ *pvalue = Py_None;
623
+ return 0;
624
+ }
625
+
626
+ // most common case: plain StopIteration without or with separate argument
627
+ if (likely(et == PyExc_StopIteration)) {
628
+ if (!ev) {
629
+ Py_INCREF(Py_None);
630
+ value = Py_None;
631
+ }
632
+ else if (likely(Py_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) {
633
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
634
+ value = PyObject_GetAttr(ev, PYIDENT("value"));
635
+ if (unlikely(!value)) goto limited_api_failure;
636
+ #else
637
+ value = ((PyStopIterationObject *)ev)->value;
638
+ Py_INCREF(value);
639
+ #endif
640
+ Py_DECREF(ev);
641
+ }
642
+ // PyErr_SetObject() and friends put the value directly into ev
643
+ else if (unlikely(PyTuple_Check(ev))) {
644
+ // if it's a tuple, it is interpreted as separate constructor arguments (surprise!)
645
+ Py_ssize_t tuple_size = __Pyx_PyTuple_GET_SIZE(ev);
646
+ #if !CYTHON_ASSUME_SAFE_SIZE
647
+ if (unlikely(tuple_size < 0)) {
648
+ Py_XDECREF(tb);
649
+ Py_DECREF(ev);
650
+ Py_DECREF(et);
651
+ return -1;
652
+ }
653
+ #endif
654
+ if (tuple_size >= 1) {
655
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
656
+ value = PyTuple_GET_ITEM(ev, 0);
657
+ Py_INCREF(value);
658
+ #elif CYTHON_ASSUME_SAFE_MACROS
659
+ value = PySequence_ITEM(ev, 0);
660
+ #else
661
+ value = PySequence_GetItem(ev, 0);
662
+ if (!value) goto limited_api_failure;
663
+ #endif
664
+ } else {
665
+ Py_INCREF(Py_None);
666
+ value = Py_None;
667
+ }
668
+ Py_DECREF(ev);
669
+ }
670
+ else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
671
+ // 'steal' reference to ev
672
+ value = ev;
673
+ }
674
+ if (likely(value)) {
675
+ Py_XDECREF(tb);
676
+ Py_DECREF(et);
677
+ *pvalue = value;
678
+ return 0;
679
+ }
680
+ } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
681
+ __Pyx_ErrRestore(et, ev, tb);
682
+ return -1;
683
+ }
684
+
685
+ // otherwise: normalise and check what that gives us
686
+ PyErr_NormalizeException(&et, &ev, &tb);
687
+ if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
688
+ // looks like normalisation failed - raise the new exception
689
+ __Pyx_ErrRestore(et, ev, tb);
690
+ return -1;
691
+ }
692
+ Py_XDECREF(tb);
693
+ Py_DECREF(et);
694
+ #if CYTHON_COMPILING_IN_LIMITED_API
695
+ value = PyObject_GetAttr(ev, PYIDENT("value"));
696
+ #else
697
+ value = ((PyStopIterationObject *)ev)->value;
698
+ Py_INCREF(value);
699
+ #endif
700
+ Py_DECREF(ev);
701
+ #if CYTHON_COMPILING_IN_LIMITED_API
702
+ if (unlikely(!value)) return -1;
703
+ #endif
704
+ *pvalue = value;
705
+ return 0;
706
+
707
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL || !CYTHON_ASSUME_SAFE_MACROS
708
+ limited_api_failure:
709
+ Py_XDECREF(et);
710
+ Py_XDECREF(tb);
711
+ Py_XDECREF(ev);
712
+ return -1;
713
+ #endif
714
+ }
715
+
716
+ static CYTHON_INLINE
717
+ __Pyx_PySendResult __Pyx_Coroutine_status_from_result(PyObject **retval) {
718
+ if (*retval) {
719
+ return PYGEN_NEXT;
720
+ } else if (likely(__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, retval) == 0)) {
721
+ //assert (*retval == Py_None);
722
+ return PYGEN_RETURN;
723
+ } else {
724
+ return PYGEN_ERROR;
725
+ }
726
+ }
727
+
728
+ static CYTHON_INLINE
729
+ void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
730
+ #if PY_VERSION_HEX >= 0x030B00a4
731
+ Py_CLEAR(exc_state->exc_value);
732
+ #else
733
+ PyObject *t, *v, *tb;
734
+ t = exc_state->exc_type;
735
+ v = exc_state->exc_value;
736
+ tb = exc_state->exc_traceback;
737
+
738
+ exc_state->exc_type = NULL;
739
+ exc_state->exc_value = NULL;
740
+ exc_state->exc_traceback = NULL;
741
+
742
+ Py_XDECREF(t);
743
+ Py_XDECREF(v);
744
+ Py_XDECREF(tb);
745
+ #endif
746
+ }
747
+
748
+ #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
749
+ static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) {
750
+ const char *msg;
751
+ CYTHON_MAYBE_UNUSED_VAR(gen);
752
+ if ((0)) {
753
+ #ifdef __Pyx_Coroutine_USED
754
+ } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
755
+ msg = "coroutine already executing";
756
+ #endif
757
+ #ifdef __Pyx_AsyncGen_USED
758
+ } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
759
+ msg = "async generator already executing";
760
+ #endif
761
+ } else {
762
+ msg = "generator already executing";
763
+ }
764
+ PyErr_SetString(PyExc_ValueError, msg);
765
+ }
766
+
767
+ static void __Pyx_Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) {
768
+ CYTHON_MAYBE_UNUSED_VAR(gen);
769
+ CYTHON_MAYBE_UNUSED_VAR(closing);
770
+ #ifdef __Pyx_Coroutine_USED
771
+ if (!closing && __Pyx_Coroutine_Check(gen)) {
772
+ // `self` is an exhausted coroutine: raise an error,
773
+ // except when called from gen_close(), which should
774
+ // always be a silent method.
775
+ PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
776
+ } else
777
+ #endif
778
+ if (value) {
779
+ // `gen` is an exhausted generator:
780
+ // only set exception if called from send().
781
+ #ifdef __Pyx_AsyncGen_USED
782
+ if (__Pyx_AsyncGen_CheckExact(gen))
783
+ PyErr_SetNone(PyExc_StopAsyncIteration);
784
+ else
785
+ #endif
786
+ PyErr_SetNone(PyExc_StopIteration);
787
+ }
788
+ }
789
+
790
+ static
791
+ __Pyx_PySendResult __Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, PyObject **result, int closing) {
792
+ __Pyx_PyThreadState_declare
793
+ PyThreadState *tstate;
794
+ __Pyx_ExcInfoStruct *exc_state;
795
+ PyObject *retval;
796
+
797
+ assert(__Pyx_Coroutine_get_is_running(self)); // Callers should ensure is_running
798
+
799
+ if (unlikely(self->resume_label == -1)) {
800
+ __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
801
+ return PYGEN_ERROR;
802
+ }
803
+
804
+ #if CYTHON_FAST_THREAD_STATE
805
+ __Pyx_PyThreadState_assign
806
+ tstate = $local_tstate_cname;
807
+ #else
808
+ tstate = __Pyx_PyThreadState_Current;
809
+ #endif
810
+
811
+ // Traceback/Frame rules pre-Py3.7:
812
+ // - on entry, save external exception state in self->gi_exc_state, restore it on exit
813
+ // - on exit, keep internally generated exceptions in self->gi_exc_state, clear everything else
814
+ // - on entry, set "f_back" pointer of internal exception traceback to (current) outer call frame
815
+ // - on exit, clear "f_back" of internal exception traceback
816
+ // - do not touch external frames and tracebacks
817
+
818
+ // Traceback/Frame rules for Py3.7+ (CYTHON_USE_EXC_INFO_STACK):
819
+ // - on entry, push internal exception state in self->gi_exc_state on the exception stack
820
+ // - on exit, keep internally generated exceptions in self->gi_exc_state, clear everything else
821
+ // - on entry, set "f_back" pointer of internal exception traceback to (current) outer call frame
822
+ // - on exit, clear "f_back" of internal exception traceback
823
+ // - do not touch external frames and tracebacks
824
+
825
+ // In the Limited API/PyPy
826
+ // - on entry, save external exception state in self->gi_exc_state, restore it on exit
827
+ // - on exit, keep internally generated exceptions in self->gi_exc_state, clear everything else
828
+ // - don't mess with f_back because we can't work out how to do that
829
+ // - do not touch external frames and tracebacks
830
+
831
+ exc_state = &self->gi_exc_state;
832
+ if (exc_state->exc_value) {
833
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
834
+ // FIXME - it'd be nice to handle f_back
835
+ #else
836
+ // Generators always return to their most recent caller, not
837
+ // necessarily their creator.
838
+ PyObject *exc_tb;
839
+ #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
840
+ // owned reference!
841
+ exc_tb = PyException_GetTraceback(exc_state->exc_value);
842
+ #elif PY_VERSION_HEX >= 0x030B00a4
843
+ exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback;
844
+ #else
845
+ exc_tb = exc_state->exc_traceback;
846
+ #endif
847
+ if (exc_tb) {
848
+ PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
849
+ PyFrameObject *f = tb->tb_frame;
850
+
851
+ assert(f->f_back == NULL);
852
+ #if PY_VERSION_HEX >= 0x030B00A1
853
+ // PyThreadState_GetFrame returns NULL if there isn't a current frame
854
+ // which is a valid state so no need to check
855
+ f->f_back = PyThreadState_GetFrame(tstate);
856
+ #else
857
+ Py_XINCREF(tstate->frame);
858
+ f->f_back = tstate->frame;
859
+ #endif
860
+ #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
861
+ Py_DECREF(exc_tb);
862
+ #endif
863
+ }
864
+ #endif
865
+ }
866
+
867
+ #if CYTHON_USE_EXC_INFO_STACK
868
+ // See https://bugs.python.org/issue25612
869
+ exc_state->previous_item = tstate->exc_info;
870
+ tstate->exc_info = exc_state;
871
+ #else
872
+ if (exc_state->exc_type) {
873
+ // We were in an except handler when we left,
874
+ // restore the exception state which was put aside.
875
+ __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
876
+ // self->exc_* now holds the exception state of the caller
877
+ } else {
878
+ // save away the exception state of the caller
879
+ __Pyx_Coroutine_ExceptionClear(exc_state);
880
+ __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
881
+ }
882
+ #endif
883
+
884
+ retval = self->body(self, tstate, value);
885
+
886
+ #if CYTHON_USE_EXC_INFO_STACK
887
+ // See https://bugs.python.org/issue25612
888
+ exc_state = &self->gi_exc_state;
889
+ tstate->exc_info = exc_state->previous_item;
890
+ exc_state->previous_item = NULL;
891
+ // Cut off the exception frame chain so that we can reconnect it on re-entry above.
892
+ __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
893
+ #endif
894
+
895
+ *result = retval;
896
+
897
+ if (self->resume_label == -1) {
898
+ // terminated => return or error?
899
+ return likely(retval) ? PYGEN_RETURN : PYGEN_ERROR;
900
+ }
901
+ return PYGEN_NEXT;
902
+ }
903
+
904
+ static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
905
+ // Don't keep the reference to f_back any longer than necessary. It
906
+ // may keep a chain of frames alive or it could create a reference
907
+ // cycle.
908
+ #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
909
+ // FIXME: what to do in PyPy?
910
+ CYTHON_UNUSED_VAR(exc_state);
911
+ #else
912
+ PyObject *exc_tb;
913
+
914
+ #if PY_VERSION_HEX >= 0x030B00a4
915
+ if (!exc_state->exc_value) return;
916
+ // owned reference!
917
+ exc_tb = PyException_GetTraceback(exc_state->exc_value);
918
+ #else
919
+ exc_tb = exc_state->exc_traceback;
920
+ #endif
921
+
922
+ if (likely(exc_tb)) {
923
+ PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
924
+ PyFrameObject *f = tb->tb_frame;
925
+ Py_CLEAR(f->f_back);
926
+ #if PY_VERSION_HEX >= 0x030B00a4
927
+ Py_DECREF(exc_tb);
928
+ #endif
929
+ }
930
+ #endif
931
+ }
932
+
933
+ #define __Pyx_Coroutine_MethodReturnFromResult(gen, result, retval, iternext) \
934
+ ((result) == PYGEN_NEXT ? (retval) : __Pyx__Coroutine_MethodReturnFromResult(gen, result, retval, iternext))
935
+
936
+ static PyObject *
937
+ __Pyx__Coroutine_MethodReturnFromResult(PyObject* gen, __Pyx_PySendResult result, PyObject *retval, int iternext) {
938
+ CYTHON_MAYBE_UNUSED_VAR(gen);
939
+ if (likely(result == PYGEN_RETURN)) {
940
+ // return values pass through StopIteration or StopAsyncIteration
941
+ int is_async = 0;
942
+ #ifdef __Pyx_AsyncGen_USED
943
+ is_async = __Pyx_AsyncGen_CheckExact(gen);
944
+ #endif
945
+ __Pyx_ReturnWithStopIteration(retval, is_async, iternext);
946
+ Py_XDECREF(retval);
947
+ }
948
+ return NULL;
949
+ }
950
+
951
+ #if CYTHON_COMPILING_IN_CPYTHON
952
+ static CYTHON_INLINE
953
+ PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
954
+ #if PY_VERSION_HEX <= 0x030A00A1
955
+ return _PyGen_Send(gen, arg);
956
+ #else
957
+ PyObject *result;
958
+ // PyIter_Send() asserts non-NULL arg
959
+ if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
960
+ if (PyAsyncGen_CheckExact(gen)) {
961
+ assert(result == Py_None);
962
+ PyErr_SetNone(PyExc_StopAsyncIteration);
963
+ }
964
+ else if (result == Py_None) {
965
+ PyErr_SetNone(PyExc_StopIteration);
966
+ }
967
+ else {
968
+ #if PY_VERSION_HEX < 0x030d00A1
969
+ _PyGen_SetStopIterationValue(result);
970
+ #else
971
+ if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) {
972
+ // delay instantiation if possible
973
+ PyErr_SetObject(PyExc_StopIteration, result);
974
+ } else {
975
+ PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result);
976
+ if (likely(exc != NULL)) {
977
+ PyErr_SetObject(PyExc_StopIteration, exc);
978
+ Py_DECREF(exc);
979
+ }
980
+ }
981
+ #endif
982
+ }
983
+ Py_DECREF(result);
984
+ result = NULL;
985
+ }
986
+ return result;
987
+ #endif
988
+ }
989
+ #endif
990
+
991
+ static CYTHON_INLINE __Pyx_PySendResult
992
+ __Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen, PyObject** retval) {
993
+ __Pyx_PySendResult result;
994
+ PyObject *val = NULL;
995
+ assert(__Pyx_Coroutine_get_is_running(gen));
996
+ __Pyx_Coroutine_Undelegate(gen);
997
+ __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
998
+ // val == NULL on failure => pass on exception
999
+ result = __Pyx_Coroutine_SendEx(gen, val, retval, 0);
1000
+ Py_XDECREF(val);
1001
+ return result;
1002
+ }
1003
+
1004
+ #if CYTHON_USE_AM_SEND
1005
+ static __Pyx_PySendResult
1006
+ __Pyx_Coroutine_SendToDelegate(__pyx_CoroutineObject *gen, __Pyx_pyiter_sendfunc gen_am_send, PyObject *value, PyObject **retval) {
1007
+ PyObject *ret = NULL;
1008
+ __Pyx_PySendResult delegate_result, result;
1009
+ assert(__Pyx_Coroutine_get_is_running(gen));
1010
+ // we assume that gen->yieldfrom cannot change as long as 'gen->is_running' is set => no safety INCREF()
1011
+ delegate_result = gen_am_send(gen->yieldfrom, value, &ret);
1012
+ if (delegate_result == PYGEN_NEXT) {
1013
+ assert (ret != NULL);
1014
+ *retval = ret;
1015
+ return PYGEN_NEXT;
1016
+ }
1017
+ //assert (delegate_result == PYGEN_ERROR ? ret == NULL : ret != NULL);
1018
+ assert (delegate_result != PYGEN_ERROR || ret == NULL);
1019
+ __Pyx_Coroutine_Undelegate(gen);
1020
+ result = __Pyx_Coroutine_SendEx(gen, ret, retval, 0);
1021
+ Py_XDECREF(ret);
1022
+ return result;
1023
+ }
1024
+ #endif
1025
+
1026
+ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
1027
+ PyObject *retval = NULL;
1028
+ __Pyx_PySendResult result = __Pyx_Coroutine_AmSend(self, value, &retval);
1029
+ return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
1030
+ }
1031
+
1032
+ static __Pyx_PySendResult
1033
+ __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
1034
+ __Pyx_PySendResult result;
1035
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
1036
+ if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
1037
+ *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
1038
+ return PYGEN_ERROR;
1039
+ }
1040
+ #if CYTHON_USE_AM_SEND
1041
+ if (gen->yieldfrom_am_send) {
1042
+ result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, value, retval);
1043
+ } else
1044
+ #endif
1045
+ if (gen->yieldfrom) {
1046
+ PyObject *yf = gen->yieldfrom;
1047
+ PyObject *ret;
1048
+ #if !CYTHON_USE_AM_SEND
1049
+ // Py3.10 puts "am_send" into "gen->yieldfrom_am_send" instead of using these special cases.
1050
+ // See "__Pyx_Coroutine_Set_Owned_Yield_From()" above.
1051
+ #ifdef __Pyx_Generator_USED
1052
+ if (__Pyx_Generator_CheckExact(yf)) {
1053
+ ret = __Pyx_Coroutine_Send(yf, value);
1054
+ } else
1055
+ #endif
1056
+ #ifdef __Pyx_Coroutine_USED
1057
+ if (__Pyx_Coroutine_Check(yf)) {
1058
+ ret = __Pyx_Coroutine_Send(yf, value);
1059
+ } else
1060
+ #endif
1061
+ #ifdef __Pyx_AsyncGen_USED
1062
+ if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
1063
+ ret = __Pyx_async_gen_asend_send(yf, value);
1064
+ } else
1065
+ #endif
1066
+ #if CYTHON_COMPILING_IN_CPYTHON
1067
+ if (PyGen_CheckExact(yf)) {
1068
+ ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
1069
+ } else
1070
+ if (PyCoro_CheckExact(yf)) {
1071
+ ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
1072
+ } else
1073
+ #endif
1074
+ #endif
1075
+ {
1076
+ if (value == Py_None && PyIter_Check(yf))
1077
+ ret = __Pyx_PyIter_Next_Plain(yf);
1078
+ else
1079
+ ret = __Pyx_PyObject_CallMethod1(yf, PYIDENT("send"), value);
1080
+ }
1081
+ if (likely(ret)) {
1082
+ __Pyx_Coroutine_unset_is_running(gen);
1083
+ *retval = ret;
1084
+ return PYGEN_NEXT;
1085
+ }
1086
+ result = __Pyx_Coroutine_FinishDelegation(gen, retval);
1087
+ } else {
1088
+ result = __Pyx_Coroutine_SendEx(gen, value, retval, 0);
1089
+ }
1090
+ __Pyx_Coroutine_unset_is_running(gen);
1091
+ return result;
1092
+ }
1093
+
1094
+ // This helper function is used by gen_close and gen_throw to
1095
+ // close a subiterator being delegated to by yield-from.
1096
+ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
1097
+ __Pyx_PySendResult result;
1098
+ PyObject *retval = NULL;
1099
+ CYTHON_UNUSED_VAR(gen);
1100
+
1101
+ assert(__Pyx_Coroutine_get_is_running(gen));
1102
+
1103
+ #ifdef __Pyx_Generator_USED
1104
+ if (__Pyx_Generator_CheckExact(yf)) {
1105
+ result = __Pyx_Coroutine_Close(yf, &retval);
1106
+ } else
1107
+ #endif
1108
+ #ifdef __Pyx_Coroutine_USED
1109
+ if (__Pyx_Coroutine_Check(yf)) {
1110
+ result = __Pyx_Coroutine_Close(yf, &retval);
1111
+ } else
1112
+ if (__Pyx_CoroutineAwait_CheckExact(yf)) {
1113
+ result = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
1114
+ } else
1115
+ #endif
1116
+ #ifdef __Pyx_AsyncGen_USED
1117
+ if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
1118
+ retval = __Pyx_async_gen_asend_close(yf, NULL);
1119
+ // cannot fail
1120
+ result = PYGEN_RETURN;
1121
+ } else
1122
+ if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
1123
+ retval = __Pyx_async_gen_athrow_close(yf, NULL);
1124
+ // cannot fail
1125
+ result = PYGEN_RETURN;
1126
+ } else
1127
+ #endif
1128
+ {
1129
+ PyObject *meth;
1130
+ result = PYGEN_RETURN;
1131
+ meth = __Pyx_PyObject_GetAttrStrNoError(yf, PYIDENT("close"));
1132
+ if (unlikely(!meth)) {
1133
+ if (unlikely(PyErr_Occurred())) {
1134
+ PyErr_WriteUnraisable(yf);
1135
+ }
1136
+ } else {
1137
+ retval = __Pyx_PyObject_CallNoArg(meth);
1138
+ Py_DECREF(meth);
1139
+ if (unlikely(!retval)) {
1140
+ result = PYGEN_ERROR;
1141
+ }
1142
+ }
1143
+ }
1144
+ Py_XDECREF(retval);
1145
+ return result == PYGEN_ERROR ? -1 : 0;
1146
+ }
1147
+
1148
+ static PyObject *__Pyx_Generator_Next(PyObject *self) {
1149
+ __Pyx_PySendResult result;
1150
+ PyObject *retval = NULL;
1151
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
1152
+ if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
1153
+ return __Pyx_Coroutine_AlreadyRunningError(gen);
1154
+ }
1155
+ #if CYTHON_USE_AM_SEND
1156
+ if (gen->yieldfrom_am_send) {
1157
+ result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, Py_None, &retval);
1158
+ } else
1159
+ #endif
1160
+ if (gen->yieldfrom) {
1161
+ PyObject *yf = gen->yieldfrom;
1162
+ PyObject *ret;
1163
+ // YieldFrom code ensures that yf is an iterator
1164
+ #ifdef __Pyx_Generator_USED
1165
+ if (__Pyx_Generator_CheckExact(yf)) {
1166
+ ret = __Pyx_Generator_Next(yf);
1167
+ } else
1168
+ #endif
1169
+ #ifdef __Pyx_Coroutine_USED
1170
+ // See https://github.com/cython/cython/issues/1999
1171
+ if (__Pyx_Coroutine_CheckExact(yf)) {
1172
+ ret = __Pyx_Coroutine_Send(yf, Py_None);
1173
+ } else
1174
+ #endif
1175
+ #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX < 0x030A00A3 || !CYTHON_USE_AM_SEND)
1176
+ // _PyGen_Send() is not needed in 3.10+ due to "am_send"
1177
+ if (PyGen_CheckExact(yf)) {
1178
+ ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
1179
+ } else
1180
+ #endif
1181
+ ret = __Pyx_PyIter_Next_Plain(yf);
1182
+ if (likely(ret)) {
1183
+ __Pyx_Coroutine_unset_is_running(gen);
1184
+ return ret;
1185
+ }
1186
+ result = __Pyx_Coroutine_FinishDelegation(gen, &retval);
1187
+ } else {
1188
+ result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
1189
+ }
1190
+ __Pyx_Coroutine_unset_is_running(gen);
1191
+
1192
+ return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 1);
1193
+ }
1194
+
1195
+ static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) {
1196
+ PyObject *retval = NULL;
1197
+ __Pyx_PySendResult result;
1198
+ CYTHON_UNUSED_VAR(arg);
1199
+ result = __Pyx_Coroutine_Close(self, &retval);
1200
+ if (unlikely(result == PYGEN_ERROR))
1201
+ return NULL;
1202
+ Py_XDECREF(retval);
1203
+ Py_RETURN_NONE;
1204
+ }
1205
+
1206
+ static __Pyx_PySendResult
1207
+ __Pyx_Coroutine_Close(PyObject *self, PyObject **retval) {
1208
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
1209
+ __Pyx_PySendResult result;
1210
+ PyObject *yf;
1211
+ int err = 0;
1212
+
1213
+ if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
1214
+ *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
1215
+ return PYGEN_ERROR;
1216
+ }
1217
+ yf = gen->yieldfrom;
1218
+
1219
+ if (yf) {
1220
+ Py_INCREF(yf);
1221
+ err = __Pyx_Coroutine_CloseIter(gen, yf);
1222
+ __Pyx_Coroutine_Undelegate(gen);
1223
+ Py_DECREF(yf);
1224
+ }
1225
+ if (err == 0)
1226
+ PyErr_SetNone(PyExc_GeneratorExit);
1227
+ result = __Pyx_Coroutine_SendEx(gen, NULL, retval, 1);
1228
+ if (result == PYGEN_ERROR) {
1229
+ // WARNING: *retval == NULL !
1230
+ __Pyx_PyThreadState_declare
1231
+ __Pyx_PyThreadState_assign
1232
+ __Pyx_Coroutine_unset_is_running(gen);
1233
+ if (!__Pyx_PyErr_Occurred()) {
1234
+ return PYGEN_RETURN;
1235
+ } else if (likely(__Pyx_PyErr_ExceptionMatches2(PyExc_GeneratorExit, PyExc_StopIteration))) {
1236
+ __Pyx_PyErr_Clear();
1237
+ return PYGEN_RETURN;
1238
+ }
1239
+ return PYGEN_ERROR;
1240
+ } else if (likely(result == PYGEN_RETURN && *retval == Py_None)) {
1241
+ __Pyx_Coroutine_unset_is_running(gen);
1242
+ return PYGEN_RETURN;
1243
+ } else {
1244
+ const char *msg;
1245
+ Py_DECREF(*retval);
1246
+ *retval = NULL;
1247
+ if ((0)) {
1248
+ #ifdef __Pyx_Coroutine_USED
1249
+ } else if (__Pyx_Coroutine_Check(self)) {
1250
+ msg = "coroutine ignored GeneratorExit";
1251
+ #endif
1252
+ #ifdef __Pyx_AsyncGen_USED
1253
+ } else if (__Pyx_AsyncGen_CheckExact(self)) {
1254
+ msg = "async generator ignored GeneratorExit";
1255
+ #endif
1256
+ } else {
1257
+ msg = "generator ignored GeneratorExit";
1258
+ }
1259
+ PyErr_SetString(PyExc_RuntimeError, msg);
1260
+ __Pyx_Coroutine_unset_is_running(gen);
1261
+ return PYGEN_ERROR;
1262
+ }
1263
+ }
1264
+
1265
+ static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
1266
+ PyObject *args, int close_on_genexit) {
1267
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
1268
+ PyObject *yf;
1269
+
1270
+ if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen)))
1271
+ return __Pyx_Coroutine_AlreadyRunningError(gen);
1272
+
1273
+ yf = gen->yieldfrom;
1274
+ if (yf) {
1275
+ __Pyx_PySendResult result;
1276
+ PyObject *ret;
1277
+ Py_INCREF(yf);
1278
+ if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
1279
+ // Asynchronous generators *should not* be closed right away.
1280
+ // We have to allow some awaits to work it through, hence the
1281
+ // `close_on_genexit` parameter here.
1282
+ int err = __Pyx_Coroutine_CloseIter(gen, yf);
1283
+ Py_DECREF(yf);
1284
+ __Pyx_Coroutine_Undelegate(gen);
1285
+ if (err < 0)
1286
+ goto propagate_exception;
1287
+ goto throw_here;
1288
+ }
1289
+ if (0
1290
+ #ifdef __Pyx_Generator_USED
1291
+ || __Pyx_Generator_CheckExact(yf)
1292
+ #endif
1293
+ #ifdef __Pyx_Coroutine_USED
1294
+ || __Pyx_Coroutine_Check(yf)
1295
+ #endif
1296
+ ) {
1297
+ ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
1298
+ #ifdef __Pyx_Coroutine_USED
1299
+ } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
1300
+ ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
1301
+ #endif
1302
+ } else {
1303
+ PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, PYIDENT("throw"));
1304
+ if (unlikely(!meth)) {
1305
+ Py_DECREF(yf);
1306
+ if (unlikely(PyErr_Occurred())) {
1307
+ __Pyx_Coroutine_unset_is_running(gen);
1308
+ return NULL;
1309
+ }
1310
+ __Pyx_Coroutine_Undelegate(gen);
1311
+ goto throw_here;
1312
+ }
1313
+ if (args) {
1314
+ ret = __Pyx_PyObject_Call(meth, args, NULL);
1315
+ } else {
1316
+ // "tb" or even "val" might be NULL.
1317
+ PyObject *cargs[4] = {NULL, typ, val, tb};
1318
+ size_t nargs = 1U + (val != NULL) + (tb != NULL);
1319
+ ret = __Pyx_PyObject_FastCall(meth, cargs+1, nargs | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
1320
+ }
1321
+ Py_DECREF(meth);
1322
+ }
1323
+ Py_DECREF(yf);
1324
+ if (ret) {
1325
+ __Pyx_Coroutine_unset_is_running(gen);
1326
+ return ret;
1327
+ }
1328
+
1329
+ result = __Pyx_Coroutine_FinishDelegation(gen, &ret);
1330
+ __Pyx_Coroutine_unset_is_running(gen);
1331
+ return __Pyx_Coroutine_MethodReturnFromResult(self, result, ret, 0);
1332
+ }
1333
+ throw_here:
1334
+ __Pyx_Raise(typ, val, tb, NULL);
1335
+
1336
+ propagate_exception:
1337
+ {
1338
+ PyObject *retval = NULL;
1339
+ __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, NULL, &retval, 0);
1340
+ __Pyx_Coroutine_unset_is_running(gen);
1341
+ return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
1342
+ }
1343
+ }
1344
+
1345
+ static PyObject *__Pyx_Coroutine_Throw(PyObject *self,
1346
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
1347
+ PyObject *args
1348
+ #else
1349
+ PyObject *const *args, Py_ssize_t nargs
1350
+ #endif
1351
+ ) {
1352
+ PyObject *typ;
1353
+ PyObject *val = NULL;
1354
+ PyObject *tb = NULL;
1355
+
1356
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
1357
+ if (unlikely(!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)))
1358
+ return NULL;
1359
+ #else
1360
+ switch (nargs) {
1361
+ case 3:
1362
+ tb = args[2];
1363
+ CYTHON_FALLTHROUGH;
1364
+ case 2:
1365
+ val = args[1];
1366
+ CYTHON_FALLTHROUGH;
1367
+ case 1:
1368
+ typ = args[0];
1369
+ break;
1370
+ default:
1371
+ PyErr_SetString(PyExc_TypeError, "throw takes between 1 and 3 positional arguments");
1372
+ return NULL;
1373
+ }
1374
+ #endif
1375
+
1376
+ return __Pyx__Coroutine_Throw(self, typ, val, tb,
1377
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
1378
+ args,
1379
+ #else
1380
+ NULL,
1381
+ #endif
1382
+ 1);
1383
+ }
1384
+
1385
+ static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
1386
+ #if PY_VERSION_HEX >= 0x030B00a4
1387
+ Py_VISIT(exc_state->exc_value);
1388
+ #else
1389
+ Py_VISIT(exc_state->exc_type);
1390
+ Py_VISIT(exc_state->exc_value);
1391
+ Py_VISIT(exc_state->exc_traceback);
1392
+ #endif
1393
+ return 0;
1394
+ }
1395
+
1396
+ static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
1397
+ {
1398
+ int e = __Pyx_call_type_traverse((PyObject*)gen, 1, visit, arg);
1399
+ if (e) return e;
1400
+ }
1401
+ Py_VISIT(gen->closure);
1402
+ Py_VISIT(gen->classobj);
1403
+ Py_VISIT(gen->yieldfrom);
1404
+ return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
1405
+ }
1406
+
1407
+ static int __Pyx_Coroutine_clear(PyObject *self) {
1408
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
1409
+
1410
+ Py_CLEAR(gen->closure);
1411
+ Py_CLEAR(gen->classobj);
1412
+ __Pyx_Coroutine_Undelegate(gen);
1413
+ __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
1414
+ #ifdef __Pyx_AsyncGen_USED
1415
+ if (__Pyx_AsyncGen_CheckExact(self)) {
1416
+ Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
1417
+ }
1418
+ #endif
1419
+ Py_CLEAR(gen->gi_code);
1420
+ Py_CLEAR(gen->gi_frame);
1421
+ Py_CLEAR(gen->gi_name);
1422
+ Py_CLEAR(gen->gi_qualname);
1423
+ Py_CLEAR(gen->gi_modulename);
1424
+ return 0;
1425
+ }
1426
+
1427
+ static void __Pyx_Coroutine_dealloc(PyObject *self) {
1428
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
1429
+
1430
+ PyObject_GC_UnTrack(gen);
1431
+
1432
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
1433
+ if (gen->gi_weakreflist != NULL)
1434
+ #endif
1435
+ PyObject_ClearWeakRefs(self);
1436
+
1437
+ if (gen->resume_label >= 0) {
1438
+ // Generator is paused or unstarted, so we need to close
1439
+ #if CYTHON_USE_TP_FINALIZE
1440
+ PyObject_GC_Track(self);
1441
+ if (unlikely(PyObject_CallFinalizerFromDealloc(self)))
1442
+ {
1443
+ // resurrected. :(
1444
+ return;
1445
+ }
1446
+ PyObject_GC_UnTrack(self);
1447
+ #endif
1448
+ }
1449
+
1450
+ #ifdef __Pyx_AsyncGen_USED
1451
+ if (__Pyx_AsyncGen_CheckExact(self)) {
1452
+ /* We have to handle this case for asynchronous generators
1453
+ right here, because this code has to be between UNTRACK
1454
+ and GC_Del. */
1455
+ Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
1456
+ }
1457
+ #endif
1458
+ __Pyx_Coroutine_clear(self);
1459
+ __Pyx_PyHeapTypeObject_GC_Del(gen);
1460
+ }
1461
+
1462
+ #if CYTHON_USE_TP_FINALIZE
1463
+ static void __Pyx_Coroutine_del(PyObject *self) {
1464
+ PyObject *error_type, *error_value, *error_traceback;
1465
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
1466
+ __Pyx_PyThreadState_declare
1467
+
1468
+ if (gen->resume_label < 0) {
1469
+ // already terminated => nothing to clean up
1470
+ return;
1471
+ }
1472
+
1473
+ __Pyx_PyThreadState_assign
1474
+
1475
+ // Save the current exception, if any.
1476
+ __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
1477
+
1478
+ #ifdef __Pyx_AsyncGen_USED
1479
+ if (__Pyx_AsyncGen_CheckExact(self)) {
1480
+ __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
1481
+ PyObject *finalizer = agen->ag_finalizer;
1482
+ if (finalizer && !agen->ag_closed) {
1483
+ PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
1484
+ if (unlikely(!res)) {
1485
+ PyErr_WriteUnraisable(self);
1486
+ } else {
1487
+ Py_DECREF(res);
1488
+ }
1489
+ // Restore the saved exception.
1490
+ __Pyx_ErrRestore(error_type, error_value, error_traceback);
1491
+ return;
1492
+ }
1493
+ }
1494
+ #endif
1495
+
1496
+ if (unlikely(gen->resume_label == 0 && !error_value)) {
1497
+ #ifdef __Pyx_Coroutine_USED
1498
+ #ifdef __Pyx_Generator_USED
1499
+ // only warn about (async) coroutines
1500
+ if (!__Pyx_Generator_CheckExact(self))
1501
+ #endif
1502
+ {
1503
+ // untrack dead object as we are executing Python code (which might trigger GC)
1504
+ PyObject_GC_UnTrack(self);
1505
+ if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
1506
+ PyErr_WriteUnraisable(self);
1507
+ PyObject_GC_Track(self);
1508
+ }
1509
+ #endif /*__Pyx_Coroutine_USED*/
1510
+ } else {
1511
+ PyObject *retval = NULL;
1512
+ __Pyx_PySendResult result = __Pyx_Coroutine_Close(self, &retval);
1513
+ if (result == PYGEN_ERROR) {
1514
+ PyErr_WriteUnraisable(self);
1515
+ } else {
1516
+ Py_XDECREF(retval);
1517
+ }
1518
+ }
1519
+
1520
+ // Restore the saved exception.
1521
+ __Pyx_ErrRestore(error_type, error_value, error_traceback);
1522
+ }
1523
+ #endif
1524
+
1525
+ static PyObject *
1526
+ __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context)
1527
+ {
1528
+ PyObject *name = self->gi_name;
1529
+ CYTHON_UNUSED_VAR(context);
1530
+ // avoid NULL pointer dereference during garbage collection
1531
+ if (unlikely(!name)) name = Py_None;
1532
+ Py_INCREF(name);
1533
+ return name;
1534
+ }
1535
+
1536
+ static int
1537
+ __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context)
1538
+ {
1539
+ CYTHON_UNUSED_VAR(context);
1540
+ if (unlikely(value == NULL || !PyUnicode_Check(value))) {
1541
+ PyErr_SetString(PyExc_TypeError,
1542
+ "__name__ must be set to a string object");
1543
+ return -1;
1544
+ }
1545
+ Py_INCREF(value);
1546
+ __Pyx_Py_XDECREF_SET(self->gi_name, value);
1547
+ return 0;
1548
+ }
1549
+
1550
+ static PyObject *
1551
+ __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context)
1552
+ {
1553
+ PyObject *name = self->gi_qualname;
1554
+ CYTHON_UNUSED_VAR(context);
1555
+ // avoid NULL pointer dereference during garbage collection
1556
+ if (unlikely(!name)) name = Py_None;
1557
+ Py_INCREF(name);
1558
+ return name;
1559
+ }
1560
+
1561
+ static int
1562
+ __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context)
1563
+ {
1564
+ CYTHON_UNUSED_VAR(context);
1565
+ if (unlikely(value == NULL || !PyUnicode_Check(value))) {
1566
+ PyErr_SetString(PyExc_TypeError,
1567
+ "__qualname__ must be set to a string object");
1568
+ return -1;
1569
+ }
1570
+ Py_INCREF(value);
1571
+ __Pyx_Py_XDECREF_SET(self->gi_qualname, value);
1572
+ return 0;
1573
+ }
1574
+
1575
+ #if !CYTHON_COMPILING_IN_LIMITED_API
1576
+ static PyObject *
1577
+ __Pyx__Coroutine_get_frame_locked(__pyx_CoroutineObject *self) {
1578
+ PyObject *frame;
1579
+ frame = self->gi_frame;
1580
+ if (!frame) {
1581
+ if (unlikely(!self->gi_code)) {
1582
+ // Avoid doing something stupid, e.g. during garbage collection.
1583
+ Py_RETURN_NONE;
1584
+ }
1585
+ // The coroutine doesn't know what module it's in so can't fill in proper globals.
1586
+ // In principle this could be solved by storing a reference to the module in the coroutine,
1587
+ // but in practice it probably isn't worth the extra memory.
1588
+ // Therefore, just supply a blank dict.
1589
+ PyObject *globals = PyDict_New();
1590
+ if (unlikely(!globals)) return NULL;
1591
+ frame = (PyObject *) PyFrame_New(
1592
+ PyThreadState_Get(), /*PyThreadState *tstate,*/
1593
+ (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/
1594
+ globals, /*PyObject *globals,*/
1595
+ 0 /*PyObject *locals*/
1596
+ );
1597
+ Py_DECREF(globals);
1598
+ if (unlikely(!frame))
1599
+ return NULL;
1600
+ // handle potential race initializing the frame
1601
+ if (unlikely(self->gi_frame)) {
1602
+ Py_DECREF(frame);
1603
+ frame = self->gi_frame;
1604
+ } else {
1605
+ // keep the frame cached once it's created
1606
+ self->gi_frame = frame;
1607
+ }
1608
+ }
1609
+ Py_INCREF(frame);
1610
+ return frame;
1611
+ }
1612
+ #endif
1613
+
1614
+
1615
+ static PyObject *
1616
+ __Pyx__Coroutine_get_frame(__pyx_CoroutineObject *self)
1617
+ {
1618
+ #if !CYTHON_COMPILING_IN_LIMITED_API
1619
+ PyObject *frame;
1620
+ __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)self);
1621
+ frame = __Pyx__Coroutine_get_frame_locked(self);
1622
+ __Pyx_END_CRITICAL_SECTION();
1623
+ return frame;
1624
+ #else
1625
+ // In the limited API there probably isn't much we can usefully do to get a frame
1626
+ CYTHON_UNUSED_VAR(self);
1627
+ Py_RETURN_NONE;
1628
+ #endif
1629
+ }
1630
+
1631
+ static PyObject *
1632
+ __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) {
1633
+ CYTHON_UNUSED_VAR(context);
1634
+ PyObject *frame = self->gi_frame;
1635
+ if (frame)
1636
+ return __Pyx_NewRef(frame);
1637
+ return __Pyx__Coroutine_get_frame(self);
1638
+ }
1639
+
1640
+ static __pyx_CoroutineObject *__Pyx__Coroutine_New(
1641
+ PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1642
+ PyObject *name, PyObject *qualname, PyObject *module_name) {
1643
+ __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
1644
+ if (unlikely(!gen))
1645
+ return NULL;
1646
+ return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
1647
+ }
1648
+
1649
+ static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
1650
+ __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1651
+ PyObject *name, PyObject *qualname, PyObject *module_name) {
1652
+ gen->body = body;
1653
+ gen->closure = closure;
1654
+ Py_XINCREF(closure);
1655
+ gen->is_running = 0;
1656
+ gen->resume_label = 0;
1657
+ gen->classobj = NULL;
1658
+ gen->yieldfrom = NULL;
1659
+ gen->yieldfrom_am_send = NULL;
1660
+ #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_LIMITED_API
1661
+ gen->gi_exc_state.exc_value = NULL;
1662
+ #else
1663
+ gen->gi_exc_state.exc_type = NULL;
1664
+ gen->gi_exc_state.exc_value = NULL;
1665
+ gen->gi_exc_state.exc_traceback = NULL;
1666
+ #endif
1667
+ #if CYTHON_USE_EXC_INFO_STACK
1668
+ gen->gi_exc_state.previous_item = NULL;
1669
+ #endif
1670
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
1671
+ gen->gi_weakreflist = NULL;
1672
+ #endif
1673
+ Py_XINCREF(qualname);
1674
+ gen->gi_qualname = qualname;
1675
+ Py_XINCREF(name);
1676
+ gen->gi_name = name;
1677
+ Py_XINCREF(module_name);
1678
+ gen->gi_modulename = module_name;
1679
+ Py_XINCREF(code);
1680
+ gen->gi_code = code;
1681
+ gen->gi_frame = NULL;
1682
+ #if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
1683
+ memset(gen->$monitoring_states_cname, 0, sizeof(gen->$monitoring_states_cname));
1684
+ gen->$monitoring_version_cname = 0;
1685
+ #endif
1686
+
1687
+ PyObject_GC_Track(gen);
1688
+ return gen;
1689
+ }
1690
+
1691
+
1692
+ static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen) {
1693
+ // Working on the basis that:
1694
+ // 1. is_running is the main thing needed to keep generators thread-safe. They can't be
1695
+ // run simultaneously from multiple threads so as long as we track this correctly
1696
+ // then all is good.
1697
+ // 2. They aren't *ultra* high performance, and so critical sections (locking) is appropriate
1698
+ // instead of atomics.
1699
+ char result;
1700
+ __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)gen);
1701
+ result = gen->is_running;
1702
+ gen->is_running = 1;
1703
+ __Pyx_END_CRITICAL_SECTION();
1704
+ return result;
1705
+ }
1706
+ static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen) {
1707
+ __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)gen);
1708
+ assert(gen->is_running);
1709
+ gen->is_running = 0;
1710
+ __Pyx_END_CRITICAL_SECTION();
1711
+ }
1712
+ static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen) {
1713
+ char result;
1714
+ __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)gen);
1715
+ result = gen->is_running;
1716
+ __Pyx_END_CRITICAL_SECTION();
1717
+ return result;
1718
+ }
1719
+ static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure) {
1720
+ CYTHON_UNUSED_VAR(closure);
1721
+ char result = __Pyx_Coroutine_get_is_running((__pyx_CoroutineObject*)gen);
1722
+ if (result) Py_RETURN_TRUE;
1723
+ else Py_RETURN_FALSE;
1724
+ }
1725
+
1726
+ #if __PYX_HAS_PY_AM_SEND == 2
1727
+ static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send) {
1728
+ Py_ssize_t ptr_offset = (char*)(type->tp_as_async) - (char*)type;
1729
+ if (ptr_offset < 0 || ptr_offset > type->tp_basicsize) {
1730
+ // The pointer isn't to somewhere within the type. This must be a cached type that's already been updated.
1731
+ return;
1732
+ }
1733
+
1734
+ // Copy the standard Python bits of it.
1735
+ memcpy((void*)static_amsend_methods, (void*)(type->tp_as_async), sizeof(*type->tp_as_async));
1736
+ static_amsend_methods->am_send = am_send;
1737
+
1738
+ // Replace.
1739
+ type->tp_as_async = __Pyx_SlotTpAsAsync(static_amsend_methods);
1740
+ }
1741
+ #endif
1742
+
1743
+
1744
+ // In earlier versions of Python an object with no __dict__ and not __slots__ is assumed
1745
+ // to be pickleable by default. Coroutine-wrappers have significant state so shouldn't be.
1746
+ // Therefore provide a default implementation.
1747
+ // Something similar applies to heaptypes (i.e. with type_specs) with protocols 0 and 1
1748
+ // even in more recent versions.
1749
+ // We are applying this to all Python versions (hence the commented out version guard)
1750
+ // to make the behaviour explicit.
1751
+ // #if CYTHON_USE_TYPE_SPECS
1752
+ static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg) {
1753
+ CYTHON_UNUSED_VAR(arg);
1754
+ __Pyx_RaiseTypeErrorWithObjectType(
1755
+ "cannot pickle '" __Pyx_FMT_TYPENAME "' object", self);
1756
+ return NULL;
1757
+ }
1758
+ // #endif
1759
+
1760
+ //////////////////// Coroutine.module_state_decls ////////////////////
1761
+
1762
+ PyTypeObject *__pyx_CoroutineType;
1763
+ PyTypeObject *__pyx_CoroutineAwaitType;
1764
+
1765
+ //////////////////// Coroutine.module_state_traverse ///////////////////
1766
+
1767
+ Py_VISIT(traverse_module_state->__pyx_CoroutineType);
1768
+ Py_VISIT(traverse_module_state->__pyx_CoroutineAwaitType);
1769
+
1770
+ //////////////////// Coroutine.module_state_clear ///////////////////
1771
+
1772
+ Py_CLEAR(clear_module_state->__pyx_CoroutineType);
1773
+ Py_CLEAR(clear_module_state->__pyx_CoroutineAwaitType);
1774
+
1775
+ //////////////////// Coroutine.init //////////////////
1776
+ //@substitute: naming
1777
+
1778
+ if (likely(__pyx_Coroutine_init($module_cname) == 0)); else
1779
+
1780
+ //////////////////// Coroutine ////////////////////
1781
+ //@requires: CoroutineBase
1782
+ //@requires: ExtensionTypes.c::CallTypeTraverse
1783
+ //@substitute: naming
1784
+
1785
+ static void __Pyx_CoroutineAwait_dealloc(PyObject *self) {
1786
+ PyObject_GC_UnTrack(self);
1787
+ Py_CLEAR(((__pyx_CoroutineAwaitObject*)self)->coroutine);
1788
+ __Pyx_PyHeapTypeObject_GC_Del(self);
1789
+ }
1790
+
1791
+ static int __Pyx_CoroutineAwait_traverse(__pyx_CoroutineAwaitObject *self, visitproc visit, void *arg) {
1792
+ {
1793
+ int e = __Pyx_call_type_traverse((PyObject*)self, 1, visit, arg);
1794
+ if (e) return e;
1795
+ }
1796
+ Py_VISIT(self->coroutine);
1797
+ return 0;
1798
+ }
1799
+
1800
+ static int __Pyx_CoroutineAwait_clear(__pyx_CoroutineAwaitObject *self) {
1801
+ Py_CLEAR(self->coroutine);
1802
+ return 0;
1803
+ }
1804
+
1805
+ static PyObject *__Pyx_CoroutineAwait_Next(__pyx_CoroutineAwaitObject *self) {
1806
+ return __Pyx_Generator_Next(self->coroutine);
1807
+ }
1808
+
1809
+ static PyObject *__Pyx_CoroutineAwait_Send(__pyx_CoroutineAwaitObject *self, PyObject *value) {
1810
+ return __Pyx_Coroutine_Send(self->coroutine, value);
1811
+ }
1812
+
1813
+ #if __PYX_HAS_PY_AM_SEND
1814
+ static __Pyx_PySendResult __Pyx_CoroutineAwait_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
1815
+ return __Pyx_Coroutine_AmSend(((__pyx_CoroutineAwaitObject*)self)->coroutine, value, retval);
1816
+ }
1817
+ #endif
1818
+
1819
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
1820
+ static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args) {
1821
+ return __Pyx_Coroutine_Throw(self->coroutine, args);
1822
+ }
1823
+ #else
1824
+ static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *const *args, Py_ssize_t nargs) {
1825
+ return __Pyx_Coroutine_Throw(self->coroutine, args, nargs);
1826
+ }
1827
+ #endif
1828
+
1829
+ static __Pyx_PySendResult __Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self) {
1830
+ PyObject *retval = NULL;
1831
+ __Pyx_PySendResult result = __Pyx_Coroutine_Close(self->coroutine, &retval);
1832
+ Py_XDECREF(retval);
1833
+ return result;
1834
+ }
1835
+
1836
+ static PyObject *__Pyx_CoroutineAwait_Close_Method(__pyx_CoroutineAwaitObject *self, PyObject *arg) {
1837
+ PyObject *retval = NULL;
1838
+ __Pyx_PySendResult result;
1839
+ CYTHON_UNUSED_VAR(arg);
1840
+ result = __Pyx_Coroutine_Close(self->coroutine, &retval);
1841
+ if (unlikely(result == PYGEN_ERROR))
1842
+ return NULL;
1843
+ Py_XDECREF(retval);
1844
+ Py_RETURN_NONE;
1845
+ }
1846
+
1847
+ static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) {
1848
+ Py_INCREF(self);
1849
+ return self;
1850
+ }
1851
+
1852
+ #if !CYTHON_COMPILING_IN_PYPY
1853
+ static PyObject *__Pyx_CoroutineAwait_no_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) {
1854
+ CYTHON_UNUSED_VAR(type);
1855
+ CYTHON_UNUSED_VAR(args);
1856
+ CYTHON_UNUSED_VAR(kwargs);
1857
+ PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead");
1858
+ return NULL;
1859
+ }
1860
+ #endif
1861
+
1862
+ static PyMethodDef __pyx_CoroutineAwait_methods[] = {
1863
+ {"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O,
1864
+ PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next yielded value or raise StopIteration.")},
1865
+ {"throw", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_CoroutineAwait_Throw),
1866
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
1867
+ METH_VARARGS,
1868
+ #else
1869
+ METH_FASTCALL,
1870
+ #endif
1871
+ PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next yielded value or raise StopIteration.")},
1872
+ {"close", (PyCFunction) __Pyx_CoroutineAwait_Close_Method, METH_NOARGS, PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
1873
+ // only needed with type-specs, but included in all versions for clarity
1874
+ // #if CYTHON_USE_TYPE_SPECS
1875
+ {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
1876
+ {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
1877
+ // #endif
1878
+ {0, 0, 0, 0}
1879
+ };
1880
+
1881
+ static PyType_Slot __pyx_CoroutineAwaitType_slots[] = {
1882
+ {Py_tp_dealloc, (void *)__Pyx_CoroutineAwait_dealloc},
1883
+ {Py_tp_traverse, (void *)__Pyx_CoroutineAwait_traverse},
1884
+ {Py_tp_clear, (void *)__Pyx_CoroutineAwait_clear},
1885
+ #if !CYTHON_COMPILING_IN_PYPY
1886
+ {Py_tp_new, (void *)__Pyx_CoroutineAwait_no_new},
1887
+ #endif
1888
+ {Py_tp_methods, (void *)__pyx_CoroutineAwait_methods},
1889
+ {Py_tp_iter, (void *)__Pyx_CoroutineAwait_self},
1890
+ {Py_tp_iternext, (void *)__Pyx_CoroutineAwait_Next},
1891
+ #if __PYX_HAS_PY_AM_SEND == 1
1892
+ {Py_am_send, (void *)__Pyx_CoroutineAwait_AmSend},
1893
+ #endif
1894
+ {0, 0},
1895
+ };
1896
+
1897
+ static PyType_Spec __pyx_CoroutineAwaitType_spec = {
1898
+ __PYX_TYPE_MODULE_PREFIX "coroutine_wrapper",
1899
+ sizeof(__pyx_CoroutineAwaitObject),
1900
+ 0,
1901
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
1902
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND, /*tp_flags*/
1903
+ __pyx_CoroutineAwaitType_slots
1904
+ };
1905
+
1906
+ #if __PYX_HAS_PY_AM_SEND == 2 // backport
1907
+ static __Pyx_PyAsyncMethodsStruct __pyx_CoroutineAwait_as_async;
1908
+ #endif
1909
+
1910
+ static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) {
1911
+ __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, CGLOBAL(__pyx_CoroutineAwaitType));
1912
+ if (unlikely(!await)) return NULL;
1913
+ Py_INCREF(coroutine);
1914
+ await->coroutine = coroutine;
1915
+ PyObject_GC_Track(await);
1916
+ return (PyObject*)await;
1917
+ }
1918
+
1919
+ static PyObject *__Pyx_Coroutine_await(PyObject *coroutine) {
1920
+ if (unlikely(!coroutine || !__Pyx_Coroutine_Check(coroutine))) {
1921
+ PyErr_SetString(PyExc_TypeError, "invalid input, expected coroutine");
1922
+ return NULL;
1923
+ }
1924
+ return __Pyx__Coroutine_await(coroutine);
1925
+ }
1926
+
1927
+ static PyMethodDef __pyx_Coroutine_methods[] = {
1928
+ {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
1929
+ PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next iterated value or raise StopIteration.")},
1930
+ {"throw", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_Coroutine_Throw),
1931
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
1932
+ METH_VARARGS,
1933
+ #else
1934
+ METH_FASTCALL,
1935
+ #endif
1936
+ PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next iterated value or raise StopIteration.")},
1937
+ {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
1938
+ {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
1939
+ {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
1940
+ {0, 0, 0, 0}
1941
+ };
1942
+
1943
+ static PyMemberDef __pyx_Coroutine_memberlist[] = {
1944
+ {"cr_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
1945
+ PyDoc_STR("object being awaited, or None")},
1946
+ {"cr_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
1947
+ {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
1948
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
1949
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
1950
+ #endif
1951
+ {0, 0, 0, 0, 0}
1952
+ };
1953
+
1954
+ static PyGetSetDef __pyx_Coroutine_getsets[] = {
1955
+ {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
1956
+ PyDoc_STR("name of the coroutine"), 0},
1957
+ {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
1958
+ PyDoc_STR("qualified name of the coroutine"), 0},
1959
+ {"cr_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
1960
+ PyDoc_STR("Frame of the coroutine"), 0},
1961
+ // getter rather than member for thread safety.
1962
+ {"cr_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
1963
+ {0, 0, 0, 0, 0}
1964
+ };
1965
+
1966
+ static PyType_Slot __pyx_CoroutineType_slots[] = {
1967
+ {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
1968
+ {Py_am_await, (void *)&__Pyx_Coroutine_await},
1969
+ {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
1970
+ {Py_tp_methods, (void *)__pyx_Coroutine_methods},
1971
+ {Py_tp_members, (void *)__pyx_Coroutine_memberlist},
1972
+ {Py_tp_getset, (void *)__pyx_Coroutine_getsets},
1973
+ {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
1974
+ #if CYTHON_USE_TP_FINALIZE
1975
+ {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
1976
+ #endif
1977
+ #if __PYX_HAS_PY_AM_SEND == 1
1978
+ {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
1979
+ #endif
1980
+ {0, 0},
1981
+ };
1982
+
1983
+ static PyType_Spec __pyx_CoroutineType_spec = {
1984
+ __PYX_TYPE_MODULE_PREFIX "coroutine",
1985
+ sizeof(__pyx_CoroutineObject),
1986
+ 0,
1987
+ #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
1988
+ Py_TPFLAGS_MANAGED_WEAKREF |
1989
+ #endif
1990
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
1991
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND, /*tp_flags*/
1992
+ __pyx_CoroutineType_slots
1993
+ };
1994
+
1995
+ #if __PYX_HAS_PY_AM_SEND == 2
1996
+ static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async;
1997
+ #endif
1998
+
1999
+ static int __pyx_Coroutine_init(PyObject *module) {
2000
+ $modulestatetype_cname *mstate;
2001
+ CYTHON_MAYBE_UNUSED_VAR(module);
2002
+ // on Windows, C-API functions can't be used in slots statically
2003
+ mstate = __Pyx_PyModule_GetState(module);
2004
+ mstate->__pyx_CoroutineType = __Pyx_FetchCommonTypeFromSpec(
2005
+ mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CoroutineType_spec, NULL);
2006
+ if (unlikely(!mstate->__pyx_CoroutineType))
2007
+ return -1;
2008
+ #if __PYX_HAS_PY_AM_SEND == 2
2009
+ __Pyx_SetBackportTypeAmSend(mstate->__pyx_CoroutineType, &__pyx_Coroutine_as_async, &__Pyx_Coroutine_AmSend);
2010
+ #endif
2011
+
2012
+ #ifdef __Pyx_IterableCoroutine_USED
2013
+ if (unlikely(__pyx_IterableCoroutine_init(module) == -1))
2014
+ return -1;
2015
+ #endif
2016
+
2017
+ mstate->__pyx_CoroutineAwaitType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CoroutineAwaitType_spec, NULL);
2018
+ if (unlikely(!mstate->__pyx_CoroutineAwaitType))
2019
+ return -1;
2020
+ #if __PYX_HAS_PY_AM_SEND == 2
2021
+ __Pyx_SetBackportTypeAmSend(mstate->__pyx_CoroutineAwaitType, &__pyx_CoroutineAwait_as_async, &__Pyx_CoroutineAwait_AmSend);
2022
+ #endif
2023
+
2024
+ return 0;
2025
+ }
2026
+
2027
+ //////////////////// IterableCoroutine.module_state_decls ////////////////////
2028
+
2029
+ PyTypeObject *__pyx_IterableCoroutineType;
2030
+
2031
+ //////////////////// IterableCoroutine.module_state_traverse ///////////////////
2032
+
2033
+ Py_VISIT(traverse_module_state->__pyx_IterableCoroutineType);
2034
+
2035
+ //////////////////// IterableCoroutine.module_state_clear ///////////////////
2036
+
2037
+ Py_CLEAR(clear_module_state->__pyx_IterableCoroutineType);
2038
+
2039
+ //////////////////// IterableCoroutine.init //////////////////
2040
+ //@substitute: naming
2041
+
2042
+ if (likely(__pyx_IterableCoroutine_init($module_cname) == 0)); else
2043
+
2044
+ //////////////////// IterableCoroutine.proto ////////////////////
2045
+
2046
+ #define __Pyx_IterableCoroutine_USED
2047
+
2048
+ #undef __Pyx_Coroutine_Check
2049
+ #define __Pyx_Coroutine_Check(obj) (__Pyx_Coroutine_CheckExact(obj) || Py_IS_TYPE(obj, CGLOBAL(__pyx_IterableCoroutineType)))
2050
+
2051
+ #define __Pyx_IterableCoroutine_New(body, code, closure, name, qualname, module_name) \
2052
+ __Pyx__Coroutine_New(CGLOBAL(__pyx_IterableCoroutineType), body, code, closure, name, qualname, module_name)
2053
+
2054
+ static int __pyx_IterableCoroutine_init(PyObject *module);/*proto*/
2055
+
2056
+
2057
+ //////////////////// IterableCoroutine ////////////////////
2058
+ //@requires: Coroutine
2059
+ //@requires: CommonStructures.c::FetchCommonType
2060
+ //@requires: CommonStructures.c::CommonTypesMetaclass
2061
+ //@substitute: naming
2062
+
2063
+ static PyType_Slot __pyx_IterableCoroutineType_slots[] = {
2064
+ {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
2065
+ {Py_am_await, (void *)&__Pyx_Coroutine_await},
2066
+ {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
2067
+ {Py_tp_iter, (void *)__Pyx_Coroutine_await},
2068
+ {Py_tp_iternext, (void *)__Pyx_Generator_Next},
2069
+ {Py_tp_methods, (void *)__pyx_Coroutine_methods},
2070
+ {Py_tp_members, (void *)__pyx_Coroutine_memberlist},
2071
+ {Py_tp_getset, (void *)__pyx_Coroutine_getsets},
2072
+ {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
2073
+ #if CYTHON_USE_TP_FINALIZE
2074
+ {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
2075
+ #endif
2076
+ #if __PYX_HAS_PY_AM_SEND == 1
2077
+ {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
2078
+ #endif
2079
+ {0, 0},
2080
+ };
2081
+
2082
+ static PyType_Spec __pyx_IterableCoroutineType_spec = {
2083
+ __PYX_TYPE_MODULE_PREFIX "iterable_coroutine",
2084
+ sizeof(__pyx_CoroutineObject),
2085
+ 0,
2086
+ #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
2087
+ Py_TPFLAGS_MANAGED_WEAKREF |
2088
+ #endif
2089
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
2090
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND, /*tp_flags*/
2091
+ __pyx_IterableCoroutineType_slots
2092
+ };
2093
+
2094
+
2095
+ static int __pyx_IterableCoroutine_init(PyObject *module) {
2096
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
2097
+ mstate->__pyx_IterableCoroutineType = __Pyx_FetchCommonTypeFromSpec(
2098
+ mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_IterableCoroutineType_spec, NULL);
2099
+ if (unlikely(!mstate->__pyx_IterableCoroutineType))
2100
+ return -1;
2101
+ #if __PYX_HAS_PY_AM_SEND == 2
2102
+ __Pyx_SetBackportTypeAmSend(mstate->__pyx_IterableCoroutineType, &__pyx_Coroutine_as_async, &__Pyx_Coroutine_AmSend);
2103
+ #endif
2104
+ return 0;
2105
+ }
2106
+
2107
+ //////////////////// Generator.module_state_decls ////////////////////
2108
+
2109
+ PyTypeObject *__pyx_GeneratorType;
2110
+
2111
+ //////////////////// Generator.module_state_traverse ///////////////////
2112
+
2113
+ Py_VISIT(traverse_module_state->__pyx_GeneratorType);
2114
+
2115
+ //////////////////// Generator.module_state_clear ///////////////////
2116
+
2117
+ Py_CLEAR(clear_module_state->__pyx_GeneratorType);
2118
+
2119
+ //////////////////// Generator.init //////////////////
2120
+ //@substitute: naming
2121
+
2122
+ if (likely(__pyx_Generator_init($module_cname) == 0)); else
2123
+
2124
+ //////////////////// Generator ////////////////////
2125
+ //@requires: CoroutineBase
2126
+ //@substitute: naming
2127
+
2128
+ static PyMethodDef __pyx_Generator_methods[] = {
2129
+ {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
2130
+ PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
2131
+ {"throw", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_Coroutine_Throw),
2132
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
2133
+ METH_VARARGS,
2134
+ #else
2135
+ METH_FASTCALL,
2136
+ #endif
2137
+ PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
2138
+ {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
2139
+ PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
2140
+ {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
2141
+ {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
2142
+ {0, 0, 0, 0}
2143
+ };
2144
+
2145
+ static PyMemberDef __pyx_Generator_memberlist[] = {
2146
+ {"gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
2147
+ PyDoc_STR("object being iterated by 'yield from', or None")},
2148
+ {"gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
2149
+ {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
2150
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
2151
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
2152
+ #endif
2153
+ {0, 0, 0, 0, 0}
2154
+ };
2155
+
2156
+ static PyGetSetDef __pyx_Generator_getsets[] = {
2157
+ {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
2158
+ PyDoc_STR("name of the generator"), 0},
2159
+ {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
2160
+ PyDoc_STR("qualified name of the generator"), 0},
2161
+ {"gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
2162
+ PyDoc_STR("Frame of the generator"), 0},
2163
+ {"gi_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
2164
+ {0, 0, 0, 0, 0}
2165
+ };
2166
+
2167
+ static PyType_Slot __pyx_GeneratorType_slots[] = {
2168
+ {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
2169
+ {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
2170
+ {Py_tp_iter, (void *)PyObject_SelfIter},
2171
+ {Py_tp_iternext, (void *)__Pyx_Generator_Next},
2172
+ {Py_tp_methods, (void *)__pyx_Generator_methods},
2173
+ {Py_tp_members, (void *)__pyx_Generator_memberlist},
2174
+ {Py_tp_getset, (void *)__pyx_Generator_getsets},
2175
+ {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
2176
+ #if CYTHON_USE_TP_FINALIZE
2177
+ {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
2178
+ #endif
2179
+ #if __PYX_HAS_PY_AM_SEND == 1
2180
+ {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
2181
+ #endif
2182
+ {0, 0},
2183
+ };
2184
+
2185
+ static PyType_Spec __pyx_GeneratorType_spec = {
2186
+ __PYX_TYPE_MODULE_PREFIX "generator",
2187
+ sizeof(__pyx_CoroutineObject),
2188
+ 0,
2189
+ #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
2190
+ Py_TPFLAGS_MANAGED_WEAKREF |
2191
+ #endif
2192
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
2193
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND, /*tp_flags*/
2194
+ __pyx_GeneratorType_slots
2195
+ };
2196
+
2197
+ #if __PYX_HAS_PY_AM_SEND == 2
2198
+ static __Pyx_PyAsyncMethodsStruct __pyx_Generator_as_async;
2199
+ #endif
2200
+
2201
+ static int __pyx_Generator_init(PyObject *module) {
2202
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
2203
+ mstate->__pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(
2204
+ mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_GeneratorType_spec, NULL);
2205
+ if (unlikely(!mstate->__pyx_GeneratorType)) {
2206
+ return -1;
2207
+ }
2208
+ #if __PYX_HAS_PY_AM_SEND == 2
2209
+ __Pyx_SetBackportTypeAmSend(mstate->__pyx_GeneratorType, &__pyx_Generator_as_async, &__Pyx_Coroutine_AmSend);
2210
+ #endif
2211
+ return 0;
2212
+ }
2213
+
2214
+ static PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self) {
2215
+ __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
2216
+ PyObject *retval = NULL;
2217
+ if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
2218
+ return __Pyx_Coroutine_AlreadyRunningError(gen);
2219
+ }
2220
+ __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
2221
+ __Pyx_Coroutine_unset_is_running(gen);
2222
+ (void) result;
2223
+ assert (result == PYGEN_RETURN || result == PYGEN_ERROR);
2224
+ assert ((result == PYGEN_RETURN && retval != NULL) || (result == PYGEN_ERROR && retval == NULL));
2225
+ return retval;
2226
+ }
2227
+
2228
+
2229
+ /////////////// ReturnWithStopIteration.proto ///////////////
2230
+
2231
+ static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext); /*proto*/
2232
+
2233
+ /////////////// ReturnWithStopIteration ///////////////
2234
+ //@requires: Exceptions.c::PyErrFetchRestore
2235
+ //@requires: Exceptions.c::PyThreadStateGet
2236
+ //@requires: ObjectHandling.c::PyObjectCallOneArg
2237
+ //@substitute: naming
2238
+
2239
+ // 1) Instantiating an exception just to pass back a value is costly.
2240
+ // 2) CPython 3.12 cannot separate exception type and value
2241
+ // 3) Passing a tuple as value into PyErr_SetObject() passes its items on as arguments.
2242
+ // 4) Passing an exception as value will interpret it as an exception on unpacking and raise it (or unpack its value).
2243
+ // 5) If there is currently an exception being handled, we need to chain it.
2244
+ // 6) CPython < 3.14a1 does not implement vectorcalls for exceptions.
2245
+
2246
+ static void __Pyx__ReturnWithStopIteration(PyObject* value, int async); /*proto*/
2247
+
2248
+ static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext) {
2249
+ if (value == Py_None) {
2250
+ if (async || !iternext)
2251
+ PyErr_SetNone(async ? PyExc_StopAsyncIteration : PyExc_StopIteration);
2252
+ // for regular iternext, then we don't have to return StopIteration and can just return NULL
2253
+ return;
2254
+ }
2255
+ __Pyx__ReturnWithStopIteration(value, async);
2256
+ }
2257
+
2258
+ static void __Pyx__ReturnWithStopIteration(PyObject* value, int async) {
2259
+ #if CYTHON_COMPILING_IN_CPYTHON
2260
+ __Pyx_PyThreadState_declare
2261
+ #endif
2262
+ PyObject *exc;
2263
+ PyObject *exc_type = async ? PyExc_StopAsyncIteration : PyExc_StopIteration;
2264
+ #if CYTHON_COMPILING_IN_CPYTHON
2265
+ if ((PY_VERSION_HEX >= (0x030C00A6)) || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
2266
+ if (PY_VERSION_HEX >= (0x030e00A1)) {
2267
+ exc = __Pyx_PyObject_CallOneArg(exc_type, value);
2268
+ } else {
2269
+ // Before Py3.14a1, CPython doesn't implement vectorcall for exceptions.
2270
+ PyObject *args_tuple = PyTuple_New(1);
2271
+ if (unlikely(!args_tuple)) return;
2272
+ Py_INCREF(value);
2273
+ PyTuple_SET_ITEM(args_tuple, 0, value);
2274
+ exc = PyObject_Call(exc_type, args_tuple, NULL);
2275
+ Py_DECREF(args_tuple);
2276
+ }
2277
+ if (unlikely(!exc)) return;
2278
+ } else {
2279
+ // it's safe to avoid instantiating the exception
2280
+ Py_INCREF(value);
2281
+ exc = value;
2282
+ }
2283
+ #if CYTHON_FAST_THREAD_STATE
2284
+ __Pyx_PyThreadState_assign
2285
+ #if CYTHON_USE_EXC_INFO_STACK
2286
+ if (!$local_tstate_cname->exc_info->exc_value)
2287
+ #else
2288
+ if (!$local_tstate_cname->exc_type)
2289
+ #endif
2290
+ {
2291
+ // no chaining needed => avoid the overhead in PyErr_SetObject()
2292
+ Py_INCREF(exc_type);
2293
+ __Pyx_ErrRestore(exc_type, exc, NULL);
2294
+ return;
2295
+ }
2296
+ #endif
2297
+ #else
2298
+ exc = __Pyx_PyObject_CallOneArg(exc_type, value);
2299
+ if (unlikely(!exc)) return;
2300
+ #endif
2301
+ PyErr_SetObject(exc_type, exc);
2302
+ Py_DECREF(exc);
2303
+ }
2304
+
2305
+ //////////////////// Coro_CheckExact.proto ////////////////
2306
+
2307
+ #if CYTHON_COMPILING_IN_LIMITED_API
2308
+ static int __Pyx_PyCoro_CheckExact(PyObject *o); /* proto */
2309
+ #else
2310
+ #define __Pyx_PyCoro_CheckExact PyCoro_CheckExact
2311
+ #endif
2312
+
2313
+ /////////////////// Coro_CheckExact.module_state_decls //////////
2314
+
2315
+ #if CYTHON_COMPILING_IN_LIMITED_API
2316
+ PyObject *__Pyx_CachedCoroType;
2317
+ #endif
2318
+
2319
+ ////////////////// Coro_CheckExact.init ////////////////
2320
+
2321
+ #if CYTHON_COMPILING_IN_LIMITED_API
2322
+ {
2323
+ PyObject *typesModule=NULL;
2324
+ typesModule = PyImport_ImportModule("types");
2325
+ if (typesModule) {
2326
+ CGLOBAL(__Pyx_CachedCoroType) = PyObject_GetAttrString(typesModule, "CoroutineType");
2327
+ Py_DECREF(typesModule);
2328
+ }
2329
+ } // error handling follows
2330
+ #endif
2331
+
2332
+ /////////////// Coro_CheckExact.cleanup ////////////////
2333
+
2334
+ #if CYTHON_COMPILING_IN_LIMITED_API
2335
+ Py_CLEAR(CGLOBAL(__Pyx_CachedCoroType));
2336
+ #endif
2337
+
2338
+ /////////////////// Coro_CheckExact /////////////////////
2339
+
2340
+ #if CYTHON_COMPILING_IN_LIMITED_API
2341
+ static int __Pyx_PyCoro_CheckExact(PyObject *o) {
2342
+ return (PyObject*)Py_TYPE(o) == CGLOBAL(__Pyx_CachedCoroType);
2343
+ }
2344
+ #endif