Cython 3.2.0__cp39-abi3-win32.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 (333) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +350 -0
  4. Cython/Build/Dependencies.py +1314 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +463 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/SharedModule.py +94 -0
  9. Cython/Build/Tests/TestCyCache.py +194 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  14. Cython/Build/Tests/TestRecythonize.py +212 -0
  15. Cython/Build/Tests/TestStripLiterals.py +155 -0
  16. Cython/Build/Tests/__init__.py +1 -0
  17. Cython/Build/__init__.py +11 -0
  18. Cython/CodeWriter.py +815 -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 +680 -0
  23. Cython/Compiler/Builtin.py +984 -0
  24. Cython/Compiler/CmdLine.py +263 -0
  25. Cython/Compiler/Code.pxd +149 -0
  26. Cython/Compiler/Code.py +3746 -0
  27. Cython/Compiler/Code.pyd +0 -0
  28. Cython/Compiler/CodeGeneration.py +33 -0
  29. Cython/Compiler/CythonScope.py +191 -0
  30. Cython/Compiler/Dataclass.py +864 -0
  31. Cython/Compiler/DebugFlags.py +24 -0
  32. Cython/Compiler/Errors.py +297 -0
  33. Cython/Compiler/ExprNodes.py +15562 -0
  34. Cython/Compiler/FlowControl.pxd +97 -0
  35. Cython/Compiler/FlowControl.py +1451 -0
  36. Cython/Compiler/FlowControl.pyd +0 -0
  37. Cython/Compiler/FusedNode.py +971 -0
  38. Cython/Compiler/FusedNode.pyd +0 -0
  39. Cython/Compiler/Future.py +16 -0
  40. Cython/Compiler/Interpreter.py +57 -0
  41. Cython/Compiler/Lexicon.py +421 -0
  42. Cython/Compiler/LineTable.py +114 -0
  43. Cython/Compiler/LineTable.pyd +0 -0
  44. Cython/Compiler/Main.py +857 -0
  45. Cython/Compiler/MatchCaseNodes.py +259 -0
  46. Cython/Compiler/MemoryView.py +905 -0
  47. Cython/Compiler/ModuleNode.py +4235 -0
  48. Cython/Compiler/Naming.py +363 -0
  49. Cython/Compiler/Nodes.py +10831 -0
  50. Cython/Compiler/Optimize.py +5288 -0
  51. Cython/Compiler/Options.py +843 -0
  52. Cython/Compiler/ParseTreeTransforms.pxd +78 -0
  53. Cython/Compiler/ParseTreeTransforms.py +4638 -0
  54. Cython/Compiler/Parsing.pxd +9 -0
  55. Cython/Compiler/Parsing.py +4775 -0
  56. Cython/Compiler/Parsing.pyd +0 -0
  57. Cython/Compiler/Pipeline.py +439 -0
  58. Cython/Compiler/PyrexTypes.py +5870 -0
  59. Cython/Compiler/Pythran.py +232 -0
  60. Cython/Compiler/Scanning.pxd +48 -0
  61. Cython/Compiler/Scanning.py +701 -0
  62. Cython/Compiler/Scanning.pyd +0 -0
  63. Cython/Compiler/StringEncoding.py +298 -0
  64. Cython/Compiler/Symtab.py +3073 -0
  65. Cython/Compiler/Tests/TestBuffer.py +105 -0
  66. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  67. Cython/Compiler/Tests/TestCmdLine.py +586 -0
  68. Cython/Compiler/Tests/TestCode.py +144 -0
  69. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  70. Cython/Compiler/Tests/TestGrammar.py +202 -0
  71. Cython/Compiler/Tests/TestMemView.py +71 -0
  72. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  73. Cython/Compiler/Tests/TestScanning.py +134 -0
  74. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  75. Cython/Compiler/Tests/TestStringEncoding.py +21 -0
  76. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  77. Cython/Compiler/Tests/TestTreePath.py +103 -0
  78. Cython/Compiler/Tests/TestTypes.py +75 -0
  79. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  80. Cython/Compiler/Tests/TestVisitor.py +61 -0
  81. Cython/Compiler/Tests/Utils.py +36 -0
  82. Cython/Compiler/Tests/__init__.py +1 -0
  83. Cython/Compiler/TreeFragment.py +278 -0
  84. Cython/Compiler/TreePath.py +303 -0
  85. Cython/Compiler/TypeInference.py +591 -0
  86. Cython/Compiler/TypeSlots.py +1174 -0
  87. Cython/Compiler/UFuncs.py +311 -0
  88. Cython/Compiler/UtilNodes.py +389 -0
  89. Cython/Compiler/UtilityCode.py +344 -0
  90. Cython/Compiler/Version.py +8 -0
  91. Cython/Compiler/Visitor.pxd +53 -0
  92. Cython/Compiler/Visitor.py +861 -0
  93. Cython/Compiler/Visitor.pyd +0 -0
  94. Cython/Compiler/__init__.py +1 -0
  95. Cython/Coverage.py +448 -0
  96. Cython/Debugger/Cygdb.py +177 -0
  97. Cython/Debugger/DebugWriter.py +82 -0
  98. Cython/Debugger/Tests/TestLibCython.py +275 -0
  99. Cython/Debugger/Tests/__init__.py +1 -0
  100. Cython/Debugger/Tests/cfuncs.c +8 -0
  101. Cython/Debugger/Tests/codefile +49 -0
  102. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  103. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  104. Cython/Debugger/__init__.py +1 -0
  105. Cython/Debugger/libcython.py +1548 -0
  106. Cython/Debugger/libpython.py +2821 -0
  107. Cython/Debugging.py +20 -0
  108. Cython/Distutils/__init__.py +2 -0
  109. Cython/Distutils/build_ext.py +139 -0
  110. Cython/Distutils/extension.py +96 -0
  111. Cython/Distutils/old_build_ext.py +351 -0
  112. Cython/Includes/cpython/__init__.pxd +173 -0
  113. Cython/Includes/cpython/array.pxd +178 -0
  114. Cython/Includes/cpython/bool.pxd +37 -0
  115. Cython/Includes/cpython/buffer.pxd +112 -0
  116. Cython/Includes/cpython/bytearray.pxd +33 -0
  117. Cython/Includes/cpython/bytes.pxd +200 -0
  118. Cython/Includes/cpython/cellobject.pxd +35 -0
  119. Cython/Includes/cpython/ceval.pxd +8 -0
  120. Cython/Includes/cpython/codecs.pxd +121 -0
  121. Cython/Includes/cpython/complex.pxd +60 -0
  122. Cython/Includes/cpython/contextvars.pxd +145 -0
  123. Cython/Includes/cpython/conversion.pxd +36 -0
  124. Cython/Includes/cpython/datetime.pxd +395 -0
  125. Cython/Includes/cpython/descr.pxd +26 -0
  126. Cython/Includes/cpython/dict.pxd +187 -0
  127. Cython/Includes/cpython/exc.pxd +263 -0
  128. Cython/Includes/cpython/fileobject.pxd +57 -0
  129. Cython/Includes/cpython/float.pxd +47 -0
  130. Cython/Includes/cpython/function.pxd +65 -0
  131. Cython/Includes/cpython/genobject.pxd +25 -0
  132. Cython/Includes/cpython/getargs.pxd +12 -0
  133. Cython/Includes/cpython/instance.pxd +25 -0
  134. Cython/Includes/cpython/iterator.pxd +36 -0
  135. Cython/Includes/cpython/iterobject.pxd +24 -0
  136. Cython/Includes/cpython/list.pxd +92 -0
  137. Cython/Includes/cpython/long.pxd +149 -0
  138. Cython/Includes/cpython/longintrepr.pxd +14 -0
  139. Cython/Includes/cpython/mapping.pxd +63 -0
  140. Cython/Includes/cpython/marshal.pxd +66 -0
  141. Cython/Includes/cpython/mem.pxd +120 -0
  142. Cython/Includes/cpython/memoryview.pxd +50 -0
  143. Cython/Includes/cpython/method.pxd +49 -0
  144. Cython/Includes/cpython/module.pxd +208 -0
  145. Cython/Includes/cpython/number.pxd +258 -0
  146. Cython/Includes/cpython/object.pxd +433 -0
  147. Cython/Includes/cpython/pycapsule.pxd +143 -0
  148. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  149. Cython/Includes/cpython/pyport.pxd +8 -0
  150. Cython/Includes/cpython/pystate.pxd +95 -0
  151. Cython/Includes/cpython/pythread.pxd +53 -0
  152. Cython/Includes/cpython/ref.pxd +141 -0
  153. Cython/Includes/cpython/sequence.pxd +134 -0
  154. Cython/Includes/cpython/set.pxd +119 -0
  155. Cython/Includes/cpython/slice.pxd +70 -0
  156. Cython/Includes/cpython/time.pxd +129 -0
  157. Cython/Includes/cpython/tuple.pxd +72 -0
  158. Cython/Includes/cpython/type.pxd +53 -0
  159. Cython/Includes/cpython/unicode.pxd +639 -0
  160. Cython/Includes/cpython/version.pxd +32 -0
  161. Cython/Includes/cpython/weakref.pxd +78 -0
  162. Cython/Includes/libc/__init__.pxd +1 -0
  163. Cython/Includes/libc/complex.pxd +35 -0
  164. Cython/Includes/libc/errno.pxd +127 -0
  165. Cython/Includes/libc/float.pxd +43 -0
  166. Cython/Includes/libc/limits.pxd +28 -0
  167. Cython/Includes/libc/locale.pxd +46 -0
  168. Cython/Includes/libc/math.pxd +209 -0
  169. Cython/Includes/libc/setjmp.pxd +10 -0
  170. Cython/Includes/libc/signal.pxd +64 -0
  171. Cython/Includes/libc/stddef.pxd +9 -0
  172. Cython/Includes/libc/stdint.pxd +105 -0
  173. Cython/Includes/libc/stdio.pxd +80 -0
  174. Cython/Includes/libc/stdlib.pxd +72 -0
  175. Cython/Includes/libc/string.pxd +50 -0
  176. Cython/Includes/libc/threads.pxd +234 -0
  177. Cython/Includes/libc/time.pxd +52 -0
  178. Cython/Includes/libcpp/__init__.pxd +4 -0
  179. Cython/Includes/libcpp/algorithm.pxd +320 -0
  180. Cython/Includes/libcpp/any.pxd +16 -0
  181. Cython/Includes/libcpp/atomic.pxd +59 -0
  182. Cython/Includes/libcpp/barrier.pxd +22 -0
  183. Cython/Includes/libcpp/bit.pxd +29 -0
  184. Cython/Includes/libcpp/cast.pxd +12 -0
  185. Cython/Includes/libcpp/cmath.pxd +518 -0
  186. Cython/Includes/libcpp/complex.pxd +106 -0
  187. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  188. Cython/Includes/libcpp/deque.pxd +165 -0
  189. Cython/Includes/libcpp/exception.pxd +86 -0
  190. Cython/Includes/libcpp/execution.pxd +15 -0
  191. Cython/Includes/libcpp/forward_list.pxd +63 -0
  192. Cython/Includes/libcpp/functional.pxd +26 -0
  193. Cython/Includes/libcpp/future.pxd +103 -0
  194. Cython/Includes/libcpp/iterator.pxd +34 -0
  195. Cython/Includes/libcpp/latch.pxd +17 -0
  196. Cython/Includes/libcpp/limits.pxd +61 -0
  197. Cython/Includes/libcpp/list.pxd +117 -0
  198. Cython/Includes/libcpp/map.pxd +252 -0
  199. Cython/Includes/libcpp/memory.pxd +115 -0
  200. Cython/Includes/libcpp/mutex.pxd +387 -0
  201. Cython/Includes/libcpp/numbers.pxd +15 -0
  202. Cython/Includes/libcpp/numeric.pxd +131 -0
  203. Cython/Includes/libcpp/optional.pxd +34 -0
  204. Cython/Includes/libcpp/pair.pxd +1 -0
  205. Cython/Includes/libcpp/queue.pxd +25 -0
  206. Cython/Includes/libcpp/random.pxd +166 -0
  207. Cython/Includes/libcpp/semaphore.pxd +43 -0
  208. Cython/Includes/libcpp/set.pxd +228 -0
  209. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  210. Cython/Includes/libcpp/span.pxd +87 -0
  211. Cython/Includes/libcpp/stack.pxd +11 -0
  212. Cython/Includes/libcpp/stop_token.pxd +117 -0
  213. Cython/Includes/libcpp/string.pxd +355 -0
  214. Cython/Includes/libcpp/string_view.pxd +183 -0
  215. Cython/Includes/libcpp/typeindex.pxd +15 -0
  216. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  217. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  218. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  219. Cython/Includes/libcpp/utility.pxd +30 -0
  220. Cython/Includes/libcpp/vector.pxd +186 -0
  221. Cython/Includes/numpy/math.pxd +150 -0
  222. Cython/Includes/openmp.pxd +50 -0
  223. Cython/Includes/posix/__init__.pxd +1 -0
  224. Cython/Includes/posix/dlfcn.pxd +14 -0
  225. Cython/Includes/posix/fcntl.pxd +86 -0
  226. Cython/Includes/posix/ioctl.pxd +4 -0
  227. Cython/Includes/posix/mman.pxd +101 -0
  228. Cython/Includes/posix/resource.pxd +57 -0
  229. Cython/Includes/posix/select.pxd +21 -0
  230. Cython/Includes/posix/signal.pxd +73 -0
  231. Cython/Includes/posix/stat.pxd +98 -0
  232. Cython/Includes/posix/stdio.pxd +37 -0
  233. Cython/Includes/posix/stdlib.pxd +29 -0
  234. Cython/Includes/posix/strings.pxd +9 -0
  235. Cython/Includes/posix/time.pxd +71 -0
  236. Cython/Includes/posix/types.pxd +30 -0
  237. Cython/Includes/posix/uio.pxd +26 -0
  238. Cython/Includes/posix/unistd.pxd +271 -0
  239. Cython/Includes/posix/wait.pxd +38 -0
  240. Cython/Plex/Actions.pxd +24 -0
  241. Cython/Plex/Actions.py +119 -0
  242. Cython/Plex/Actions.pyd +0 -0
  243. Cython/Plex/DFA.pxd +14 -0
  244. Cython/Plex/DFA.py +164 -0
  245. Cython/Plex/DFA.pyd +0 -0
  246. Cython/Plex/Errors.py +48 -0
  247. Cython/Plex/Lexicons.py +178 -0
  248. Cython/Plex/Machines.pxd +36 -0
  249. Cython/Plex/Machines.py +238 -0
  250. Cython/Plex/Machines.pyd +0 -0
  251. Cython/Plex/Regexps.py +535 -0
  252. Cython/Plex/Scanners.pxd +45 -0
  253. Cython/Plex/Scanners.py +328 -0
  254. Cython/Plex/Scanners.pyd +0 -0
  255. Cython/Plex/Transitions.pxd +14 -0
  256. Cython/Plex/Transitions.py +239 -0
  257. Cython/Plex/Transitions.pyd +0 -0
  258. Cython/Plex/__init__.py +34 -0
  259. Cython/Runtime/__init__.py +1 -0
  260. Cython/Runtime/refnanny.pyd +0 -0
  261. Cython/Runtime/refnanny.pyx +237 -0
  262. Cython/Shadow.py +690 -0
  263. Cython/Shadow.pyi +521 -0
  264. Cython/StringIOTree.py +170 -0
  265. Cython/StringIOTree.pyd +0 -0
  266. Cython/Tempita/__init__.py +4 -0
  267. Cython/Tempita/_looper.py +154 -0
  268. Cython/Tempita/_tempita.py +1091 -0
  269. Cython/Tempita/_tempita.pyd +0 -0
  270. Cython/TestUtils.py +422 -0
  271. Cython/Tests/TestCodeWriter.py +128 -0
  272. Cython/Tests/TestCythonUtils.py +202 -0
  273. Cython/Tests/TestJediTyper.py +223 -0
  274. Cython/Tests/TestShadow.py +114 -0
  275. Cython/Tests/TestStringIOTree.py +67 -0
  276. Cython/Tests/TestTestUtils.py +90 -0
  277. Cython/Tests/__init__.py +1 -0
  278. Cython/Tests/xmlrunner.py +390 -0
  279. Cython/Utility/AsyncGen.c +1031 -0
  280. Cython/Utility/Buffer.c +865 -0
  281. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  282. Cython/Utility/Builtins.c +810 -0
  283. Cython/Utility/CConvert.pyx +134 -0
  284. Cython/Utility/CMath.c +104 -0
  285. Cython/Utility/CommonStructures.c +226 -0
  286. Cython/Utility/Complex.c +378 -0
  287. Cython/Utility/Coroutine.c +2300 -0
  288. Cython/Utility/CpdefEnums.pyx +103 -0
  289. Cython/Utility/CppConvert.pyx +282 -0
  290. Cython/Utility/CppSupport.cpp +151 -0
  291. Cython/Utility/CythonFunction.c +1832 -0
  292. Cython/Utility/Dataclasses.c +101 -0
  293. Cython/Utility/Embed.c +121 -0
  294. Cython/Utility/Exceptions.c +1016 -0
  295. Cython/Utility/ExtensionTypes.c +996 -0
  296. Cython/Utility/FunctionArguments.c +1043 -0
  297. Cython/Utility/FusedFunction.pyx +44 -0
  298. Cython/Utility/ImportExport.c +907 -0
  299. Cython/Utility/MemoryView.pxd +188 -0
  300. Cython/Utility/MemoryView.pyx +1482 -0
  301. Cython/Utility/MemoryView_C.c +927 -0
  302. Cython/Utility/ModuleSetupCode.c +3203 -0
  303. Cython/Utility/NumpyImportArray.c +46 -0
  304. Cython/Utility/ObjectHandling.c +3273 -0
  305. Cython/Utility/Optimize.c +1603 -0
  306. Cython/Utility/Overflow.c +384 -0
  307. Cython/Utility/Printing.c +86 -0
  308. Cython/Utility/Profile.c +732 -0
  309. Cython/Utility/StringTools.c +1379 -0
  310. Cython/Utility/Synchronization.c +399 -0
  311. Cython/Utility/TString.c +356 -0
  312. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  313. Cython/Utility/TestCythonScope.pyx +75 -0
  314. Cython/Utility/TestUtilityLoader.c +12 -0
  315. Cython/Utility/TypeConversion.c +1385 -0
  316. Cython/Utility/UFuncs.pyx +50 -0
  317. Cython/Utility/UFuncs_C.c +89 -0
  318. Cython/Utility/__init__.py +28 -0
  319. Cython/Utility/arrayarray.h +167 -0
  320. Cython/Utils.py +687 -0
  321. Cython/Utils.pyd +0 -0
  322. Cython/__init__.py +10 -0
  323. Cython/__init__.pyi +7 -0
  324. Cython/py.typed +0 -0
  325. cython-3.2.0.dist-info/METADATA +85 -0
  326. cython-3.2.0.dist-info/RECORD +333 -0
  327. cython-3.2.0.dist-info/WHEEL +5 -0
  328. cython-3.2.0.dist-info/entry_points.txt +4 -0
  329. cython-3.2.0.dist-info/top_level.txt +3 -0
  330. cython.py +29 -0
  331. pyximport/__init__.py +4 -0
  332. pyximport/pyxbuild.py +160 -0
  333. pyximport/pyximport.py +482 -0
@@ -0,0 +1,1016 @@
1
+ // Exception raising code
2
+ //
3
+ // Exceptions are raised by __Pyx_Raise() and stored as plain
4
+ // type/value/tb in PyThreadState->curexc_*. When being caught by an
5
+ // 'except' statement, curexc_* is moved over to exc_* by
6
+ // __Pyx_GetException()
7
+
8
+
9
+ /////////////// AssertionsEnabled.init ///////////////
10
+
11
+ if (likely(__Pyx_init_assertions_enabled() == 0)); else
12
+ // error propagation code is appended automatically
13
+
14
+ /////////////// AssertionsEnabled.proto ///////////////
15
+
16
+ #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000
17
+ // Py_OptimizeFlag is deprecated in Py3.12+ and not available in the Limited API.
18
+ static int __pyx_assertions_enabled_flag;
19
+ #define __pyx_assertions_enabled() (__pyx_assertions_enabled_flag)
20
+
21
+ static int __Pyx_init_assertions_enabled(void) {
22
+ PyObject *builtins, *debug, *debug_str;
23
+ int flag;
24
+ builtins = PyEval_GetBuiltins();
25
+ if (!builtins) goto bad;
26
+ // Not using PYIDENT() here because we probably don't need the string more than this once.
27
+ debug_str = PyUnicode_FromStringAndSize("__debug__", 9);
28
+ if (!debug_str) goto bad;
29
+ debug = PyObject_GetItem(builtins, debug_str);
30
+ Py_DECREF(debug_str);
31
+ if (!debug) goto bad;
32
+ flag = PyObject_IsTrue(debug);
33
+ Py_DECREF(debug);
34
+ if (flag == -1) goto bad;
35
+ __pyx_assertions_enabled_flag = flag;
36
+ return 0;
37
+ bad:
38
+ __pyx_assertions_enabled_flag = 1;
39
+ // We (rarely) may not have an exception set, but the calling code will call PyErr_Occurred() either way.
40
+ return -1;
41
+ }
42
+ #else
43
+ #define __Pyx_init_assertions_enabled() (0)
44
+ #define __pyx_assertions_enabled() (!Py_OptimizeFlag)
45
+ #endif
46
+
47
+
48
+ /////////////// ErrOccurredWithGIL.proto ///////////////
49
+ static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */
50
+
51
+ /////////////// ErrOccurredWithGIL ///////////////
52
+ static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) {
53
+ int err;
54
+ PyGILState_STATE _save = PyGILState_Ensure();
55
+ err = !!PyErr_Occurred();
56
+ PyGILState_Release(_save);
57
+ return err;
58
+ }
59
+
60
+
61
+ /////////////// PyThreadStateGet.proto ///////////////
62
+ //@substitute: naming
63
+
64
+ #if CYTHON_FAST_THREAD_STATE
65
+ #define __Pyx_PyThreadState_declare PyThreadState *$local_tstate_cname;
66
+ #define __Pyx_PyThreadState_assign $local_tstate_cname = __Pyx_PyThreadState_Current;
67
+ #if PY_VERSION_HEX >= 0x030C00A6
68
+ #define __Pyx_PyErr_Occurred() ($local_tstate_cname->current_exception != NULL)
69
+ #define __Pyx_PyErr_CurrentExceptionType() ($local_tstate_cname->current_exception ? (PyObject*) Py_TYPE($local_tstate_cname->current_exception) : (PyObject*) NULL)
70
+ #else
71
+ #define __Pyx_PyErr_Occurred() ($local_tstate_cname->curexc_type != NULL)
72
+ #define __Pyx_PyErr_CurrentExceptionType() ($local_tstate_cname->curexc_type)
73
+ #endif
74
+ #else
75
+ // !CYTHON_FAST_THREAD_STATE
76
+ #define __Pyx_PyThreadState_declare
77
+ #define __Pyx_PyThreadState_assign
78
+ #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
79
+ #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
80
+ #endif
81
+
82
+
83
+ /////////////// PyErrExceptionMatches.proto ///////////////
84
+ //@substitute: naming
85
+
86
+ #if CYTHON_FAST_THREAD_STATE
87
+ #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState($local_tstate_cname, err)
88
+ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
89
+ #else
90
+ #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
91
+ #endif
92
+
93
+ /////////////// PyErrExceptionMatches ///////////////
94
+
95
+ #if CYTHON_FAST_THREAD_STATE
96
+ static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
97
+ Py_ssize_t i, n;
98
+ n = PyTuple_GET_SIZE(tuple);
99
+ // the tighter subtype checking in Py3 allows faster out-of-order comparison
100
+ for (i=0; i<n; i++) {
101
+ if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
102
+ }
103
+ for (i=0; i<n; i++) {
104
+ if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
105
+ }
106
+ return 0;
107
+ }
108
+
109
+ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
110
+ int result;
111
+ PyObject *exc_type;
112
+ #if PY_VERSION_HEX >= 0x030C00A6
113
+ PyObject *current_exception = tstate->current_exception;
114
+ if (unlikely(!current_exception)) return 0;
115
+ exc_type = (PyObject*) Py_TYPE(current_exception);
116
+ if (exc_type == err) return 1;
117
+ #else
118
+ exc_type = tstate->curexc_type;
119
+ if (exc_type == err) return 1;
120
+ if (unlikely(!exc_type)) return 0;
121
+ #endif
122
+ #if CYTHON_AVOID_BORROWED_REFS
123
+ Py_INCREF(exc_type);
124
+ #endif
125
+ if (unlikely(PyTuple_Check(err))) {
126
+ result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
127
+ } else {
128
+ result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
129
+ }
130
+ #if CYTHON_AVOID_BORROWED_REFS
131
+ Py_DECREF(exc_type);
132
+ #endif
133
+ return result;
134
+ }
135
+ #endif
136
+
137
+ /////////////// PyErrFetchRestore.proto ///////////////
138
+ //@substitute: naming
139
+ //@requires: PyThreadStateGet
140
+
141
+ #if CYTHON_FAST_THREAD_STATE
142
+ #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
143
+ #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
144
+ #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
145
+ #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState($local_tstate_cname, type, value, tb)
146
+ #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState($local_tstate_cname, type, value, tb)
147
+ static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/
148
+ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
149
+
150
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
151
+ #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
152
+ #else
153
+ #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
154
+ #endif
155
+
156
+ #else
157
+ #define __Pyx_PyErr_Clear() PyErr_Clear()
158
+ #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
159
+ #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
160
+ #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
161
+ #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
162
+ #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
163
+ #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
164
+ #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
165
+ #endif
166
+
167
+ /////////////// PyErrFetchRestore ///////////////
168
+
169
+ #if CYTHON_FAST_THREAD_STATE
170
+ static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
171
+ #if PY_VERSION_HEX >= 0x030C00A6
172
+ PyObject *tmp_value;
173
+ assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
174
+ if (value) {
175
+ #if CYTHON_COMPILING_IN_CPYTHON
176
+ if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
177
+ #endif
178
+ // If this fails, we may lose the traceback but still set the expected exception below.
179
+ PyException_SetTraceback(value, tb);
180
+ }
181
+ tmp_value = tstate->current_exception;
182
+ tstate->current_exception = value;
183
+ Py_XDECREF(tmp_value);
184
+ Py_XDECREF(type);
185
+ Py_XDECREF(tb);
186
+ #else
187
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
188
+ tmp_type = tstate->curexc_type;
189
+ tmp_value = tstate->curexc_value;
190
+ tmp_tb = tstate->curexc_traceback;
191
+ tstate->curexc_type = type;
192
+ tstate->curexc_value = value;
193
+ tstate->curexc_traceback = tb;
194
+ Py_XDECREF(tmp_type);
195
+ Py_XDECREF(tmp_value);
196
+ Py_XDECREF(tmp_tb);
197
+ #endif
198
+ }
199
+
200
+ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
201
+ #if PY_VERSION_HEX >= 0x030C00A6
202
+ PyObject* exc_value;
203
+ exc_value = tstate->current_exception;
204
+ tstate->current_exception = 0;
205
+ *value = exc_value;
206
+ *type = NULL;
207
+ *tb = NULL;
208
+ if (exc_value) {
209
+ *type = (PyObject*) Py_TYPE(exc_value);
210
+ Py_INCREF(*type);
211
+ #if CYTHON_COMPILING_IN_CPYTHON
212
+ *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
213
+ Py_XINCREF(*tb);
214
+ #else
215
+ *tb = PyException_GetTraceback(exc_value);
216
+ #endif
217
+ }
218
+ #else
219
+ *type = tstate->curexc_type;
220
+ *value = tstate->curexc_value;
221
+ *tb = tstate->curexc_traceback;
222
+ tstate->curexc_type = 0;
223
+ tstate->curexc_value = 0;
224
+ tstate->curexc_traceback = 0;
225
+ #endif
226
+ }
227
+ #endif
228
+
229
+ /////////////// RaiseException.export ///////////////
230
+
231
+ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
232
+
233
+ /////////////// RaiseException ///////////////
234
+ //@requires: PyErrFetchRestore
235
+ //@requires: PyThreadStateGet
236
+
237
+ // The following function is based on do_raise() from ceval.c.
238
+
239
+ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
240
+ PyObject* owned_instance = NULL;
241
+ if (tb == Py_None) {
242
+ tb = 0;
243
+ } else if (tb && !PyTraceBack_Check(tb)) {
244
+ PyErr_SetString(PyExc_TypeError,
245
+ "raise: arg 3 must be a traceback or None");
246
+ goto bad;
247
+ }
248
+ if (value == Py_None)
249
+ value = 0;
250
+
251
+ if (PyExceptionInstance_Check(type)) {
252
+ if (value) {
253
+ PyErr_SetString(PyExc_TypeError,
254
+ "instance exception may not have a separate value");
255
+ goto bad;
256
+ }
257
+ value = type;
258
+ type = (PyObject*) Py_TYPE(value);
259
+ } else if (PyExceptionClass_Check(type)) {
260
+ // make sure value is an exception instance of type
261
+ PyObject *instance_class = NULL;
262
+ if (value && PyExceptionInstance_Check(value)) {
263
+ instance_class = (PyObject*) Py_TYPE(value);
264
+ if (instance_class != type) {
265
+ int is_subclass = PyObject_IsSubclass(instance_class, type);
266
+ if (!is_subclass) {
267
+ instance_class = NULL;
268
+ } else if (unlikely(is_subclass == -1)) {
269
+ // error on subclass test
270
+ goto bad;
271
+ } else {
272
+ // believe the instance
273
+ type = instance_class;
274
+ }
275
+ }
276
+ }
277
+ if (!instance_class) {
278
+ // instantiate the type now (we don't know when and how it will be caught)
279
+ // assuming that 'value' is an argument to the type's constructor
280
+ // not using PyErr_NormalizeException() to avoid ref-counting problems
281
+ PyObject *args;
282
+ if (!value)
283
+ args = PyTuple_New(0);
284
+ else if (PyTuple_Check(value)) {
285
+ Py_INCREF(value);
286
+ args = value;
287
+ } else
288
+ args = PyTuple_Pack(1, value);
289
+ if (!args)
290
+ goto bad;
291
+ owned_instance = PyObject_Call(type, args, NULL);
292
+ Py_DECREF(args);
293
+ if (!owned_instance)
294
+ goto bad;
295
+ value = owned_instance;
296
+ if (!PyExceptionInstance_Check(value)) {
297
+ PyErr_Format(PyExc_TypeError,
298
+ "calling %R should have returned an instance of "
299
+ "BaseException, not %R",
300
+ type, Py_TYPE(value));
301
+ goto bad;
302
+ }
303
+ }
304
+ } else {
305
+ PyErr_SetString(PyExc_TypeError,
306
+ "raise: exception class must be a subclass of BaseException");
307
+ goto bad;
308
+ }
309
+
310
+ if (cause) {
311
+ PyObject *fixed_cause;
312
+ if (cause == Py_None) {
313
+ // raise ... from None
314
+ fixed_cause = NULL;
315
+ } else if (PyExceptionClass_Check(cause)) {
316
+ fixed_cause = PyObject_CallObject(cause, NULL);
317
+ if (fixed_cause == NULL)
318
+ goto bad;
319
+ } else if (PyExceptionInstance_Check(cause)) {
320
+ fixed_cause = cause;
321
+ Py_INCREF(fixed_cause);
322
+ } else {
323
+ PyErr_SetString(PyExc_TypeError,
324
+ "exception causes must derive from "
325
+ "BaseException");
326
+ goto bad;
327
+ }
328
+ PyException_SetCause(value, fixed_cause);
329
+ }
330
+
331
+ PyErr_SetObject(type, value);
332
+
333
+ if (tb) {
334
+ #if PY_VERSION_HEX >= 0x030C00A6
335
+ // If this fails, we just get a different exception, so ignore the return value.
336
+ PyException_SetTraceback(value, tb);
337
+ #elif CYTHON_FAST_THREAD_STATE
338
+ PyThreadState *tstate = __Pyx_PyThreadState_Current;
339
+ PyObject* tmp_tb = tstate->curexc_traceback;
340
+ if (tb != tmp_tb) {
341
+ Py_INCREF(tb);
342
+ tstate->curexc_traceback = tb;
343
+ Py_XDECREF(tmp_tb);
344
+ }
345
+ #else
346
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
347
+ PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
348
+ Py_INCREF(tb);
349
+ PyErr_Restore(tmp_type, tmp_value, tb);
350
+ Py_XDECREF(tmp_tb);
351
+ #endif
352
+ }
353
+
354
+ bad:
355
+ Py_XDECREF(owned_instance);
356
+ return;
357
+ }
358
+
359
+
360
+ /////////////// GetTopmostException.proto ///////////////
361
+
362
+ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
363
+ static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
364
+ #endif
365
+
366
+ /////////////// GetTopmostException ///////////////
367
+
368
+ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
369
+ // Copied from errors.c in CPython.
370
+ static _PyErr_StackItem *
371
+ __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
372
+ {
373
+ _PyErr_StackItem *exc_info = tstate->exc_info;
374
+ while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
375
+ exc_info->previous_item != NULL)
376
+ {
377
+ exc_info = exc_info->previous_item;
378
+ }
379
+ return exc_info;
380
+ }
381
+ #endif
382
+
383
+
384
+ /////////////// GetException.proto ///////////////
385
+ //@substitute: naming
386
+ //@requires: PyThreadStateGet
387
+
388
+ #if CYTHON_FAST_THREAD_STATE
389
+ #define __Pyx_GetException(type, value, tb) __Pyx__GetException($local_tstate_cname, type, value, tb)
390
+ static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
391
+ #else
392
+ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
393
+ #endif
394
+
395
+ /////////////// GetException ///////////////
396
+
397
+ #if CYTHON_FAST_THREAD_STATE
398
+ static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
399
+ #else
400
+ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
401
+ #endif
402
+ {
403
+ PyObject *local_type = NULL, *local_value, *local_tb = NULL;
404
+ #if CYTHON_FAST_THREAD_STATE
405
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
406
+ #if PY_VERSION_HEX >= 0x030C0000
407
+ local_value = tstate->current_exception;
408
+ tstate->current_exception = 0;
409
+ #else
410
+ local_type = tstate->curexc_type;
411
+ local_value = tstate->curexc_value;
412
+ local_tb = tstate->curexc_traceback;
413
+ tstate->curexc_type = 0;
414
+ tstate->curexc_value = 0;
415
+ tstate->curexc_traceback = 0;
416
+ #endif
417
+ #elif __PYX_LIMITED_VERSION_HEX > 0x030C0000
418
+ local_value = PyErr_GetRaisedException();
419
+ #else
420
+ PyErr_Fetch(&local_type, &local_value, &local_tb);
421
+ #endif
422
+
423
+ #if __PYX_LIMITED_VERSION_HEX > 0x030C0000
424
+ if (likely(local_value)) {
425
+ local_type = (PyObject*) Py_TYPE(local_value);
426
+ Py_INCREF(local_type);
427
+ local_tb = PyException_GetTraceback(local_value);
428
+ }
429
+ #else
430
+ // Note that In Python 3.12+ exceptions are already normalized
431
+ PyErr_NormalizeException(&local_type, &local_value, &local_tb);
432
+ #if CYTHON_FAST_THREAD_STATE
433
+ if (unlikely(tstate->curexc_type))
434
+ #else
435
+ if (unlikely(PyErr_Occurred()))
436
+ #endif
437
+ goto bad;
438
+
439
+ // Note that in Python 3.12 the traceback came directly from local_value anyway.
440
+ if (local_tb) {
441
+ if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
442
+ goto bad;
443
+ }
444
+ #endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000
445
+
446
+ // traceback may be NULL for freshly raised exceptions
447
+ Py_XINCREF(local_tb);
448
+ // exception state may be empty in parallel loops (code-gen error where we don't generate a
449
+ // top-level PyGILState_Ensure surrounding the whole loop, and so releasing the GIL temporarily
450
+ // wipes the whole thread state).
451
+ Py_XINCREF(local_type);
452
+ Py_XINCREF(local_value);
453
+ *type = local_type;
454
+ *value = local_value;
455
+ *tb = local_tb;
456
+
457
+ #if CYTHON_FAST_THREAD_STATE
458
+ #if CYTHON_USE_EXC_INFO_STACK
459
+ {
460
+ _PyErr_StackItem *exc_info = tstate->exc_info;
461
+ #if PY_VERSION_HEX >= 0x030B00a4
462
+ tmp_value = exc_info->exc_value;
463
+ exc_info->exc_value = local_value;
464
+ tmp_type = NULL;
465
+ tmp_tb = NULL;
466
+ Py_XDECREF(local_type);
467
+ Py_XDECREF(local_tb);
468
+ #else
469
+ tmp_type = exc_info->exc_type;
470
+ tmp_value = exc_info->exc_value;
471
+ tmp_tb = exc_info->exc_traceback;
472
+ exc_info->exc_type = local_type;
473
+ exc_info->exc_value = local_value;
474
+ exc_info->exc_traceback = local_tb;
475
+ #endif
476
+ }
477
+ #else
478
+ tmp_type = tstate->exc_type;
479
+ tmp_value = tstate->exc_value;
480
+ tmp_tb = tstate->exc_traceback;
481
+ tstate->exc_type = local_type;
482
+ tstate->exc_value = local_value;
483
+ tstate->exc_traceback = local_tb;
484
+ #endif
485
+ // Make sure tstate is in a consistent state when we XDECREF
486
+ // these objects (DECREF may run arbitrary code).
487
+ Py_XDECREF(tmp_type);
488
+ Py_XDECREF(tmp_value);
489
+ Py_XDECREF(tmp_tb);
490
+ #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
491
+ PyErr_SetHandledException(local_value);
492
+ Py_XDECREF(local_value);
493
+ Py_XDECREF(local_type);
494
+ Py_XDECREF(local_tb);
495
+ #else
496
+ PyErr_SetExcInfo(local_type, local_value, local_tb);
497
+ #endif
498
+
499
+ return 0;
500
+
501
+ #if __PYX_LIMITED_VERSION_HEX <= 0x030C0000
502
+ bad:
503
+ *type = 0;
504
+ *value = 0;
505
+ *tb = 0;
506
+ Py_XDECREF(local_type);
507
+ Py_XDECREF(local_value);
508
+ Py_XDECREF(local_tb);
509
+ return -1;
510
+ #endif
511
+ }
512
+
513
+ /////////////// ReRaiseException.proto ///////////////
514
+
515
+ static CYTHON_INLINE void __Pyx_ReraiseException(void); /*proto*/
516
+
517
+ /////////////// ReRaiseException ///////////////
518
+ //@requires: GetTopmostException
519
+
520
+ static CYTHON_INLINE void __Pyx_ReraiseException(void) {
521
+ PyObject *type = NULL, *value = NULL, *tb = NULL;
522
+ #if CYTHON_FAST_THREAD_STATE
523
+ PyThreadState *tstate = PyThreadState_GET();
524
+ #if CYTHON_USE_EXC_INFO_STACK
525
+ _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
526
+ value = exc_info->exc_value;
527
+ #if PY_VERSION_HEX >= 0x030B00a4
528
+ if (unlikely(value == Py_None)) {
529
+ value = NULL;
530
+ } else if (value) {
531
+ Py_INCREF(value);
532
+ type = (PyObject*) Py_TYPE(value);
533
+ Py_INCREF(type);
534
+ tb = PyException_GetTraceback(value);
535
+ }
536
+ #else
537
+ type = exc_info->exc_type;
538
+ tb = exc_info->exc_traceback;
539
+ Py_XINCREF(type);
540
+ Py_XINCREF(value);
541
+ Py_XINCREF(tb);
542
+ #endif
543
+ #else
544
+ type = tstate->exc_type;
545
+ value = tstate->exc_value;
546
+ tb = tstate->exc_traceback;
547
+ Py_XINCREF(type);
548
+ Py_XINCREF(value);
549
+ Py_XINCREF(tb);
550
+ #endif
551
+ #else
552
+ PyErr_GetExcInfo(&type, &value, &tb);
553
+ #endif
554
+ if (unlikely(!type || type == Py_None)) {
555
+ Py_XDECREF(type);
556
+ Py_XDECREF(value);
557
+ Py_XDECREF(tb);
558
+ // message copied from Py3
559
+ PyErr_SetString(PyExc_RuntimeError,
560
+ "No active exception to reraise");
561
+ } else {
562
+ PyErr_Restore(type, value, tb);
563
+ }
564
+ }
565
+
566
+ /////////////// SaveResetException.proto ///////////////
567
+ //@substitute: naming
568
+ //@requires: PyThreadStateGet
569
+
570
+ #if CYTHON_FAST_THREAD_STATE
571
+ #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave($local_tstate_cname, type, value, tb)
572
+ static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
573
+ #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset($local_tstate_cname, type, value, tb)
574
+ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/
575
+
576
+ #else
577
+
578
+ #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
579
+ #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
580
+ #endif
581
+
582
+ /////////////// SaveResetException ///////////////
583
+ //@requires: GetTopmostException
584
+
585
+ #if CYTHON_FAST_THREAD_STATE
586
+ static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
587
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
588
+ _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
589
+ PyObject *exc_value = exc_info->exc_value;
590
+ if (exc_value == NULL || exc_value == Py_None) {
591
+ *value = NULL;
592
+ *type = NULL;
593
+ *tb = NULL;
594
+ } else {
595
+ *value = exc_value;
596
+ Py_INCREF(*value);
597
+ *type = (PyObject*) Py_TYPE(exc_value);
598
+ Py_INCREF(*type);
599
+ *tb = PyException_GetTraceback(exc_value);
600
+ }
601
+ #elif CYTHON_USE_EXC_INFO_STACK
602
+ _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
603
+ *type = exc_info->exc_type;
604
+ *value = exc_info->exc_value;
605
+ *tb = exc_info->exc_traceback;
606
+ Py_XINCREF(*type);
607
+ Py_XINCREF(*value);
608
+ Py_XINCREF(*tb);
609
+ #else
610
+ *type = tstate->exc_type;
611
+ *value = tstate->exc_value;
612
+ *tb = tstate->exc_traceback;
613
+ Py_XINCREF(*type);
614
+ Py_XINCREF(*value);
615
+ Py_XINCREF(*tb);
616
+ #endif
617
+ }
618
+
619
+ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
620
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
621
+ _PyErr_StackItem *exc_info = tstate->exc_info;
622
+ PyObject *tmp_value = exc_info->exc_value;
623
+ exc_info->exc_value = value;
624
+ Py_XDECREF(tmp_value);
625
+ // TODO: avoid passing these at all
626
+ Py_XDECREF(type);
627
+ Py_XDECREF(tb);
628
+ #else
629
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
630
+ #if CYTHON_USE_EXC_INFO_STACK
631
+ _PyErr_StackItem *exc_info = tstate->exc_info;
632
+ tmp_type = exc_info->exc_type;
633
+ tmp_value = exc_info->exc_value;
634
+ tmp_tb = exc_info->exc_traceback;
635
+ exc_info->exc_type = type;
636
+ exc_info->exc_value = value;
637
+ exc_info->exc_traceback = tb;
638
+ #else
639
+ tmp_type = tstate->exc_type;
640
+ tmp_value = tstate->exc_value;
641
+ tmp_tb = tstate->exc_traceback;
642
+ tstate->exc_type = type;
643
+ tstate->exc_value = value;
644
+ tstate->exc_traceback = tb;
645
+ #endif
646
+ Py_XDECREF(tmp_type);
647
+ Py_XDECREF(tmp_value);
648
+ Py_XDECREF(tmp_tb);
649
+ #endif
650
+ }
651
+ #endif
652
+
653
+ /////////////// SwapException.proto ///////////////
654
+ //@substitute: naming
655
+ //@requires: PyThreadStateGet
656
+
657
+ #if CYTHON_FAST_THREAD_STATE
658
+ #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap($local_tstate_cname, type, value, tb)
659
+ static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
660
+ #else
661
+ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
662
+ #endif
663
+
664
+ /////////////// SwapException ///////////////
665
+
666
+ #if CYTHON_FAST_THREAD_STATE
667
+ static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
668
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
669
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
670
+ _PyErr_StackItem *exc_info = tstate->exc_info;
671
+ tmp_value = exc_info->exc_value;
672
+ exc_info->exc_value = *value;
673
+ if (tmp_value == NULL || tmp_value == Py_None) {
674
+ Py_XDECREF(tmp_value);
675
+ tmp_value = NULL;
676
+ tmp_type = NULL;
677
+ tmp_tb = NULL;
678
+ } else {
679
+ // TODO: avoid swapping these at all
680
+ tmp_type = (PyObject*) Py_TYPE(tmp_value);
681
+ Py_INCREF(tmp_type);
682
+ #if CYTHON_COMPILING_IN_CPYTHON
683
+ tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
684
+ Py_XINCREF(tmp_tb);
685
+ #else
686
+ tmp_tb = PyException_GetTraceback(tmp_value);
687
+ #endif
688
+ }
689
+ #elif CYTHON_USE_EXC_INFO_STACK
690
+ _PyErr_StackItem *exc_info = tstate->exc_info;
691
+ tmp_type = exc_info->exc_type;
692
+ tmp_value = exc_info->exc_value;
693
+ tmp_tb = exc_info->exc_traceback;
694
+
695
+ exc_info->exc_type = *type;
696
+ exc_info->exc_value = *value;
697
+ exc_info->exc_traceback = *tb;
698
+ #else
699
+ tmp_type = tstate->exc_type;
700
+ tmp_value = tstate->exc_value;
701
+ tmp_tb = tstate->exc_traceback;
702
+
703
+ tstate->exc_type = *type;
704
+ tstate->exc_value = *value;
705
+ tstate->exc_traceback = *tb;
706
+ #endif
707
+
708
+ *type = tmp_type;
709
+ *value = tmp_value;
710
+ *tb = tmp_tb;
711
+ }
712
+
713
+ #else
714
+
715
+ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
716
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
717
+ PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
718
+ PyErr_SetExcInfo(*type, *value, *tb);
719
+ *type = tmp_type;
720
+ *value = tmp_value;
721
+ *tb = tmp_tb;
722
+ }
723
+ #endif
724
+
725
+ /////////////// WriteUnraisableException.proto ///////////////
726
+
727
+ static void __Pyx_WriteUnraisable(const char *name, int clineno,
728
+ int lineno, const char *filename,
729
+ int full_traceback, int nogil); /*proto*/
730
+
731
+ /////////////// WriteUnraisableException ///////////////
732
+ //@requires: PyErrFetchRestore
733
+ //@requires: PyThreadStateGet
734
+
735
+ static void __Pyx_WriteUnraisable(const char *name, int clineno,
736
+ int lineno, const char *filename,
737
+ int full_traceback, int nogil) {
738
+ PyObject *old_exc, *old_val, *old_tb;
739
+ PyObject *ctx;
740
+ __Pyx_PyThreadState_declare
741
+ PyGILState_STATE state;
742
+ if (nogil)
743
+ state = PyGILState_Ensure();
744
+ /* arbitrary, to suppress warning */
745
+ else state = (PyGILState_STATE)0;
746
+ CYTHON_UNUSED_VAR(clineno);
747
+ CYTHON_UNUSED_VAR(lineno);
748
+ CYTHON_UNUSED_VAR(filename);
749
+ CYTHON_MAYBE_UNUSED_VAR(nogil);
750
+
751
+ __Pyx_PyThreadState_assign
752
+ __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
753
+ if (full_traceback) {
754
+ Py_XINCREF(old_exc);
755
+ Py_XINCREF(old_val);
756
+ Py_XINCREF(old_tb);
757
+ __Pyx_ErrRestore(old_exc, old_val, old_tb);
758
+ PyErr_PrintEx(0);
759
+ }
760
+ ctx = PyUnicode_FromString(name);
761
+ __Pyx_ErrRestore(old_exc, old_val, old_tb);
762
+ if (!ctx) {
763
+ PyErr_WriteUnraisable(Py_None);
764
+ } else {
765
+ PyErr_WriteUnraisable(ctx);
766
+ Py_DECREF(ctx);
767
+ }
768
+ if (nogil)
769
+ PyGILState_Release(state);
770
+ }
771
+
772
+ /////////////// CLineInTraceback.proto ///////////////
773
+
774
+ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
775
+ static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);/*proto*/
776
+ #else
777
+ #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
778
+ #endif
779
+
780
+ /////////////// CLineInTraceback ///////////////
781
+ //@requires: ObjectHandling.c::PyObjectGetAttrStrNoError
782
+ //@requires: ObjectHandling.c::PyDictVersioning
783
+ //@requires: PyErrFetchRestore
784
+ //@requires: Builtins.c::dict_setdefault
785
+
786
+ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
787
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
788
+ // On earlier version of the Limited API we're less flexible and assume it's
789
+ // definitely a module. Which will break some odd user monkey-patching...
790
+ #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
791
+ #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
792
+ // On freethreading, use PyObject_GenericGetDict to avoid having to think too hard
793
+ // about atomics and _PyObject_GetDictPtr.
794
+ #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
795
+ #else
796
+ PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
797
+ PyObject **dict_ptr = _PyObject_GetDictPtr(o);
798
+ return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
799
+ }
800
+ #endif
801
+
802
+
803
+ static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
804
+ PyObject *use_cline = NULL;
805
+ PyObject *ptype, *pvalue, *ptraceback;
806
+ PyObject *cython_runtime_dict;
807
+
808
+ CYTHON_MAYBE_UNUSED_VAR(tstate);
809
+
810
+ if (unlikely(!NAMED_CGLOBAL(cython_runtime_cname))) {
811
+ // Very early error where the runtime module is not set up yet.
812
+ return c_line;
813
+ }
814
+
815
+ __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
816
+
817
+ cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(NAMED_CGLOBAL(cython_runtime_cname));
818
+ if (likely(cython_runtime_dict)) {
819
+ __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
820
+ use_cline, cython_runtime_dict,
821
+ __Pyx_PyDict_SetDefault(cython_runtime_dict, PYIDENT("cline_in_traceback"), Py_False))
822
+ }
823
+ if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
824
+ c_line = 0;
825
+ }
826
+ Py_XDECREF(use_cline);
827
+ Py_XDECREF(cython_runtime_dict);
828
+ __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
829
+ return c_line;
830
+ }
831
+ #endif
832
+
833
+ /////////////// AddTraceback.proto ///////////////
834
+
835
+ static void __Pyx_AddTraceback(const char *funcname, int c_line,
836
+ int py_line, const char *filename); /*proto*/
837
+
838
+ /////////////// AddTraceback ///////////////
839
+ //@requires: ModuleSetupCode.c::CodeObjectCache
840
+ //@requires: CLineInTraceback
841
+ //@substitute: naming
842
+
843
+ #include "compile.h"
844
+ #include "frameobject.h"
845
+ #include "traceback.h"
846
+ #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
847
+ #ifndef Py_BUILD_CORE
848
+ #define Py_BUILD_CORE 1
849
+ #endif
850
+ #include "internal/pycore_frame.h"
851
+ #endif
852
+
853
+ #if CYTHON_COMPILING_IN_LIMITED_API
854
+ static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
855
+ PyObject *firstlineno, PyObject *name) {
856
+ PyObject *replace = NULL;
857
+ if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
858
+ if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
859
+
860
+ replace = PyObject_GetAttrString(code, "replace");
861
+ if (likely(replace)) {
862
+ PyObject *result = PyObject_Call(replace, EMPTY(tuple), scratch_dict);
863
+ Py_DECREF(replace);
864
+ return result;
865
+ }
866
+ PyErr_Clear();
867
+
868
+ return NULL;
869
+ }
870
+
871
+ static void __Pyx_AddTraceback(const char *funcname, int c_line,
872
+ int py_line, const char *filename) {
873
+ PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
874
+ PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
875
+ PyObject *exc_type, *exc_value, *exc_traceback;
876
+ int success = 0;
877
+ if (c_line) {
878
+ c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
879
+ }
880
+
881
+ // DW - this is a horrendous hack, but I'm quite proud of it. Essentially
882
+ // we need to generate a frame with the right line number/filename/funcname.
883
+ // We do this by compiling a small bit of code that uses sys._getframe to get a
884
+ // frame, and then customizing the details of the code to match.
885
+ // We then run the code object and use the generated frame to set the traceback.
886
+
887
+ PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
888
+
889
+ code_object = $global_code_object_cache_find(c_line ? -c_line : py_line);
890
+ if (!code_object) {
891
+ code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
892
+ if (unlikely(!code_object)) goto bad;
893
+ py_py_line = PyLong_FromLong(py_line);
894
+ if (unlikely(!py_py_line)) goto bad;
895
+ if (c_line) {
896
+ py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line);
897
+ } else {
898
+ py_funcname = PyUnicode_FromString(funcname);
899
+ }
900
+ if (unlikely(!py_funcname)) goto bad;
901
+ dict = PyDict_New();
902
+ if (unlikely(!dict)) goto bad;
903
+ {
904
+ PyObject *old_code_object = code_object;
905
+ code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
906
+ Py_DECREF(old_code_object);
907
+ }
908
+ if (unlikely(!code_object)) goto bad;
909
+
910
+ $global_code_object_cache_insert(c_line ? -c_line : py_line, code_object);
911
+ } else {
912
+ // The frame part still expects a dict
913
+ dict = PyDict_New();
914
+ }
915
+
916
+ // Note that getframe is borrowed
917
+ getframe = PySys_GetObject("_getframe");
918
+ if (unlikely(!getframe)) goto bad;
919
+ // reuse dict as globals (nothing conflicts, and it saves an allocation)
920
+ if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
921
+
922
+ frame = PyEval_EvalCode(code_object, dict, dict);
923
+ if (unlikely(!frame) || frame == Py_None) goto bad;
924
+ success = 1;
925
+
926
+ bad:
927
+ PyErr_Restore(exc_type, exc_value, exc_traceback);
928
+ Py_XDECREF(code_object);
929
+ Py_XDECREF(py_py_line);
930
+ Py_XDECREF(py_funcname);
931
+ Py_XDECREF(dict);
932
+ Py_XDECREF(replace);
933
+
934
+ if (success) {
935
+ // Unfortunately an easy way to check the type of frame isn't in the
936
+ // limited API. The check against None should cover the most
937
+ // likely wrong answer though.
938
+ PyTraceBack_Here(
939
+ // Python < 0x03090000 didn't expose PyFrameObject
940
+ // but they all expose struct _frame as an opaque type
941
+ (struct _frame*)frame);
942
+ }
943
+
944
+ Py_XDECREF(frame);
945
+ }
946
+ #else
947
+ static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
948
+ const char *funcname, int c_line,
949
+ int py_line, const char *filename) {
950
+ PyCodeObject *py_code = NULL;
951
+ PyObject *py_funcname = NULL;
952
+
953
+ if (c_line) {
954
+ py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line);
955
+ if (!py_funcname) goto bad;
956
+ funcname = PyUnicode_AsUTF8(py_funcname);
957
+ if (!funcname) goto bad;
958
+ }
959
+ py_code = PyCode_NewEmpty(filename, funcname, py_line);
960
+ Py_XDECREF(py_funcname); /* XDECREF since it's only set on Py3 if cline */
961
+ return py_code;
962
+ bad:
963
+ Py_XDECREF(py_funcname);
964
+ return NULL;
965
+ }
966
+
967
+ static void __Pyx_AddTraceback(const char *funcname, int c_line,
968
+ int py_line, const char *filename) {
969
+ PyCodeObject *py_code = 0;
970
+ PyFrameObject *py_frame = 0;
971
+ PyThreadState *tstate = __Pyx_PyThreadState_Current;
972
+ PyObject *ptype, *pvalue, *ptraceback;
973
+
974
+ if (c_line) {
975
+ c_line = __Pyx_CLineForTraceback(tstate, c_line);
976
+ }
977
+
978
+ // Negate to avoid collisions between py and c lines.
979
+ py_code = $global_code_object_cache_find(c_line ? -c_line : py_line);
980
+ if (!py_code) {
981
+ __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
982
+ py_code = __Pyx_CreateCodeObjectForTraceback(
983
+ funcname, c_line, py_line, filename);
984
+ if (!py_code) {
985
+ /* If the code object creation fails, then we should clear the
986
+ fetched exception references and propagate the new exception */
987
+ Py_XDECREF(ptype);
988
+ Py_XDECREF(pvalue);
989
+ Py_XDECREF(ptraceback);
990
+ goto bad;
991
+ }
992
+ __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
993
+ $global_code_object_cache_insert(c_line ? -c_line : py_line, py_code);
994
+ }
995
+ py_frame = PyFrame_New(
996
+ tstate, /*PyThreadState *tstate,*/
997
+ py_code, /*PyCodeObject *code,*/
998
+ NAMED_CGLOBAL(moddict_cname), /*PyObject *globals,*/
999
+ 0 /*PyObject *locals*/
1000
+ );
1001
+ if (!py_frame) goto bad;
1002
+ __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
1003
+ PyTraceBack_Here(py_frame);
1004
+ bad:
1005
+ Py_XDECREF(py_code);
1006
+ Py_XDECREF(py_frame);
1007
+ }
1008
+ #endif
1009
+
1010
+ ///////////////////////////// FloatExceptionCheck.proto ///////////////////////////
1011
+
1012
+ // Detect if error_value is NaN, and use a different check in that case
1013
+ #define __PYX_CHECK_FLOAT_EXCEPTION(value, error_value) \
1014
+ ((error_value) == (error_value) ? \
1015
+ (value) == (error_value) : \
1016
+ (value) != (value))