oxython 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. Cython/Build/BuildExecutable.py +156 -0
  2. Cython/Build/Cache.py +198 -0
  3. Cython/Build/Cythonize.py +349 -0
  4. Cython/Build/Dependencies.py +1320 -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 +222 -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.pxd +154 -0
  26. Cython/Compiler/Code.py +3760 -0
  27. Cython/Compiler/CodeGeneration.py +33 -0
  28. Cython/Compiler/CythonScope.py +208 -0
  29. Cython/Compiler/Dataclass.py +890 -0
  30. Cython/Compiler/DebugFlags.py +24 -0
  31. Cython/Compiler/Errors.py +310 -0
  32. Cython/Compiler/ExprNodes.py +16319 -0
  33. Cython/Compiler/FlowControl.pxd +112 -0
  34. Cython/Compiler/FlowControl.py +1575 -0
  35. Cython/Compiler/FusedNode.py +978 -0
  36. Cython/Compiler/Future.py +16 -0
  37. Cython/Compiler/Interpreter.py +57 -0
  38. Cython/Compiler/Lexicon.py +442 -0
  39. Cython/Compiler/LineTable.py +114 -0
  40. Cython/Compiler/Main.py +879 -0
  41. Cython/Compiler/MatchCaseNodes.py +2200 -0
  42. Cython/Compiler/MemoryView.py +930 -0
  43. Cython/Compiler/ModuleNode.py +4558 -0
  44. Cython/Compiler/Naming.py +370 -0
  45. Cython/Compiler/Nodes.py +11334 -0
  46. Cython/Compiler/Optimize.py +5563 -0
  47. Cython/Compiler/Options.py +841 -0
  48. Cython/Compiler/ParseTreeTransforms.pxd +80 -0
  49. Cython/Compiler/ParseTreeTransforms.py +4808 -0
  50. Cython/Compiler/Parsing.pxd +9 -0
  51. Cython/Compiler/Parsing.py +5442 -0
  52. Cython/Compiler/Pipeline.py +439 -0
  53. Cython/Compiler/PyrexTypes.py +6588 -0
  54. Cython/Compiler/Pythran.py +232 -0
  55. Cython/Compiler/Scanning.pxd +74 -0
  56. Cython/Compiler/Scanning.py +771 -0
  57. Cython/Compiler/StringEncoding.py +354 -0
  58. Cython/Compiler/Symtab.py +3122 -0
  59. Cython/Compiler/Tests/TestBuffer.py +105 -0
  60. Cython/Compiler/Tests/TestBuiltin.py +196 -0
  61. Cython/Compiler/Tests/TestCmdLine.py +652 -0
  62. Cython/Compiler/Tests/TestCode.py +145 -0
  63. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  64. Cython/Compiler/Tests/TestGrammar.py +202 -0
  65. Cython/Compiler/Tests/TestMemView.py +71 -0
  66. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  67. Cython/Compiler/Tests/TestScanning.py +132 -0
  68. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  69. Cython/Compiler/Tests/TestStringEncoding.py +20 -0
  70. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  71. Cython/Compiler/Tests/TestTreePath.py +103 -0
  72. Cython/Compiler/Tests/TestTypes.py +119 -0
  73. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  74. Cython/Compiler/Tests/TestVisitor.py +119 -0
  75. Cython/Compiler/Tests/Utils.py +36 -0
  76. Cython/Compiler/Tests/__init__.py +1 -0
  77. Cython/Compiler/TreeFragment.py +279 -0
  78. Cython/Compiler/TreePath.py +303 -0
  79. Cython/Compiler/TypeInference.py +626 -0
  80. Cython/Compiler/TypeSlots.py +1330 -0
  81. Cython/Compiler/UFuncs.py +317 -0
  82. Cython/Compiler/UtilNodes.py +389 -0
  83. Cython/Compiler/UtilityCode.py +354 -0
  84. Cython/Compiler/Version.py +8 -0
  85. Cython/Compiler/Visitor.pxd +52 -0
  86. Cython/Compiler/Visitor.py +914 -0
  87. Cython/Compiler/__init__.py +1 -0
  88. Cython/Coverage.py +448 -0
  89. Cython/Debugger/Cygdb.py +214 -0
  90. Cython/Debugger/DebugWriter.py +82 -0
  91. Cython/Debugger/Tests/TestLibCython.py +280 -0
  92. Cython/Debugger/Tests/__init__.py +1 -0
  93. Cython/Debugger/Tests/cfuncs.c +8 -0
  94. Cython/Debugger/Tests/codefile +49 -0
  95. Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
  96. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  97. Cython/Debugger/__init__.py +1 -0
  98. Cython/Debugger/libcython.py +1548 -0
  99. Cython/Debugger/libpython.py +2821 -0
  100. Cython/Debugging.py +20 -0
  101. Cython/Distutils/__init__.py +2 -0
  102. Cython/Distutils/build_ext.py +143 -0
  103. Cython/Distutils/extension.py +96 -0
  104. Cython/Distutils/old_build_ext.py +351 -0
  105. Cython/Includes/cpython/__init__.pxd +173 -0
  106. Cython/Includes/cpython/array.pxd +159 -0
  107. Cython/Includes/cpython/bool.pxd +37 -0
  108. Cython/Includes/cpython/buffer.pxd +112 -0
  109. Cython/Includes/cpython/bytearray.pxd +33 -0
  110. Cython/Includes/cpython/bytes.pxd +200 -0
  111. Cython/Includes/cpython/cellobject.pxd +35 -0
  112. Cython/Includes/cpython/ceval.pxd +8 -0
  113. Cython/Includes/cpython/codecs.pxd +121 -0
  114. Cython/Includes/cpython/complex.pxd +60 -0
  115. Cython/Includes/cpython/contextvars.pxd +145 -0
  116. Cython/Includes/cpython/conversion.pxd +36 -0
  117. Cython/Includes/cpython/datetime.pxd +395 -0
  118. Cython/Includes/cpython/descr.pxd +26 -0
  119. Cython/Includes/cpython/dict.pxd +268 -0
  120. Cython/Includes/cpython/exc.pxd +263 -0
  121. Cython/Includes/cpython/fileobject.pxd +57 -0
  122. Cython/Includes/cpython/float.pxd +56 -0
  123. Cython/Includes/cpython/frozendict.pxd +37 -0
  124. Cython/Includes/cpython/function.pxd +65 -0
  125. Cython/Includes/cpython/genobject.pxd +25 -0
  126. Cython/Includes/cpython/getargs.pxd +12 -0
  127. Cython/Includes/cpython/instance.pxd +25 -0
  128. Cython/Includes/cpython/iterator.pxd +36 -0
  129. Cython/Includes/cpython/iterobject.pxd +24 -0
  130. Cython/Includes/cpython/list.pxd +144 -0
  131. Cython/Includes/cpython/long.pxd +180 -0
  132. Cython/Includes/cpython/longintrepr.pxd +14 -0
  133. Cython/Includes/cpython/mapping.pxd +63 -0
  134. Cython/Includes/cpython/marshal.pxd +66 -0
  135. Cython/Includes/cpython/mem.pxd +120 -0
  136. Cython/Includes/cpython/memoryview.pxd +50 -0
  137. Cython/Includes/cpython/method.pxd +49 -0
  138. Cython/Includes/cpython/module.pxd +208 -0
  139. Cython/Includes/cpython/number.pxd +258 -0
  140. Cython/Includes/cpython/object.pxd +430 -0
  141. Cython/Includes/cpython/pycapsule.pxd +143 -0
  142. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  143. Cython/Includes/cpython/pyport.pxd +8 -0
  144. Cython/Includes/cpython/pystate.pxd +95 -0
  145. Cython/Includes/cpython/pythread.pxd +53 -0
  146. Cython/Includes/cpython/ref.pxd +141 -0
  147. Cython/Includes/cpython/sentinel.pxd +17 -0
  148. Cython/Includes/cpython/sequence.pxd +134 -0
  149. Cython/Includes/cpython/set.pxd +119 -0
  150. Cython/Includes/cpython/slice.pxd +70 -0
  151. Cython/Includes/cpython/time.pxd +129 -0
  152. Cython/Includes/cpython/tuple.pxd +72 -0
  153. Cython/Includes/cpython/type.pxd +146 -0
  154. Cython/Includes/cpython/unicode.pxd +639 -0
  155. Cython/Includes/cpython/version.pxd +32 -0
  156. Cython/Includes/cpython/weakref.pxd +78 -0
  157. Cython/Includes/libc/__init__.pxd +1 -0
  158. Cython/Includes/libc/complex.pxd +35 -0
  159. Cython/Includes/libc/errno.pxd +127 -0
  160. Cython/Includes/libc/float.pxd +43 -0
  161. Cython/Includes/libc/limits.pxd +28 -0
  162. Cython/Includes/libc/locale.pxd +46 -0
  163. Cython/Includes/libc/math.pxd +209 -0
  164. Cython/Includes/libc/setjmp.pxd +10 -0
  165. Cython/Includes/libc/signal.pxd +64 -0
  166. Cython/Includes/libc/stdbool.pxd +5 -0
  167. Cython/Includes/libc/stddef.pxd +9 -0
  168. Cython/Includes/libc/stdint.pxd +105 -0
  169. Cython/Includes/libc/stdio.pxd +80 -0
  170. Cython/Includes/libc/stdlib.pxd +72 -0
  171. Cython/Includes/libc/string.pxd +50 -0
  172. Cython/Includes/libc/threads.pxd +234 -0
  173. Cython/Includes/libc/time.pxd +52 -0
  174. Cython/Includes/libcpp/__init__.pxd +4 -0
  175. Cython/Includes/libcpp/algorithm.pxd +320 -0
  176. Cython/Includes/libcpp/any.pxd +16 -0
  177. Cython/Includes/libcpp/atomic.pxd +59 -0
  178. Cython/Includes/libcpp/barrier.pxd +22 -0
  179. Cython/Includes/libcpp/bit.pxd +29 -0
  180. Cython/Includes/libcpp/cast.pxd +12 -0
  181. Cython/Includes/libcpp/cmath.pxd +518 -0
  182. Cython/Includes/libcpp/complex.pxd +106 -0
  183. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  184. Cython/Includes/libcpp/deque.pxd +165 -0
  185. Cython/Includes/libcpp/exception.pxd +216 -0
  186. Cython/Includes/libcpp/execution.pxd +15 -0
  187. Cython/Includes/libcpp/forward_list.pxd +63 -0
  188. Cython/Includes/libcpp/functional.pxd +26 -0
  189. Cython/Includes/libcpp/future.pxd +103 -0
  190. Cython/Includes/libcpp/iterator.pxd +34 -0
  191. Cython/Includes/libcpp/latch.pxd +17 -0
  192. Cython/Includes/libcpp/limits.pxd +61 -0
  193. Cython/Includes/libcpp/list.pxd +117 -0
  194. Cython/Includes/libcpp/map.pxd +252 -0
  195. Cython/Includes/libcpp/memory.pxd +115 -0
  196. Cython/Includes/libcpp/mutex.pxd +387 -0
  197. Cython/Includes/libcpp/numbers.pxd +15 -0
  198. Cython/Includes/libcpp/numeric.pxd +131 -0
  199. Cython/Includes/libcpp/optional.pxd +34 -0
  200. Cython/Includes/libcpp/pair.pxd +1 -0
  201. Cython/Includes/libcpp/queue.pxd +25 -0
  202. Cython/Includes/libcpp/random.pxd +166 -0
  203. Cython/Includes/libcpp/semaphore.pxd +43 -0
  204. Cython/Includes/libcpp/set.pxd +228 -0
  205. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  206. Cython/Includes/libcpp/span.pxd +87 -0
  207. Cython/Includes/libcpp/stack.pxd +11 -0
  208. Cython/Includes/libcpp/stop_token.pxd +117 -0
  209. Cython/Includes/libcpp/string.pxd +355 -0
  210. Cython/Includes/libcpp/string_view.pxd +183 -0
  211. Cython/Includes/libcpp/typeindex.pxd +15 -0
  212. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  213. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  214. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  215. Cython/Includes/libcpp/utility.pxd +30 -0
  216. Cython/Includes/libcpp/vector.pxd +186 -0
  217. Cython/Includes/numpy/math.pxd +150 -0
  218. Cython/Includes/openmp.pxd +50 -0
  219. Cython/Includes/posix/__init__.pxd +1 -0
  220. Cython/Includes/posix/dlfcn.pxd +14 -0
  221. Cython/Includes/posix/fcntl.pxd +86 -0
  222. Cython/Includes/posix/ioctl.pxd +4 -0
  223. Cython/Includes/posix/mman.pxd +101 -0
  224. Cython/Includes/posix/resource.pxd +57 -0
  225. Cython/Includes/posix/select.pxd +21 -0
  226. Cython/Includes/posix/signal.pxd +73 -0
  227. Cython/Includes/posix/stat.pxd +98 -0
  228. Cython/Includes/posix/stdio.pxd +37 -0
  229. Cython/Includes/posix/stdlib.pxd +29 -0
  230. Cython/Includes/posix/strings.pxd +9 -0
  231. Cython/Includes/posix/time.pxd +71 -0
  232. Cython/Includes/posix/types.pxd +30 -0
  233. Cython/Includes/posix/uio.pxd +26 -0
  234. Cython/Includes/posix/unistd.pxd +271 -0
  235. Cython/Includes/posix/wait.pxd +38 -0
  236. Cython/LZSS.py +184 -0
  237. Cython/Plex/Actions.pxd +24 -0
  238. Cython/Plex/Actions.py +119 -0
  239. Cython/Plex/DFA.pxd +14 -0
  240. Cython/Plex/DFA.py +164 -0
  241. Cython/Plex/Errors.py +48 -0
  242. Cython/Plex/Lexicons.py +178 -0
  243. Cython/Plex/Machines.pxd +36 -0
  244. Cython/Plex/Machines.py +238 -0
  245. Cython/Plex/Regexps.py +535 -0
  246. Cython/Plex/Scanners.pxd +45 -0
  247. Cython/Plex/Scanners.py +328 -0
  248. Cython/Plex/Transitions.pxd +14 -0
  249. Cython/Plex/Transitions.py +239 -0
  250. Cython/Plex/__init__.py +34 -0
  251. Cython/Runtime/__init__.py +1 -0
  252. Cython/Runtime/refnanny.pyx +237 -0
  253. Cython/Shadow.py +1172 -0
  254. Cython/StringIOTree.py +169 -0
  255. Cython/Tempita/__init__.py +4 -0
  256. Cython/Tempita/_looper.py +154 -0
  257. Cython/Tempita/_tempita.py +1087 -0
  258. Cython/TestUtils.py +472 -0
  259. Cython/Tests/TestCodeWriter.py +128 -0
  260. Cython/Tests/TestCythonUtils.py +237 -0
  261. Cython/Tests/TestJediTyper.py +223 -0
  262. Cython/Tests/TestShadow.py +125 -0
  263. Cython/Tests/TestStringIOTree.py +68 -0
  264. Cython/Tests/TestTestUtils.py +89 -0
  265. Cython/Tests/__init__.py +1 -0
  266. Cython/Tests/xmlrunner.py +390 -0
  267. Cython/Utility/AsyncGen.c +1152 -0
  268. Cython/Utility/Buffer.c +866 -0
  269. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  270. Cython/Utility/Builtins.c +1068 -0
  271. Cython/Utility/CConvert.pyx +153 -0
  272. Cython/Utility/CMath.c +104 -0
  273. Cython/Utility/CommonStructures.c +244 -0
  274. Cython/Utility/Complex.c +378 -0
  275. Cython/Utility/Coroutine.c +2344 -0
  276. Cython/Utility/CpdefEnums.pyx +119 -0
  277. Cython/Utility/CppConvert.pyx +284 -0
  278. Cython/Utility/CppSupport.cpp +151 -0
  279. Cython/Utility/CythonFunction.c +2143 -0
  280. Cython/Utility/Dataclasses.c +101 -0
  281. Cython/Utility/Embed.c +129 -0
  282. Cython/Utility/Exceptions.c +1331 -0
  283. Cython/Utility/Exceptions_Cy.pyx +109 -0
  284. Cython/Utility/ExtensionTypes.c +1199 -0
  285. Cython/Utility/FunctionArguments.c +1052 -0
  286. Cython/Utility/FusedFunction.pyx +44 -0
  287. Cython/Utility/ImportExport.c +972 -0
  288. Cython/Utility/MatchCase.c +985 -0
  289. Cython/Utility/MatchCase_Cy.pyx +12 -0
  290. Cython/Utility/MemoryView.pxd +108 -0
  291. Cython/Utility/MemoryView.pyx +1499 -0
  292. Cython/Utility/MemoryView_C.c +1056 -0
  293. Cython/Utility/ModuleSetupCode.c +3349 -0
  294. Cython/Utility/NumpyImportArray.c +46 -0
  295. Cython/Utility/ObjectHandling.c +3404 -0
  296. Cython/Utility/Optimize.c +2575 -0
  297. Cython/Utility/Overflow.c +378 -0
  298. Cython/Utility/Profile.c +736 -0
  299. Cython/Utility/StringTools.c +1534 -0
  300. Cython/Utility/Synchronization.c +438 -0
  301. Cython/Utility/TString.c +369 -0
  302. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  303. Cython/Utility/TestCythonScope.pyx +75 -0
  304. Cython/Utility/TestUtilityLoader.c +12 -0
  305. Cython/Utility/TypeConversion.c +1588 -0
  306. Cython/Utility/UFuncs.pyx +50 -0
  307. Cython/Utility/UFuncs_C.c +89 -0
  308. Cython/Utility/__init__.py +28 -0
  309. Cython/Utility/arrayarray.h +190 -0
  310. Cython/Utils.py +682 -0
  311. Cython/__init__.py +12 -0
  312. Cython/py.typed +0 -0
  313. cython.py +29 -0
  314. oxython-0.1.0.dist-info/METADATA +138 -0
  315. oxython-0.1.0.dist-info/RECORD +321 -0
  316. oxython-0.1.0.dist-info/WHEEL +5 -0
  317. oxython-0.1.0.dist-info/entry_points.txt +4 -0
  318. oxython-0.1.0.dist-info/top_level.txt +3 -0
  319. pyximport/__init__.py +4 -0
  320. pyximport/pyxbuild.py +160 -0
  321. pyximport/pyximport.py +482 -0
@@ -0,0 +1,1331 @@
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
+ #if __clang__ || __GNUC__
22
+ // "Assertions enabled" may be written multiple times when using subinterpreters.
23
+ // However, it should always be written to the same value to isn't a "real" race.
24
+ __attribute__((no_sanitize("thread")))
25
+ #endif
26
+ static int __Pyx_init_assertions_enabled(void) {
27
+ PyObject *builtins, *debug, *debug_str;
28
+ int flag;
29
+ builtins = PyEval_GetBuiltins();
30
+ if (!builtins) goto bad;
31
+ // Not using PYIDENT() here because we probably don't need the string more than this once.
32
+ debug_str = PyUnicode_FromStringAndSize("__debug__", 9);
33
+ if (!debug_str) goto bad;
34
+ debug = PyObject_GetItem(builtins, debug_str);
35
+ Py_DECREF(debug_str);
36
+ if (!debug) goto bad;
37
+ flag = PyObject_IsTrue(debug);
38
+ Py_DECREF(debug);
39
+ if (flag == -1) goto bad;
40
+ __pyx_assertions_enabled_flag = flag;
41
+ return 0;
42
+ bad:
43
+ __pyx_assertions_enabled_flag = 1;
44
+ // We (rarely) may not have an exception set, but the calling code will call PyErr_Occurred() either way.
45
+ return -1;
46
+ }
47
+ #else
48
+ #define __Pyx_init_assertions_enabled() (0)
49
+ #define __pyx_assertions_enabled() (!Py_OptimizeFlag)
50
+ #endif
51
+
52
+
53
+ /////////////// ErrOccurredWithGIL.proto ///////////////
54
+ static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */
55
+
56
+ /////////////// ErrOccurredWithGIL ///////////////
57
+ static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) {
58
+ int err;
59
+ PyGILState_STATE _save = PyGILState_Ensure();
60
+ err = !!PyErr_Occurred();
61
+ PyGILState_Release(_save);
62
+ return err;
63
+ }
64
+
65
+
66
+ /////////////// PyThreadStateGet.proto ///////////////
67
+ //@substitute: naming
68
+
69
+ #if CYTHON_FAST_THREAD_STATE
70
+ #define __Pyx_PyThreadState_declare PyThreadState *$local_tstate_cname;
71
+ #define __Pyx_PyThreadState_assign $local_tstate_cname = __Pyx_PyThreadState_Current;
72
+ #if PY_VERSION_HEX >= 0x030C00A6
73
+ #define __Pyx_PyErr_Occurred() ($local_tstate_cname->current_exception != NULL)
74
+ #define __Pyx_PyErr_CurrentExceptionType() ($local_tstate_cname->current_exception ? (PyObject*) Py_TYPE($local_tstate_cname->current_exception) : (PyObject*) NULL)
75
+ #else
76
+ #define __Pyx_PyErr_Occurred() ($local_tstate_cname->curexc_type != NULL)
77
+ #define __Pyx_PyErr_CurrentExceptionType() ($local_tstate_cname->curexc_type)
78
+ #endif
79
+ #else
80
+ // !CYTHON_FAST_THREAD_STATE
81
+ #define __Pyx_PyThreadState_declare
82
+ #define __Pyx_PyThreadState_assign
83
+ #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
84
+ #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
85
+ #endif
86
+
87
+
88
+ /////////////// GivenExceptionMatches.proto ///////////////
89
+ //@requires: PyThreadStateGet
90
+
91
+ #if CYTHON_COMPILING_IN_CPYTHON
92
+ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);/*proto*/
93
+ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);/*proto*/
94
+ #else
95
+ #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
96
+ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) {
97
+ return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2);
98
+ }
99
+ #endif
100
+ #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2)
101
+
102
+ /////////////// GivenExceptionMatches ///////////////
103
+ //@requires: ModuleSetupCode.c::FastTypeChecks
104
+ //@requires: PyErrFetchRestore
105
+
106
+ #if CYTHON_COMPILING_IN_CPYTHON
107
+
108
+ static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
109
+ if (exc_type1) {
110
+ return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2);
111
+ } else {
112
+ return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
113
+ }
114
+ }
115
+
116
+ // so far, we only call PyErr_GivenExceptionMatches() with an exception type (not instance) as first argument
117
+ // => optimise for that case
118
+
119
+ static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
120
+ Py_ssize_t i, n;
121
+ assert(PyExceptionClass_Check(exc_type));
122
+ n = PyTuple_GET_SIZE(tuple);
123
+ // the tight subtype checking in Py3 allows faster out-of-order comparison
124
+ for (i=0; i<n; i++) {
125
+ if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
126
+ }
127
+ for (i=0; i<n; i++) {
128
+ PyObject *t = PyTuple_GET_ITEM(tuple, i);
129
+ if (likely(PyExceptionClass_Check(t))) {
130
+ if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
131
+ } else {
132
+ // FIXME: Py3: PyErr_SetString(PyExc_TypeError, "catching classes that do not inherit from BaseException is not allowed");
133
+ }
134
+ }
135
+ return 0;
136
+ }
137
+
138
+ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
139
+ if (likely(err == exc_type)) return 1;
140
+ if (likely(PyExceptionClass_Check(err))) {
141
+ if (likely(PyExceptionClass_Check(exc_type))) {
142
+ return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
143
+ } else if (likely(PyTuple_Check(exc_type))) {
144
+ return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
145
+ } else {
146
+ // FIXME: Py3: PyErr_SetString(PyExc_TypeError, "catching classes that do not inherit from BaseException is not allowed");
147
+ }
148
+ }
149
+ return PyErr_GivenExceptionMatches(err, exc_type);
150
+ }
151
+
152
+ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
153
+ // Only used internally with known exception types => pure safety check assertions.
154
+ assert(PyExceptionClass_Check(exc_type1));
155
+ assert(PyExceptionClass_Check(exc_type2));
156
+ if (likely(err == exc_type1 || err == exc_type2)) return 1;
157
+ if (likely(PyExceptionClass_Check(err))) {
158
+ return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
159
+ }
160
+ return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
161
+ }
162
+
163
+ #endif
164
+
165
+
166
+ /////////////// PyErrExceptionMatches.proto ///////////////
167
+ //@substitute: naming
168
+
169
+ #if CYTHON_FAST_THREAD_STATE
170
+ #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState($local_tstate_cname, err)
171
+ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
172
+ #else
173
+ #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
174
+ #endif
175
+
176
+ /////////////// PyErrExceptionMatches ///////////////
177
+ //@requires: GivenExceptionMatches
178
+
179
+ #if CYTHON_FAST_THREAD_STATE
180
+ static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
181
+ Py_ssize_t i, n;
182
+ n = PyTuple_GET_SIZE(tuple);
183
+ // the tighter subtype checking in Py3 allows faster out-of-order comparison
184
+ for (i=0; i<n; i++) {
185
+ if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
186
+ }
187
+ for (i=0; i<n; i++) {
188
+ if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
189
+ }
190
+ return 0;
191
+ }
192
+
193
+ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
194
+ int result;
195
+ PyObject *exc_type;
196
+ #if PY_VERSION_HEX >= 0x030C00A6
197
+ PyObject *current_exception = tstate->current_exception;
198
+ if (unlikely(!current_exception)) return 0;
199
+ exc_type = (PyObject*) Py_TYPE(current_exception);
200
+ if (exc_type == err) return 1;
201
+ #else
202
+ exc_type = tstate->curexc_type;
203
+ if (exc_type == err) return 1;
204
+ if (unlikely(!exc_type)) return 0;
205
+ #endif
206
+ #if CYTHON_AVOID_BORROWED_REFS
207
+ Py_INCREF(exc_type);
208
+ #endif
209
+ if (unlikely(PyTuple_Check(err))) {
210
+ result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
211
+ } else {
212
+ result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
213
+ }
214
+ #if CYTHON_AVOID_BORROWED_REFS
215
+ Py_DECREF(exc_type);
216
+ #endif
217
+ return result;
218
+ }
219
+ #endif
220
+
221
+
222
+ /////////////// PyErrFetchRestore.proto ///////////////
223
+ //@substitute: naming
224
+ //@requires: PyThreadStateGet
225
+
226
+ #if CYTHON_FAST_THREAD_STATE
227
+ #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
228
+ #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
229
+ #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
230
+ #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState($local_tstate_cname, type, value, tb)
231
+ #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState($local_tstate_cname, type, value, tb)
232
+ static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/
233
+ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
234
+
235
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
236
+ #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
237
+ #else
238
+ #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
239
+ #endif
240
+
241
+ #else
242
+ #define __Pyx_PyErr_Clear() PyErr_Clear()
243
+ #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
244
+ #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
245
+ #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
246
+ #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
247
+ #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
248
+ #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
249
+ #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
250
+ #endif
251
+
252
+ /////////////// PyErrFetchRestore ///////////////
253
+
254
+ #if CYTHON_FAST_THREAD_STATE
255
+ static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
256
+ #if PY_VERSION_HEX >= 0x030C00A6
257
+ PyObject *tmp_value;
258
+ assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
259
+ if (value) {
260
+ #if CYTHON_COMPILING_IN_CPYTHON
261
+ if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
262
+ #endif
263
+ // If this fails, we may lose the traceback but still set the expected exception below.
264
+ PyException_SetTraceback(value, tb);
265
+ }
266
+ tmp_value = tstate->current_exception;
267
+ tstate->current_exception = value;
268
+ Py_XDECREF(tmp_value);
269
+ Py_XDECREF(type);
270
+ Py_XDECREF(tb);
271
+ #else
272
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
273
+ tmp_type = tstate->curexc_type;
274
+ tmp_value = tstate->curexc_value;
275
+ tmp_tb = tstate->curexc_traceback;
276
+ tstate->curexc_type = type;
277
+ tstate->curexc_value = value;
278
+ tstate->curexc_traceback = tb;
279
+ Py_XDECREF(tmp_type);
280
+ Py_XDECREF(tmp_value);
281
+ Py_XDECREF(tmp_tb);
282
+ #endif
283
+ }
284
+
285
+ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
286
+ #if PY_VERSION_HEX >= 0x030C00A6
287
+ PyObject* exc_value;
288
+ exc_value = tstate->current_exception;
289
+ tstate->current_exception = 0;
290
+ *value = exc_value;
291
+ *type = NULL;
292
+ *tb = NULL;
293
+ if (exc_value) {
294
+ *type = (PyObject*) Py_TYPE(exc_value);
295
+ Py_INCREF(*type);
296
+ #if CYTHON_COMPILING_IN_CPYTHON
297
+ *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
298
+ Py_XINCREF(*tb);
299
+ #else
300
+ *tb = PyException_GetTraceback(exc_value);
301
+ #endif
302
+ }
303
+ #else
304
+ *type = tstate->curexc_type;
305
+ *value = tstate->curexc_value;
306
+ *tb = tstate->curexc_traceback;
307
+ tstate->curexc_type = 0;
308
+ tstate->curexc_value = 0;
309
+ tstate->curexc_traceback = 0;
310
+ #endif
311
+ }
312
+ #endif
313
+
314
+ /////////////// RaiseException.export ///////////////
315
+
316
+ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
317
+
318
+ /////////////// RaiseException ///////////////
319
+ //@requires: PyErrFetchRestore
320
+ //@requires: PyThreadStateGet
321
+
322
+ // The following function is based on do_raise() from ceval.c.
323
+
324
+ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
325
+ PyObject* owned_instance = NULL;
326
+ if (tb == Py_None) {
327
+ tb = 0;
328
+ } else if (tb && !PyTraceBack_Check(tb)) {
329
+ PyErr_SetString(PyExc_TypeError,
330
+ "raise: arg 3 must be a traceback or None");
331
+ goto bad;
332
+ }
333
+ if (value == Py_None)
334
+ value = 0;
335
+
336
+ if (PyExceptionInstance_Check(type)) {
337
+ if (value) {
338
+ PyErr_SetString(PyExc_TypeError,
339
+ "instance exception may not have a separate value");
340
+ goto bad;
341
+ }
342
+ value = type;
343
+ type = (PyObject*) Py_TYPE(value);
344
+ } else if (PyExceptionClass_Check(type)) {
345
+ // make sure value is an exception instance of type
346
+ PyObject *instance_class = NULL;
347
+ if (value && PyExceptionInstance_Check(value)) {
348
+ instance_class = (PyObject*) Py_TYPE(value);
349
+ if (instance_class != type) {
350
+ int is_subclass = PyObject_IsSubclass(instance_class, type);
351
+ if (!is_subclass) {
352
+ instance_class = NULL;
353
+ } else if (unlikely(is_subclass == -1)) {
354
+ // error on subclass test
355
+ goto bad;
356
+ } else {
357
+ // believe the instance
358
+ type = instance_class;
359
+ }
360
+ }
361
+ }
362
+ if (!instance_class) {
363
+ // instantiate the type now (we don't know when and how it will be caught)
364
+ // assuming that 'value' is an argument to the type's constructor
365
+ // not using PyErr_NormalizeException() to avoid ref-counting problems
366
+ PyObject *args;
367
+ if (!value)
368
+ args = PyTuple_New(0);
369
+ else if (PyTuple_Check(value)) {
370
+ Py_INCREF(value);
371
+ args = value;
372
+ } else
373
+ args = PyTuple_Pack(1, value);
374
+ if (!args)
375
+ goto bad;
376
+ owned_instance = PyObject_Call(type, args, NULL);
377
+ Py_DECREF(args);
378
+ if (!owned_instance)
379
+ goto bad;
380
+ value = owned_instance;
381
+ if (!PyExceptionInstance_Check(value)) {
382
+ PyErr_Format(PyExc_TypeError,
383
+ "calling %R should have returned an instance of "
384
+ "BaseException, not %R",
385
+ type, Py_TYPE(value));
386
+ goto bad;
387
+ }
388
+ }
389
+ } else {
390
+ PyErr_SetString(PyExc_TypeError,
391
+ "raise: exception class must be a subclass of BaseException");
392
+ goto bad;
393
+ }
394
+
395
+ if (cause) {
396
+ PyObject *fixed_cause;
397
+ if (cause == Py_None) {
398
+ // raise ... from None
399
+ fixed_cause = NULL;
400
+ } else if (PyExceptionClass_Check(cause)) {
401
+ fixed_cause = PyObject_CallObject(cause, NULL);
402
+ if (fixed_cause == NULL)
403
+ goto bad;
404
+ } else if (PyExceptionInstance_Check(cause)) {
405
+ fixed_cause = cause;
406
+ Py_INCREF(fixed_cause);
407
+ } else {
408
+ PyErr_SetString(PyExc_TypeError,
409
+ "exception causes must derive from "
410
+ "BaseException");
411
+ goto bad;
412
+ }
413
+ PyException_SetCause(value, fixed_cause);
414
+ }
415
+
416
+ PyErr_SetObject(type, value);
417
+
418
+ if (tb) {
419
+ #if PY_VERSION_HEX >= 0x030C00A6
420
+ // If this fails, we just get a different exception, so ignore the return value.
421
+ PyException_SetTraceback(value, tb);
422
+ #elif CYTHON_FAST_THREAD_STATE
423
+ PyThreadState *tstate = __Pyx_PyThreadState_Current;
424
+ PyObject* tmp_tb = tstate->curexc_traceback;
425
+ if (tb != tmp_tb) {
426
+ Py_INCREF(tb);
427
+ tstate->curexc_traceback = tb;
428
+ Py_XDECREF(tmp_tb);
429
+ }
430
+ #else
431
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
432
+ PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
433
+ Py_INCREF(tb);
434
+ PyErr_Restore(tmp_type, tmp_value, tb);
435
+ Py_XDECREF(tmp_tb);
436
+ #endif
437
+ }
438
+
439
+ bad:
440
+ Py_XDECREF(owned_instance);
441
+ return;
442
+ }
443
+
444
+
445
+ /////////////// GetTopmostException.proto ///////////////
446
+
447
+ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
448
+ static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
449
+ #endif
450
+
451
+ /////////////// GetTopmostException ///////////////
452
+
453
+ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
454
+ // Copied from errors.c in CPython.
455
+ static _PyErr_StackItem *
456
+ __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
457
+ {
458
+ _PyErr_StackItem *exc_info = tstate->exc_info;
459
+ while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
460
+ exc_info->previous_item != NULL)
461
+ {
462
+ exc_info = exc_info->previous_item;
463
+ }
464
+ return exc_info;
465
+ }
466
+ #endif
467
+
468
+
469
+ /////////////// GetException.proto ///////////////
470
+ //@substitute: naming
471
+ //@requires: PyThreadStateGet
472
+
473
+ #if CYTHON_FAST_THREAD_STATE
474
+ #define __Pyx_GetException(type, value, tb) __Pyx__GetException($local_tstate_cname, type, value, tb)
475
+ static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
476
+ #else
477
+ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
478
+ #endif
479
+
480
+ /////////////// GetException ///////////////
481
+
482
+ #if CYTHON_FAST_THREAD_STATE
483
+ static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
484
+ #else
485
+ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
486
+ #endif
487
+ {
488
+ PyObject *local_type = NULL, *local_value, *local_tb = NULL;
489
+ #if CYTHON_FAST_THREAD_STATE
490
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
491
+ #if PY_VERSION_HEX >= 0x030C0000
492
+ local_value = tstate->current_exception;
493
+ tstate->current_exception = 0;
494
+ #else
495
+ local_type = tstate->curexc_type;
496
+ local_value = tstate->curexc_value;
497
+ local_tb = tstate->curexc_traceback;
498
+ tstate->curexc_type = 0;
499
+ tstate->curexc_value = 0;
500
+ tstate->curexc_traceback = 0;
501
+ #endif
502
+ #elif __PYX_LIMITED_VERSION_HEX >= 0x030C0000
503
+ local_value = PyErr_GetRaisedException();
504
+ #else
505
+ PyErr_Fetch(&local_type, &local_value, &local_tb);
506
+ #endif
507
+
508
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
509
+ if (likely(local_value)) {
510
+ local_type = (PyObject*) Py_TYPE(local_value);
511
+ Py_INCREF(local_type);
512
+ local_tb = PyException_GetTraceback(local_value);
513
+ }
514
+ #else
515
+ // Note that In Python 3.12+ exceptions are already normalized
516
+ PyErr_NormalizeException(&local_type, &local_value, &local_tb);
517
+ #if CYTHON_FAST_THREAD_STATE
518
+ if (unlikely(tstate->curexc_type))
519
+ #else
520
+ if (unlikely(PyErr_Occurred()))
521
+ #endif
522
+ goto bad;
523
+
524
+ // Note that in Python 3.12 the traceback came directly from local_value anyway.
525
+ if (local_tb) {
526
+ if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
527
+ goto bad;
528
+ }
529
+ #endif // __PYX_LIMITED_VERSION_HEX >= 0x030C0000
530
+
531
+ // traceback may be NULL for freshly raised exceptions
532
+ Py_XINCREF(local_tb);
533
+ // exception state may be empty in parallel loops (code-gen error where we don't generate a
534
+ // top-level PyGILState_Ensure surrounding the whole loop, and so releasing the GIL temporarily
535
+ // wipes the whole thread state).
536
+ Py_XINCREF(local_type);
537
+ Py_XINCREF(local_value);
538
+ *type = local_type;
539
+ *value = local_value;
540
+ *tb = local_tb;
541
+
542
+ #if CYTHON_FAST_THREAD_STATE
543
+ #if CYTHON_USE_EXC_INFO_STACK
544
+ {
545
+ _PyErr_StackItem *exc_info = tstate->exc_info;
546
+ #if PY_VERSION_HEX >= 0x030B00a4
547
+ tmp_value = exc_info->exc_value;
548
+ exc_info->exc_value = local_value;
549
+ tmp_type = NULL;
550
+ tmp_tb = NULL;
551
+ Py_XDECREF(local_type);
552
+ Py_XDECREF(local_tb);
553
+ #else
554
+ tmp_type = exc_info->exc_type;
555
+ tmp_value = exc_info->exc_value;
556
+ tmp_tb = exc_info->exc_traceback;
557
+ exc_info->exc_type = local_type;
558
+ exc_info->exc_value = local_value;
559
+ exc_info->exc_traceback = local_tb;
560
+ #endif
561
+ }
562
+ #else
563
+ tmp_type = tstate->exc_type;
564
+ tmp_value = tstate->exc_value;
565
+ tmp_tb = tstate->exc_traceback;
566
+ tstate->exc_type = local_type;
567
+ tstate->exc_value = local_value;
568
+ tstate->exc_traceback = local_tb;
569
+ #endif
570
+ // Make sure tstate is in a consistent state when we XDECREF
571
+ // these objects (DECREF may run arbitrary code).
572
+ Py_XDECREF(tmp_type);
573
+ Py_XDECREF(tmp_value);
574
+ Py_XDECREF(tmp_tb);
575
+ #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
576
+ PyErr_SetHandledException(local_value);
577
+ Py_XDECREF(local_value);
578
+ Py_XDECREF(local_type);
579
+ Py_XDECREF(local_tb);
580
+ #else
581
+ PyErr_SetExcInfo(local_type, local_value, local_tb);
582
+ #endif
583
+
584
+ return 0;
585
+
586
+ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
587
+ bad:
588
+ *type = 0;
589
+ *value = 0;
590
+ *tb = 0;
591
+ Py_XDECREF(local_type);
592
+ Py_XDECREF(local_value);
593
+ Py_XDECREF(local_tb);
594
+ return -1;
595
+ #endif
596
+ }
597
+
598
+ /////////////// ReRaiseException.proto ///////////////
599
+
600
+ static CYTHON_INLINE void __Pyx_ReraiseException(void); /*proto*/
601
+
602
+ /////////////// ReRaiseException ///////////////
603
+ //@requires: GetTopmostException
604
+
605
+ static CYTHON_INLINE void __Pyx_ReraiseException(void) {
606
+ PyObject *type = NULL, *value = NULL, *tb = NULL;
607
+ #if CYTHON_FAST_THREAD_STATE
608
+ PyThreadState *tstate = PyThreadState_GET();
609
+ #if CYTHON_USE_EXC_INFO_STACK
610
+ _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
611
+ value = exc_info->exc_value;
612
+ #if PY_VERSION_HEX >= 0x030B00a4
613
+ if (unlikely(value == Py_None)) {
614
+ value = NULL;
615
+ } else if (value) {
616
+ Py_INCREF(value);
617
+ type = (PyObject*) Py_TYPE(value);
618
+ Py_INCREF(type);
619
+ tb = PyException_GetTraceback(value);
620
+ }
621
+ #else
622
+ type = exc_info->exc_type;
623
+ tb = exc_info->exc_traceback;
624
+ Py_XINCREF(type);
625
+ Py_XINCREF(value);
626
+ Py_XINCREF(tb);
627
+ #endif
628
+ #else
629
+ type = tstate->exc_type;
630
+ value = tstate->exc_value;
631
+ tb = tstate->exc_traceback;
632
+ Py_XINCREF(type);
633
+ Py_XINCREF(value);
634
+ Py_XINCREF(tb);
635
+ #endif
636
+ #else
637
+ PyErr_GetExcInfo(&type, &value, &tb);
638
+ #endif
639
+ if (unlikely(!type || type == Py_None)) {
640
+ Py_XDECREF(type);
641
+ Py_XDECREF(value);
642
+ Py_XDECREF(tb);
643
+ // message copied from Py3
644
+ PyErr_SetString(PyExc_RuntimeError,
645
+ "No active exception to reraise");
646
+ } else {
647
+ PyErr_Restore(type, value, tb);
648
+ }
649
+ }
650
+
651
+ /////////////// SaveResetException.proto ///////////////
652
+ //@substitute: naming
653
+ //@requires: PyThreadStateGet
654
+
655
+ #if CYTHON_FAST_THREAD_STATE
656
+ #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave($local_tstate_cname, type, value, tb)
657
+ static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
658
+ #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset($local_tstate_cname, type, value, tb)
659
+ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/
660
+
661
+ #else
662
+
663
+ #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
664
+ #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
665
+ #endif
666
+
667
+ /////////////// SaveResetException ///////////////
668
+ //@requires: GetTopmostException
669
+
670
+ #if CYTHON_FAST_THREAD_STATE
671
+ static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
672
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
673
+ _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
674
+ PyObject *exc_value = exc_info->exc_value;
675
+ if (exc_value == NULL || exc_value == Py_None) {
676
+ *value = NULL;
677
+ *type = NULL;
678
+ *tb = NULL;
679
+ } else {
680
+ *value = exc_value;
681
+ Py_INCREF(*value);
682
+ *type = (PyObject*) Py_TYPE(exc_value);
683
+ Py_INCREF(*type);
684
+ *tb = PyException_GetTraceback(exc_value);
685
+ }
686
+ #elif CYTHON_USE_EXC_INFO_STACK
687
+ _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
688
+ *type = exc_info->exc_type;
689
+ *value = exc_info->exc_value;
690
+ *tb = exc_info->exc_traceback;
691
+ Py_XINCREF(*type);
692
+ Py_XINCREF(*value);
693
+ Py_XINCREF(*tb);
694
+ #else
695
+ *type = tstate->exc_type;
696
+ *value = tstate->exc_value;
697
+ *tb = tstate->exc_traceback;
698
+ Py_XINCREF(*type);
699
+ Py_XINCREF(*value);
700
+ Py_XINCREF(*tb);
701
+ #endif
702
+ }
703
+
704
+ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
705
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
706
+ _PyErr_StackItem *exc_info = tstate->exc_info;
707
+ PyObject *tmp_value = exc_info->exc_value;
708
+ exc_info->exc_value = value;
709
+ Py_XDECREF(tmp_value);
710
+ // TODO: avoid passing these at all
711
+ Py_XDECREF(type);
712
+ Py_XDECREF(tb);
713
+ #else
714
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
715
+ #if CYTHON_USE_EXC_INFO_STACK
716
+ _PyErr_StackItem *exc_info = tstate->exc_info;
717
+ tmp_type = exc_info->exc_type;
718
+ tmp_value = exc_info->exc_value;
719
+ tmp_tb = exc_info->exc_traceback;
720
+ exc_info->exc_type = type;
721
+ exc_info->exc_value = value;
722
+ exc_info->exc_traceback = tb;
723
+ #else
724
+ tmp_type = tstate->exc_type;
725
+ tmp_value = tstate->exc_value;
726
+ tmp_tb = tstate->exc_traceback;
727
+ tstate->exc_type = type;
728
+ tstate->exc_value = value;
729
+ tstate->exc_traceback = tb;
730
+ #endif
731
+ Py_XDECREF(tmp_type);
732
+ Py_XDECREF(tmp_value);
733
+ Py_XDECREF(tmp_tb);
734
+ #endif
735
+ }
736
+ #endif
737
+
738
+ /////////////// SwapException.proto ///////////////
739
+ //@substitute: naming
740
+ //@requires: PyThreadStateGet
741
+
742
+ #if CYTHON_FAST_THREAD_STATE
743
+ #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap($local_tstate_cname, type, value, tb)
744
+ static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
745
+ #else
746
+ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
747
+ #endif
748
+
749
+ /////////////// SwapException ///////////////
750
+
751
+ #if CYTHON_FAST_THREAD_STATE
752
+ static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
753
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
754
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
755
+ _PyErr_StackItem *exc_info = tstate->exc_info;
756
+ tmp_value = exc_info->exc_value;
757
+ exc_info->exc_value = *value;
758
+ if (tmp_value == NULL || tmp_value == Py_None) {
759
+ Py_XDECREF(tmp_value);
760
+ tmp_value = NULL;
761
+ tmp_type = NULL;
762
+ tmp_tb = NULL;
763
+ } else {
764
+ // TODO: avoid swapping these at all
765
+ tmp_type = (PyObject*) Py_TYPE(tmp_value);
766
+ Py_INCREF(tmp_type);
767
+ #if CYTHON_COMPILING_IN_CPYTHON
768
+ tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
769
+ Py_XINCREF(tmp_tb);
770
+ #else
771
+ tmp_tb = PyException_GetTraceback(tmp_value);
772
+ #endif
773
+ }
774
+ #elif CYTHON_USE_EXC_INFO_STACK
775
+ _PyErr_StackItem *exc_info = tstate->exc_info;
776
+ tmp_type = exc_info->exc_type;
777
+ tmp_value = exc_info->exc_value;
778
+ tmp_tb = exc_info->exc_traceback;
779
+
780
+ exc_info->exc_type = *type;
781
+ exc_info->exc_value = *value;
782
+ exc_info->exc_traceback = *tb;
783
+ #else
784
+ tmp_type = tstate->exc_type;
785
+ tmp_value = tstate->exc_value;
786
+ tmp_tb = tstate->exc_traceback;
787
+
788
+ tstate->exc_type = *type;
789
+ tstate->exc_value = *value;
790
+ tstate->exc_traceback = *tb;
791
+ #endif
792
+
793
+ *type = tmp_type;
794
+ *value = tmp_value;
795
+ *tb = tmp_tb;
796
+ }
797
+
798
+ #else
799
+
800
+ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
801
+ PyObject *tmp_type, *tmp_value, *tmp_tb;
802
+ PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
803
+ PyErr_SetExcInfo(*type, *value, *tb);
804
+ *type = tmp_type;
805
+ *value = tmp_value;
806
+ *tb = tmp_tb;
807
+ }
808
+ #endif
809
+
810
+ /////////////// WriteUnraisableException.proto ///////////////
811
+
812
+ static void __Pyx_WriteUnraisable(const char *name, int clineno,
813
+ int lineno, const char *filename,
814
+ int full_traceback, int nogil); /*proto*/
815
+
816
+ /////////////// WriteUnraisableException ///////////////
817
+ //@requires: PyErrFetchRestore
818
+ //@requires: PyThreadStateGet
819
+
820
+ static void __Pyx_WriteUnraisable(const char *name, int clineno,
821
+ int lineno, const char *filename,
822
+ int full_traceback, int nogil) {
823
+ PyObject *old_exc, *old_val, *old_tb;
824
+ PyObject *ctx;
825
+ __Pyx_PyThreadState_declare
826
+ PyGILState_STATE state;
827
+ if (nogil)
828
+ state = PyGILState_Ensure();
829
+ /* arbitrary, to suppress warning */
830
+ else state = (PyGILState_STATE)0;
831
+ CYTHON_UNUSED_VAR(clineno);
832
+ CYTHON_UNUSED_VAR(lineno);
833
+ CYTHON_UNUSED_VAR(filename);
834
+ CYTHON_MAYBE_UNUSED_VAR(nogil);
835
+
836
+ __Pyx_PyThreadState_assign
837
+ __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
838
+ if (full_traceback) {
839
+ Py_XINCREF(old_exc);
840
+ Py_XINCREF(old_val);
841
+ Py_XINCREF(old_tb);
842
+ __Pyx_ErrRestore(old_exc, old_val, old_tb);
843
+ PyErr_PrintEx(0);
844
+ }
845
+ ctx = PyUnicode_FromString(name);
846
+ __Pyx_ErrRestore(old_exc, old_val, old_tb);
847
+ if (!ctx) {
848
+ PyErr_WriteUnraisable(Py_None);
849
+ } else {
850
+ PyErr_WriteUnraisable(ctx);
851
+ Py_DECREF(ctx);
852
+ }
853
+ if (nogil)
854
+ PyGILState_Release(state);
855
+ }
856
+
857
+ /////////////// CLineInTraceback.proto ///////////////
858
+
859
+ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
860
+ static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);/*proto*/
861
+ #else
862
+ #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
863
+ #endif
864
+
865
+ /////////////// CLineInTraceback ///////////////
866
+ //@requires: ObjectHandling.c::PyObjectGetAttrStrNoError
867
+ //@requires: ObjectHandling.c::PyDictVersioning
868
+ //@requires: PyErrFetchRestore
869
+ //@requires: Builtins.c::dict_setdefault
870
+
871
+ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
872
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
873
+ // On earlier version of the Limited API we're less flexible and assume it's
874
+ // definitely a module. Which will break some odd user monkey-patching...
875
+ #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
876
+ #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
877
+ // On freethreading, use PyObject_GenericGetDict to avoid having to think too hard
878
+ // about atomics and _PyObject_GetDictPtr.
879
+ #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
880
+ #else
881
+ PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
882
+ PyObject **dict_ptr = _PyObject_GetDictPtr(o);
883
+ return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
884
+ }
885
+ #endif
886
+
887
+
888
+ static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
889
+ PyObject *use_cline = NULL;
890
+ PyObject *ptype, *pvalue, *ptraceback;
891
+ PyObject *cython_runtime_dict;
892
+
893
+ CYTHON_MAYBE_UNUSED_VAR(tstate);
894
+
895
+ if (unlikely(!NAMED_CGLOBAL(cython_runtime_cname))) {
896
+ // Very early error where the runtime module is not set up yet.
897
+ return c_line;
898
+ }
899
+
900
+ __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
901
+
902
+ cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(NAMED_CGLOBAL(cython_runtime_cname));
903
+ if (likely(cython_runtime_dict)) {
904
+ __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
905
+ use_cline, cython_runtime_dict,
906
+ __Pyx_PyDict_SetDefault(cython_runtime_dict, PYIDENT("cline_in_traceback"), Py_False))
907
+ }
908
+ if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
909
+ c_line = 0;
910
+ }
911
+ Py_XDECREF(use_cline);
912
+ Py_XDECREF(cython_runtime_dict);
913
+ __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
914
+ return c_line;
915
+ }
916
+ #endif
917
+
918
+ /////////////// AddTraceback.proto ///////////////
919
+
920
+ static void __Pyx_AddTraceback(const char *funcname, int c_line,
921
+ int py_line, const char *filename); /*proto*/
922
+
923
+ /////////////// AddTraceback ///////////////
924
+ //@requires: ModuleSetupCode.c::CodeObjectCache
925
+ //@requires: CLineInTraceback
926
+ //@substitute: naming
927
+
928
+ #include "compile.h"
929
+ #include "frameobject.h"
930
+ #include "traceback.h"
931
+ #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
932
+ #ifndef Py_BUILD_CORE
933
+ #define Py_BUILD_CORE 1
934
+ #endif
935
+ #include "internal/pycore_frame.h"
936
+ #endif
937
+
938
+ #if CYTHON_COMPILING_IN_LIMITED_API
939
+ static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
940
+ PyObject *firstlineno, PyObject *name) {
941
+ PyObject *replace = NULL;
942
+ if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
943
+ if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
944
+
945
+ replace = PyObject_GetAttrString(code, "replace");
946
+ if (likely(replace)) {
947
+ PyObject *result = PyObject_Call(replace, EMPTY(tuple), scratch_dict);
948
+ Py_DECREF(replace);
949
+ return result;
950
+ }
951
+
952
+ return NULL;
953
+ }
954
+
955
+ static void __Pyx_AddTraceback(const char *funcname, int c_line,
956
+ int py_line, const char *filename) {
957
+ PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
958
+ PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
959
+ PyObject *exc_type, *exc_value, *exc_traceback;
960
+ int success = 0;
961
+ if (c_line) {
962
+ c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
963
+ }
964
+
965
+ // DW - this is a horrendous hack, but I'm quite proud of it. Essentially
966
+ // we need to generate a frame with the right line number/filename/funcname.
967
+ // We do this by compiling a small bit of code that uses sys._getframe to get a
968
+ // frame, and then customizing the details of the code to match.
969
+ // We then run the code object and use the generated frame to set the traceback.
970
+
971
+ __Pyx_PyErr_FetchException(&exc_type, &exc_value, &exc_traceback);
972
+
973
+ code_object = $global_code_object_cache_find(c_line ? -c_line : py_line);
974
+ if (!code_object) {
975
+ code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
976
+ if (unlikely(!code_object)) goto bad;
977
+ py_py_line = PyLong_FromLong(py_line);
978
+ if (unlikely(!py_py_line)) goto bad;
979
+ if (c_line) {
980
+ py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line);
981
+ } else {
982
+ py_funcname = PyUnicode_FromString(funcname);
983
+ }
984
+ if (unlikely(!py_funcname)) goto bad;
985
+ dict = PyDict_New();
986
+ if (unlikely(!dict)) goto bad;
987
+ {
988
+ PyObject *old_code_object = code_object;
989
+ code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
990
+ Py_DECREF(old_code_object);
991
+ }
992
+ if (unlikely(!code_object)) goto bad;
993
+
994
+ $global_code_object_cache_insert(c_line ? -c_line : py_line, code_object);
995
+ } else {
996
+ // The frame part still expects a dict
997
+ dict = PyDict_New();
998
+ }
999
+
1000
+ // Note that getframe is borrowed
1001
+ getframe = PySys_GetObject("_getframe");
1002
+ if (unlikely(!getframe)) goto bad;
1003
+ // reuse dict as globals (nothing conflicts, and it saves an allocation)
1004
+ if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
1005
+
1006
+ frame = PyEval_EvalCode(code_object, dict, dict);
1007
+ if (unlikely(!frame) || frame == Py_None) goto bad;
1008
+ success = 1;
1009
+
1010
+ bad:
1011
+ __Pyx_PyErr_RestoreException(exc_type, exc_value, exc_traceback);
1012
+ Py_XDECREF(code_object);
1013
+ Py_XDECREF(py_py_line);
1014
+ Py_XDECREF(py_funcname);
1015
+ Py_XDECREF(dict);
1016
+ Py_XDECREF(replace);
1017
+
1018
+ if (success) {
1019
+ // Unfortunately an easy way to check the type of frame isn't in the
1020
+ // limited API. The check against None should cover the most
1021
+ // likely wrong answer though.
1022
+ PyTraceBack_Here(
1023
+ // Python < 0x03090000 didn't expose PyFrameObject
1024
+ // but they all expose struct _frame as an opaque type
1025
+ (struct _frame*)frame);
1026
+ }
1027
+
1028
+ Py_XDECREF(frame);
1029
+ }
1030
+ #else
1031
+ static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
1032
+ const char *funcname, int c_line,
1033
+ int py_line, const char *filename) {
1034
+ PyCodeObject *py_code = NULL;
1035
+ PyObject *py_funcname = NULL;
1036
+
1037
+ if (c_line) {
1038
+ py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line);
1039
+ if (!py_funcname) goto bad;
1040
+ funcname = PyUnicode_AsUTF8(py_funcname);
1041
+ if (!funcname) goto bad;
1042
+ }
1043
+ py_code = PyCode_NewEmpty(filename, funcname, py_line);
1044
+ Py_XDECREF(py_funcname); /* XDECREF since it's only set on Py3 if cline */
1045
+ return py_code;
1046
+ bad:
1047
+ Py_XDECREF(py_funcname);
1048
+ return NULL;
1049
+ }
1050
+
1051
+ static void __Pyx_AddTraceback(const char *funcname, int c_line,
1052
+ int py_line, const char *filename) {
1053
+ PyCodeObject *py_code = 0;
1054
+ PyFrameObject *py_frame = 0;
1055
+ PyThreadState *tstate = __Pyx_PyThreadState_Current;
1056
+ PyObject *ptype, *pvalue, *ptraceback;
1057
+
1058
+ if (c_line) {
1059
+ c_line = __Pyx_CLineForTraceback(tstate, c_line);
1060
+ }
1061
+
1062
+ // Negate to avoid collisions between py and c lines.
1063
+ py_code = $global_code_object_cache_find(c_line ? -c_line : py_line);
1064
+ if (!py_code) {
1065
+ __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
1066
+ py_code = __Pyx_CreateCodeObjectForTraceback(
1067
+ funcname, c_line, py_line, filename);
1068
+ if (!py_code) {
1069
+ /* If the code object creation fails, then we should clear the
1070
+ fetched exception references and propagate the new exception */
1071
+ Py_XDECREF(ptype);
1072
+ Py_XDECREF(pvalue);
1073
+ Py_XDECREF(ptraceback);
1074
+ goto bad;
1075
+ }
1076
+ __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
1077
+ $global_code_object_cache_insert(c_line ? -c_line : py_line, py_code);
1078
+ }
1079
+ py_frame = PyFrame_New(
1080
+ tstate, /*PyThreadState *tstate,*/
1081
+ py_code, /*PyCodeObject *code,*/
1082
+ NAMED_CGLOBAL(moddict_cname), /*PyObject *globals,*/
1083
+ 0 /*PyObject *locals*/
1084
+ );
1085
+ if (!py_frame) goto bad;
1086
+ __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
1087
+ PyTraceBack_Here(py_frame);
1088
+ bad:
1089
+ Py_XDECREF(py_code);
1090
+ Py_XDECREF(py_frame);
1091
+ }
1092
+ #endif
1093
+
1094
+
1095
+ ///////////////////////////// FloatExceptionCheck.proto ///////////////////////////
1096
+
1097
+ // Detect if error_value is NaN, and use a different check in that case
1098
+ #define __PYX_CHECK_FLOAT_EXCEPTION(value, error_value) \
1099
+ ((error_value) == (error_value) ? \
1100
+ (value) == (error_value) : \
1101
+ (value) != (value))
1102
+
1103
+
1104
+ /////////////////// ExceptStar.proto /////////////////////////
1105
+
1106
+ static int __Pyx_ValidateStarCatchPattern(PyObject *pattern); /* proto */
1107
+ static int __Pyx_ExceptionGroupMatch(PyObject *, PyObject **, PyObject **); /* proto */
1108
+ static void __Pyx_RaisePreppedException(PyObject *exc); /* proto */
1109
+
1110
+ #if CYTHON_USE_OWN_PREP_RERAISE_STAR
1111
+ // Our implementation, in Cython utility code
1112
+ #define __Pyx_PyExc_PrepReraiseStar __Pyx__PyExc_PrepReraiseStar
1113
+ #else
1114
+ #define __Pyx_PyExc_PrepReraiseStar PyUnstable_Exc_PrepReraiseStar
1115
+ #endif
1116
+
1117
+ /////////////////// ExceptStar ///////////////////////////////
1118
+ //@requires: ObjectHandling.c::PyObjectCallMethod1
1119
+ //@requires: ObjectHandling.c::RaiseErrorWithObjectTypes
1120
+ //@requires: ObjectHandling.c::RaiseErrorWithTypeAndVarargs
1121
+
1122
+ static int __Pyx_ValidateStarCatchPatternElement(PyObject *pattern) {
1123
+ int is_subclass;
1124
+ if (!unlikely(PyExceptionClass_Check(pattern))) {
1125
+ // Note that Cython only asserts and doesn't validate this for regular except clauses
1126
+ PyErr_SetString(PyExc_TypeError, "catching classes that do not inherit from BaseException is not allowed");
1127
+ return -1;
1128
+ }
1129
+ is_subclass = PyObject_IsSubclass(pattern, PyExc_BaseExceptionGroup);
1130
+ if (unlikely(is_subclass)) {
1131
+ if (is_subclass > 0) {
1132
+ PyErr_SetString(PyExc_TypeError, "catching ExceptionGroup with except* is not allowed. Use except instead.");
1133
+ }
1134
+ return -1;
1135
+ }
1136
+ return 0;
1137
+ }
1138
+
1139
+ static int __Pyx_ValidateStarCatchPattern(PyObject *pattern) {
1140
+ if (PyTuple_Check(pattern)) {
1141
+ Py_ssize_t size, i;
1142
+ #if CYTHON_ASSUME_SAFE_MACROS
1143
+ size = PyTuple_GET_SIZE(pattern);
1144
+ #else
1145
+ size = PyTuple_Size(pattern);
1146
+ if (size < 0) return -1;
1147
+ #endif
1148
+ for (i=0; i<size; ++i) {
1149
+ int result;
1150
+ PyObject* item;
1151
+ #if !CYTHON_ASSUME_SAFE_MACROS || CYTHON_AVOID_BORROWED_REFS
1152
+ item = PySequence_GetItem(pattern, i);
1153
+ if (!item) return -1;
1154
+ #else
1155
+ item = PyTuple_GET_ITEM(pattern, i);
1156
+ #endif
1157
+ result = __Pyx_ValidateStarCatchPatternElement(item);
1158
+ #if !CYTHON_ASSUME_SAFE_MACROS || CYTHON_AVOID_BORROWED_REFS
1159
+ Py_DECREF(item);
1160
+ #endif
1161
+ if (result) {
1162
+ return result;
1163
+ }
1164
+ }
1165
+ return 0;
1166
+ } else {
1167
+ return __Pyx_ValidateStarCatchPatternElement(pattern);
1168
+ }
1169
+ }
1170
+
1171
+ // Copied with slight modifications from exception_group_match in ceval.c in CPython
1172
+ // The main difference is that I combine the exc_value input argument and rest output argument into one
1173
+ static int __Pyx_ExceptionGroupMatch(PyObject *match_type, PyObject **current_exception, PyObject **match) {
1174
+ int is_instance;
1175
+
1176
+ Py_DECREF(*match); // whatever happens, we'll re-assign it
1177
+ *match = Py_NewRef(Py_None);
1178
+
1179
+ if (PyErr_GivenExceptionMatches(*current_exception, match_type)) {
1180
+ int is_eg = PyObject_IsInstance(*current_exception, PyExc_BaseExceptionGroup);
1181
+ if (is_eg) {
1182
+ if (unlikely(is_eg<0)) return -1;
1183
+ *match = Py_NewRef(*current_exception);
1184
+ } else {
1185
+ PyObject *wrapped;
1186
+ PyObject *call_args[2];
1187
+
1188
+ /* naked exception - wrap it */
1189
+ call_args[0] = EMPTY(unicode);
1190
+ call_args[1] = PyTuple_Pack(1, *current_exception);
1191
+ if (call_args[1] == NULL) {
1192
+ return -1;
1193
+ }
1194
+ #if CYTHON_VECTORCALL
1195
+ // We know we have Python 3.11 to be using except* so VectorCall is definitely available
1196
+ wrapped = PyObject_Vectorcall(PyExc_BaseExceptionGroup, call_args, 2, NULL);
1197
+ #else
1198
+ wrapped = PyObject_CallFunctionObjArgs(PyExc_BaseExceptionGroup, call_args[0], call_args[1], NULL);
1199
+ #endif
1200
+ Py_DECREF(call_args[1]);
1201
+
1202
+ if (wrapped == NULL) {
1203
+ return -1;
1204
+ }
1205
+ Py_DECREF(*match);
1206
+ *match = wrapped;
1207
+ }
1208
+
1209
+ Py_DECREF(*current_exception);
1210
+ *current_exception = Py_NewRef(Py_None);
1211
+ return 0;
1212
+ }
1213
+
1214
+ /* current_exception does not match match_type.
1215
+ * Check for partial match if it's an exception group.
1216
+ */
1217
+ is_instance = PyObject_IsInstance(*current_exception, PyExc_BaseExceptionGroup);
1218
+ if (unlikely(is_instance < 0)) return -1;
1219
+ if (is_instance) {
1220
+ PyObject *pair = __Pyx_PyObject_CallMethod1(
1221
+ *current_exception, PYIDENT("split"), match_type);
1222
+
1223
+ if (pair == NULL) return -1;
1224
+
1225
+ if (unlikely(!PyTuple_CheckExact(pair))) {
1226
+ __Pyx_RaiseTypeErrorWithObjectTypes(
1227
+ __Pyx_FMT_TYPENAME ".split must return a tuple, not " __Pyx_FMT_TYPENAME,
1228
+ *current_exception, pair);
1229
+ Py_DECREF(pair);
1230
+ return -1;
1231
+ }
1232
+ Py_ssize_t pair_size = __Pyx_PyTuple_GET_SIZE(pair);
1233
+ if (unlikely(pair_size != 2)) {
1234
+ #if !CYTHON_ASSUME_SAFE_SIZE
1235
+ if (pair_size >= 0)
1236
+ #endif
1237
+ {
1238
+ __Pyx_RaiseErrorWithTypeAndVarargs(PyExc_TypeError,
1239
+ __Pyx_FMT_TYPENAME ".split must return a 2-tuple, "
1240
+ "got tuple of size %zd",
1241
+ Py_TYPE(*current_exception), pair_size);
1242
+ }
1243
+ Py_DECREF(pair);
1244
+ return -1;
1245
+ }
1246
+
1247
+ #if !CYTHON_ASSUME_SAFE_MACROS || CYTHON_AVOID_BORROWED_REFS
1248
+ __Pyx_Py_XDECREF_SET(*match, PySequence_GetItem(pair, 0));
1249
+ if (!*match) {
1250
+ goto limited_api_bad;
1251
+ }
1252
+ __Pyx_Py_XDECREF_SET(*current_exception, PySequence_GetItem(pair, 1));
1253
+ if (!*current_exception) {
1254
+ limited_api_bad:
1255
+ Py_DECREF(pair);
1256
+ return -1;
1257
+ }
1258
+ #else
1259
+ __Pyx_Py_XDECREF_SET(*match, Py_NewRef(PyTuple_GET_ITEM(pair, 0)));
1260
+ __Pyx_Py_XDECREF_SET(*current_exception, Py_NewRef(PyTuple_GET_ITEM(pair, 1)));
1261
+ #endif
1262
+
1263
+ Py_DECREF(pair);
1264
+ return 0;
1265
+ }
1266
+
1267
+ // No match
1268
+ // match is None and
1269
+ // current_exception remains the same
1270
+ return 0;
1271
+ }
1272
+
1273
+ static void __Pyx_RaisePreppedException(PyObject *exc) {
1274
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
1275
+ Py_INCREF(exc);
1276
+ PyErr_SetRaisedException(exc);
1277
+ #else
1278
+ // Raise the exception but preserve all original traceback,
1279
+ // avoid setting cause and context, etc.
1280
+
1281
+ PyObject *traceback, *type;
1282
+
1283
+ traceback = PyException_GetTraceback(exc);
1284
+ if (!traceback && unlikely(PyErr_Occurred())) return;
1285
+
1286
+ type = (PyObject*)Py_TYPE(exc);
1287
+ Py_INCREF(type);
1288
+ Py_INCREF(exc);
1289
+ PyErr_Restore((PyObject*)Py_TYPE(exc), exc, traceback);
1290
+ #endif
1291
+ }
1292
+
1293
+ #if !CYTHON_USE_OWN_PREP_RERAISE_STAR
1294
+ // Unfortunately c_compile_guard in Cython utility code still causes the proto to be created
1295
+ // leading to a "declared static but never defined" warning. This looks hard to avoid so
1296
+ // create trivial definitions instead.
1297
+ CYTHON_UNUSED static PyObject *__Pyx_exception_get_notes(CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *b) {
1298
+ return NULL;
1299
+ }
1300
+ CYTHON_UNUSED static PyObject *__Pyx_split_into_same_metadata(CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *b) {
1301
+ return NULL;
1302
+ }
1303
+ CYTHON_UNUSED static PyObject *__Pyx_except_star_leafs(CYTHON_UNUSED PyObject *a) {
1304
+ return NULL;
1305
+ }
1306
+ CYTHON_UNUSED static PyObject *__Pyx_exception_group_projection(CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *b) {
1307
+ return NULL;
1308
+ }
1309
+ CYTHON_UNUSED static PyObject *__Pyx__PyExc_PrepReraiseStar(CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *b) {
1310
+ return NULL;
1311
+ }
1312
+ #endif
1313
+
1314
+
1315
+ //////////////////// IgnoreException.proto /////////////////////////////////
1316
+
1317
+ // Returns 1 if the exception was ignored, 0, otherwise.
1318
+ // given_exception may be NULL, in which case PyErr_Occurred() is used.
1319
+ static CYTHON_INLINE int __Pyx_IgnoreGivenException(PyObject *given_exception, PyObject *ignorable_exception); /* proto */
1320
+
1321
+ #define __Pyx_IgnoreException(ignorable_exception) __Pyx_IgnoreGivenException(NULL, ignorable_exception)
1322
+
1323
+ //////////////////// IgnoreException /////////////////////////////////
1324
+
1325
+ static CYTHON_INLINE int __Pyx_IgnoreGivenException(PyObject *given_exception, PyObject *ignorable_exception) {
1326
+ if (PyErr_GivenExceptionMatches(given_exception ? given_exception : PyErr_Occurred(), ignorable_exception)) {
1327
+ PyErr_Clear();
1328
+ return 1;
1329
+ }
1330
+ return 0;
1331
+ }