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,972 @@
1
+ /////////////// Import.proto ///////////////////
2
+
3
+ static CYTHON_INLINE PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level); /*proto*/
4
+
5
+ /////////////// Import /////////////////////////
6
+ //@requires: ImportImpl
7
+
8
+ static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) {
9
+ // Forward to the shared utility code with an extra moddict argument (because that's not possible to look up in shared utility code)
10
+ return __Pyx__Import(name, imported_names, len_imported_names, qualname, NAMED_CGLOBAL(moddict_cname), level);
11
+ }
12
+
13
+ /////////////// ImportImpl.export ///////////////
14
+
15
+ static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level); /*proto*/
16
+
17
+ /////////////// ImportImpl ///////////////
18
+ //@requires: StringTools.c::IncludeStringH
19
+ //@requires: Builtins.c::HasAttr
20
+ //@requires: ObjectHandling.c::ListFromArray
21
+ //@requires: ObjectHandling.c::PyObjectCallOneArg
22
+
23
+ static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) {
24
+ PyObject *imported_module = PyImport_GetModule(qualname);
25
+ if (unlikely(!imported_module)) {
26
+ *module = NULL;
27
+ if (PyErr_Occurred()) {
28
+ return -1;
29
+ }
30
+ return 0;
31
+ }
32
+ *module = imported_module;
33
+ return 1;
34
+ }
35
+
36
+ static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) {
37
+ PyObject *imported_module;
38
+ PyObject *top_level_package_name;
39
+ Py_ssize_t i;
40
+ int status, module_found;
41
+ Py_ssize_t dot_index;
42
+
43
+ module_found = __Pyx__Import_GetModule(qualname, &imported_module);
44
+ if (unlikely(!module_found || module_found == -1)) {
45
+ *module = NULL;
46
+ return module_found;
47
+ }
48
+
49
+ if (imported_names) {
50
+ for (i = 0; i < len_imported_names; i++) {
51
+ PyObject *imported_name = imported_names[i];
52
+ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
53
+ int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name);
54
+ #else
55
+ int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name);
56
+ if (unlikely(has_imported_attribute == -1)) goto error;
57
+ #endif
58
+ if (!has_imported_attribute) {
59
+ goto not_found;
60
+ }
61
+ }
62
+ *module = imported_module;
63
+ return 1;
64
+ }
65
+
66
+ // Get top-level module
67
+ dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1);
68
+ if (dot_index == -1) {
69
+ // No dot, so we already have the top-level module
70
+ *module = imported_module;
71
+ return 1;
72
+ }
73
+ if (unlikely(dot_index == -2)) goto error;
74
+ top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index);
75
+ if (unlikely(!top_level_package_name)) goto error;
76
+
77
+ Py_DECREF(imported_module);
78
+
79
+ status = __Pyx__Import_GetModule(top_level_package_name, module);
80
+ Py_DECREF(top_level_package_name);
81
+ return status;
82
+
83
+ error:
84
+ Py_DECREF(imported_module);
85
+ *module = NULL;
86
+ return -1;
87
+
88
+ not_found:
89
+ Py_DECREF(imported_module);
90
+ *module = NULL;
91
+ return 0;
92
+ }
93
+
94
+ static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level) {
95
+ PyObject *module = 0;
96
+ PyObject *empty_dict = 0;
97
+ PyObject *from_list = 0;
98
+ int module_found;
99
+
100
+ if (!qualname) {
101
+ qualname = name;
102
+ }
103
+ module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module);
104
+ if (likely(module_found == 1)) {
105
+ return module;
106
+ } else if (unlikely(module_found == -1)) {
107
+ return NULL;
108
+ }
109
+ #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030f00a6
110
+ // Prefer the empty frozendict singleton when we know it's faster to get than creating a new dict.
111
+ empty_dict = PyFrozenDict_New(NULL);
112
+ #else
113
+ empty_dict = PyDict_New();
114
+ #endif
115
+ if (unlikely(!empty_dict))
116
+ goto bad;
117
+ if (imported_names) {
118
+ from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names);
119
+ if (unlikely(!from_list))
120
+ goto bad;
121
+ }
122
+ if (level == -1) {
123
+ const char* package_sep = strchr(__Pyx_MODULE_NAME, '.');
124
+ if (package_sep != (0)) {
125
+ /* try package relative import first */
126
+ module = PyImport_ImportModuleLevelObject(
127
+ name, moddict, empty_dict, from_list, 1);
128
+ if (unlikely(!module)) {
129
+ if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
130
+ goto bad;
131
+ PyErr_Clear();
132
+ }
133
+ }
134
+ level = 0; /* try absolute import on failure */
135
+ }
136
+ if (!module) {
137
+ module = PyImport_ImportModuleLevelObject(
138
+ name, moddict, empty_dict, from_list, level);
139
+ }
140
+ bad:
141
+ Py_XDECREF(from_list);
142
+ Py_XDECREF(empty_dict);
143
+ return module;
144
+ }
145
+
146
+
147
+ /////////////// ImportFrom.export ///////////////
148
+
149
+ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/
150
+
151
+ /////////////// ImportFrom ///////////////
152
+ //@requires: ObjectHandling.c::PyObjectGetAttrStr
153
+
154
+ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
155
+ PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
156
+ if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
157
+ // 'name' may refer to a (sub-)module which has not finished initialization
158
+ // yet, and may not be assigned as an attribute to its parent, so try
159
+ // finding it by full name.
160
+ const char* module_name_str = 0;
161
+ PyObject* module_name = 0;
162
+ PyObject* module_dot = 0;
163
+ PyObject* full_name = 0;
164
+ PyErr_Clear();
165
+ module_name_str = PyModule_GetName(module);
166
+ if (unlikely(!module_name_str)) { goto modbad; }
167
+ module_name = PyUnicode_FromString(module_name_str);
168
+ if (unlikely(!module_name)) { goto modbad; }
169
+ module_dot = PyUnicode_Concat(module_name, PYUNICODE("."));
170
+ if (unlikely(!module_dot)) { goto modbad; }
171
+ full_name = PyUnicode_Concat(module_dot, name);
172
+ if (unlikely(!full_name)) { goto modbad; }
173
+ #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) || \
174
+ CYTHON_COMPILING_IN_GRAAL
175
+ {
176
+ PyObject *modules = PyImport_GetModuleDict();
177
+ if (unlikely(!modules))
178
+ goto modbad;
179
+ value = PyObject_GetItem(modules, full_name);
180
+ }
181
+ #else
182
+ value = PyImport_GetModule(full_name);
183
+ #endif
184
+
185
+ modbad:
186
+ Py_XDECREF(full_name);
187
+ Py_XDECREF(module_dot);
188
+ Py_XDECREF(module_name);
189
+ }
190
+ if (unlikely(!value)) {
191
+ PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
192
+ }
193
+ return value;
194
+ }
195
+
196
+
197
+ /////////////// ImportStar ///////////////
198
+ //@substitute: naming
199
+
200
+ /* import_all_from is an unexposed function from ceval.c */
201
+
202
+ static int
203
+ __Pyx_import_all_from(PyObject *locals, PyObject *v)
204
+ {
205
+ PyObject *all = PyObject_GetAttrString(v, "__all__");
206
+ PyObject *dict, *name, *value;
207
+ int skip_leading_underscores = 0;
208
+ int pos, err;
209
+
210
+ if (all == NULL) {
211
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError))
212
+ return -1; /* Unexpected error */
213
+ PyErr_Clear();
214
+ dict = PyObject_GetAttrString(v, "__dict__");
215
+ if (dict == NULL) {
216
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError))
217
+ return -1;
218
+ PyErr_SetString(PyExc_ImportError,
219
+ "from-import-* object has no __dict__ and no __all__");
220
+ return -1;
221
+ }
222
+ all = PyMapping_Keys(dict);
223
+ Py_DECREF(dict);
224
+ if (all == NULL)
225
+ return -1;
226
+ skip_leading_underscores = 1;
227
+ }
228
+
229
+ for (pos = 0, err = 0; ; pos++) {
230
+ name = PySequence_GetItem(all, pos);
231
+ if (name == NULL) {
232
+ if (!PyErr_ExceptionMatches(PyExc_IndexError))
233
+ err = -1;
234
+ else
235
+ PyErr_Clear();
236
+ break;
237
+ }
238
+ if (skip_leading_underscores && likely(PyUnicode_Check(name))) {
239
+ Py_ssize_t length = __Pyx_PyUnicode_GET_LENGTH(name);
240
+ #if !CYTHON_ASSUME_SAFE_SIZE
241
+ if (unlikely(length < 0)) {
242
+ Py_DECREF(name);
243
+ return -1;
244
+ }
245
+ #endif
246
+ if (likely(length) && __Pyx_PyUnicode_READ_CHAR(name, 0) == '_') {
247
+ Py_DECREF(name);
248
+ continue;
249
+ }
250
+ }
251
+ value = PyObject_GetAttr(v, name);
252
+ if (value == NULL)
253
+ err = -1;
254
+ else if (PyDict_CheckExact(locals))
255
+ err = PyDict_SetItem(locals, name, value);
256
+ else
257
+ err = PyObject_SetItem(locals, name, value);
258
+ Py_DECREF(name);
259
+ Py_XDECREF(value);
260
+ if (err != 0)
261
+ break;
262
+ }
263
+ Py_DECREF(all);
264
+ return err;
265
+ }
266
+
267
+
268
+ static int ${import_star}(PyObject* m) {
269
+ int ret = -1;
270
+ Py_ssize_t size;
271
+ PyObject *locals = 0;
272
+ PyObject *list = 0;
273
+ ${modulestatetype_cname} *mstate = __Pyx_PyModule_GetState(m);
274
+
275
+ locals = PyDict_New(); if (!locals) goto bad;
276
+ if (__Pyx_import_all_from(locals, m) < 0) goto bad;
277
+ list = PyDict_Items(locals); if (!list) goto bad;
278
+
279
+ size = __Pyx_PyList_GET_SIZE(list);
280
+ #if !CYTHON_ASSUME_SAFE_SIZE
281
+ if (size < 0) goto bad;
282
+ #endif
283
+ for (Py_ssize_t i=0; i<size; i++) {
284
+ PyObject *import_obj, *name, *item;
285
+ import_obj = __Pyx_PyList_GET_ITEM(list, i); if (!import_obj) goto bad;
286
+ name = __Pyx_PyTuple_GET_ITEM(import_obj, 0); if (!name) goto bad;
287
+ item = __Pyx_PyTuple_GET_ITEM(import_obj, 1); if (!item) goto bad;
288
+
289
+ if (${import_star_set}(mstate, item, name) < 0) goto bad;
290
+ }
291
+ ret = 0;
292
+
293
+ bad:
294
+ Py_XDECREF(locals);
295
+ Py_XDECREF(list);
296
+ return ret;
297
+ }
298
+
299
+
300
+ /////////////// SetPackagePathFromImportLib.proto ///////////////
301
+
302
+ #if !CYTHON_PEP489_MULTI_PHASE_INIT
303
+ static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name);
304
+ #else
305
+ #define __Pyx_SetPackagePathFromImportLib(a) 0
306
+ #endif
307
+
308
+ /////////////// SetPackagePathFromImportLib ///////////////
309
+ //@substitute: naming
310
+
311
+ #if !CYTHON_PEP489_MULTI_PHASE_INIT
312
+ static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name) {
313
+ PyObject *importlib, *osmod, *ossep, *parts, *package_path;
314
+ PyObject *file_path = NULL;
315
+ PyObject *item;
316
+ int result;
317
+ PyObject *spec;
318
+ // package_path = [importlib.util.find_spec(module_name).origin.rsplit(os.sep, 1)[0]]
319
+ importlib = PyImport_ImportModule("importlib.util");
320
+ if (unlikely(!importlib))
321
+ goto bad;
322
+ spec = PyObject_CallMethod(importlib, "find_spec", "(O)", module_name);
323
+ Py_DECREF(importlib);
324
+ if (unlikely(!spec))
325
+ goto bad;
326
+ file_path = PyObject_GetAttrString(spec, "origin");
327
+ Py_DECREF(spec);
328
+ if (unlikely(!file_path))
329
+ goto bad;
330
+
331
+ if (unlikely(PyObject_SetAttrString($module_cname, "__file__", file_path) < 0))
332
+ goto bad;
333
+
334
+ osmod = PyImport_ImportModule("os");
335
+ if (unlikely(!osmod))
336
+ goto bad;
337
+ ossep = PyObject_GetAttrString(osmod, "sep");
338
+ Py_DECREF(osmod);
339
+ if (unlikely(!ossep))
340
+ goto bad;
341
+ parts = PyObject_CallMethod(file_path, "rsplit", "(Oi)", ossep, 1);
342
+ Py_DECREF(file_path); file_path = NULL;
343
+ Py_DECREF(ossep);
344
+ if (unlikely(!parts))
345
+ goto bad;
346
+ #if CYTHON_ASSUME_SAFE_MACROS
347
+ package_path = Py_BuildValue("[O]", PyList_GET_ITEM(parts, 0));
348
+ #else
349
+ item = PyList_GetItem(parts, 0);
350
+ if (unlikely(!item))
351
+ goto bad;
352
+ package_path = Py_BuildValue("[O]", item);
353
+ #endif
354
+ Py_DECREF(parts);
355
+ if (unlikely(!package_path))
356
+ goto bad;
357
+ goto set_path;
358
+
359
+ bad:
360
+ PyErr_WriteUnraisable(module_name);
361
+ Py_XDECREF(file_path);
362
+
363
+ // set an empty path list on failure
364
+ PyErr_Clear();
365
+ package_path = PyList_New(0);
366
+ if (unlikely(!package_path))
367
+ return -1;
368
+
369
+ set_path:
370
+ result = PyObject_SetAttrString($module_cname, "__path__", package_path);
371
+ Py_DECREF(package_path);
372
+ return result;
373
+ }
374
+ #endif
375
+
376
+
377
+ /////////////// TypeImport.proto ///////////////
378
+ //@substitute: naming
379
+
380
+ #ifndef __PYX_HAVE_RT_ImportType_proto_$cyversion
381
+ #define __PYX_HAVE_RT_ImportType_proto_$cyversion
382
+
383
+ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
384
+ #include <stdalign.h>
385
+ #endif
386
+
387
+ #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L
388
+ #define __PYX_GET_STRUCT_ALIGNMENT_$cyversion(s) alignof(s)
389
+ #else
390
+ // best guess at what the alignment could be since we can't measure it
391
+ #define __PYX_GET_STRUCT_ALIGNMENT_$cyversion(s) sizeof(void*)
392
+ #endif
393
+
394
+ enum __Pyx_ImportType_CheckSize_$cyversion {
395
+ __Pyx_ImportType_CheckSize_Error_$cyversion = 0,
396
+ __Pyx_ImportType_CheckSize_Warn_$cyversion = 1,
397
+ __Pyx_ImportType_CheckSize_Ignore_$cyversion = 2
398
+ };
399
+
400
+ static PyTypeObject *__Pyx_ImportType_$cyversion(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_$cyversion check_size); /*proto*/
401
+
402
+ #endif
403
+
404
+ /////////////// TypeImport ///////////////
405
+ //@substitute: naming
406
+
407
+ // Note that this goes into headers so CYTHON_COMPILING_IN_LIMITED_API may not be available.
408
+
409
+ #ifndef __PYX_HAVE_RT_ImportType_$cyversion
410
+ #define __PYX_HAVE_RT_ImportType_$cyversion
411
+ static PyTypeObject *__Pyx_ImportType_$cyversion(PyObject *module, const char *module_name, const char *class_name,
412
+ size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_$cyversion check_size)
413
+ {
414
+ PyObject *result = 0;
415
+ Py_ssize_t basicsize;
416
+ Py_ssize_t itemsize;
417
+ #if defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API)
418
+ PyObject *py_basicsize;
419
+ PyObject *py_itemsize;
420
+ #endif
421
+
422
+ result = PyObject_GetAttrString(module, class_name);
423
+ if (!result)
424
+ goto bad;
425
+ if (!PyType_Check(result)) {
426
+ PyErr_Format(PyExc_TypeError,
427
+ "%.200s.%.200s is not a type object",
428
+ module_name, class_name);
429
+ goto bad;
430
+ }
431
+ #if !( defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) )
432
+ basicsize = ((PyTypeObject *)result)->tp_basicsize;
433
+ itemsize = ((PyTypeObject *)result)->tp_itemsize;
434
+ #else
435
+ if (size == 0) {
436
+ return (PyTypeObject *)result;
437
+ }
438
+ py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
439
+ if (!py_basicsize)
440
+ goto bad;
441
+ basicsize = PyLong_AsSsize_t(py_basicsize);
442
+ Py_DECREF(py_basicsize);
443
+ py_basicsize = 0;
444
+ if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
445
+ goto bad;
446
+ py_itemsize = PyObject_GetAttrString(result, "__itemsize__");
447
+ if (!py_itemsize)
448
+ goto bad;
449
+ itemsize = PyLong_AsSsize_t(py_itemsize);
450
+ Py_DECREF(py_itemsize);
451
+ py_itemsize = 0;
452
+ if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred())
453
+ goto bad;
454
+ #endif
455
+ if (itemsize) {
456
+ // If itemsize is smaller than the alignment the struct can end up with some extra
457
+ // padding at the end. In this case we need to work out the maximum size that
458
+ // the padding could be when calculating the range of valid struct sizes.
459
+ if (size % alignment) {
460
+ // if this is true we've probably calculated the alignment wrongly
461
+ // (most likely because alignof isn't available)
462
+ alignment = size % alignment;
463
+ }
464
+ if (itemsize < (Py_ssize_t)alignment)
465
+ itemsize = (Py_ssize_t)alignment;
466
+ }
467
+ if ((size_t)(basicsize + itemsize) < size) {
468
+ PyErr_Format(PyExc_ValueError,
469
+ "%.200s.%.200s size changed, may indicate binary incompatibility. "
470
+ "Expected %zd from C header, got %zd from PyObject",
471
+ module_name, class_name, size, basicsize+itemsize);
472
+ goto bad;
473
+ }
474
+ // varobjects almost have structs between basicsize and basicsize + itemsize
475
+ // but the struct isn't always one of the two limiting values
476
+ if (check_size == __Pyx_ImportType_CheckSize_Error_$cyversion &&
477
+ ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) {
478
+ PyErr_Format(PyExc_ValueError,
479
+ "%.200s.%.200s size changed, may indicate binary incompatibility. "
480
+ "Expected %zd from C header, got %zd-%zd from PyObject",
481
+ module_name, class_name, size, basicsize, basicsize+itemsize);
482
+ goto bad;
483
+ }
484
+ else if (check_size == __Pyx_ImportType_CheckSize_Warn_$cyversion && (size_t)basicsize > size) {
485
+ if (PyErr_WarnFormat(NULL, 0,
486
+ "%.200s.%.200s size changed, may indicate binary incompatibility. "
487
+ "Expected %zd from C header, got %zd from PyObject",
488
+ module_name, class_name, size, basicsize) < 0) {
489
+ goto bad;
490
+ }
491
+ }
492
+ /* check_size == __Pyx_ImportType_CheckSize_Ignore does not warn nor error */
493
+ return (PyTypeObject *)result;
494
+ bad:
495
+ Py_XDECREF(result);
496
+ return NULL;
497
+ }
498
+ #endif
499
+
500
+ /////////////// FunctionImport.proto ///////////////
501
+ //@substitute: naming
502
+
503
+ static int __Pyx_ImportFunction_$cyversion(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
504
+
505
+ /////////////// FunctionImport ///////////////
506
+ //@substitute: naming
507
+ //@requires: PxdImportShared
508
+
509
+ #ifndef __PYX_HAVE_RT_ImportFunction_$cyversion
510
+ #define __PYX_HAVE_RT_ImportFunction_$cyversion
511
+ static int __Pyx_ImportFunction_$cyversion(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
512
+ if (*f) {
513
+ return 0; // already imported under a different name
514
+ }
515
+ union {
516
+ void (*fp)(void);
517
+ void *p;
518
+ } tmp;
519
+ int result = __Pyx_ImportFromPxd_$cyversion(module, funcname, &tmp.p, sig, "function", 0);
520
+ if (result == 0) {
521
+ *f = tmp.fp;
522
+ }
523
+ return result;
524
+ }
525
+ #endif
526
+
527
+ /////////////// FunctionImportFused.proto ///////////////
528
+ //@substitute: naming
529
+
530
+ static int __Pyx_ImportFusedFunction_$cyversion(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
531
+
532
+ /////////////// FunctionImportFused ///////////////
533
+ //@substitute: naming
534
+ //@requires: PxdImportShared
535
+
536
+ // Account for updated naming of fused functions in the API dictionary.
537
+ // This looks them up under the new name, but if they aren't found isn't considered a failure.
538
+ // For now they are still looked up under the old name afterwards and it becomes an error if that fails.
539
+ // Eventually this can go away when enough time has passed that both importers and exporters will be
540
+ // using the new scheme.
541
+ #ifndef __PYX_HAVE_RT_ImportFusedFunction_$cyversion
542
+ #define __PYX_HAVE_RT_ImportFusedFunction_$cyversion
543
+ static int __Pyx_ImportFusedFunction_$cyversion(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
544
+ union {
545
+ void (*fp)(void);
546
+ void *p;
547
+ } tmp;
548
+ int result = __Pyx_ImportFromPxd_$cyversion(module, funcname, &tmp.p, sig, "function", 1);
549
+ if (result == 0) {
550
+ *f = tmp.fp;
551
+ }
552
+ return result;
553
+ }
554
+ #endif
555
+
556
+ /////////////// GetApiDict.proto ///////////////
557
+
558
+ static PyObject *__Pyx_ApiExport_GetApiDict(void); /*proto*/
559
+
560
+ /////////////// GetApiDict ///////////////
561
+ //@substitute: naming
562
+
563
+ static PyObject *__Pyx_ApiExport_GetApiDict(void) {
564
+ PyObject *d;
565
+ if (__Pyx_PyDict_GetItemRef(NAMED_CGLOBAL(moddict_cname), PYIDENT("$api_name"), &d) == -1)
566
+ return NULL;
567
+ if (!d) {
568
+ d = PyDict_New();
569
+ if (!d)
570
+ goto bad;
571
+ if (PyObject_SetAttr($module_cname, PYIDENT("$api_name"), d) < 0)
572
+ goto bad;
573
+ }
574
+ return d;
575
+
576
+ bad:
577
+ Py_XDECREF(d);
578
+ return NULL;
579
+ }
580
+
581
+
582
+ /////////////// FunctionExport.proto ///////////////
583
+
584
+ static int __Pyx_ExportFunction(PyObject *api_dict, const char *name, void (*f)(void), const char *sig); /*proto*/
585
+
586
+ /////////////// FunctionExport ///////////////
587
+
588
+ static int __Pyx_ExportFunction(PyObject *api_dict, const char *name, void (*f)(void), const char *sig) {
589
+ PyObject *cobj;
590
+ union {
591
+ void (*fp)(void);
592
+ void *p;
593
+ } tmp;
594
+
595
+ tmp.fp = f;
596
+ cobj = PyCapsule_New(tmp.p, sig, 0);
597
+ if (!cobj)
598
+ goto bad;
599
+ if (PyDict_SetItemString(api_dict, name, cobj) < 0)
600
+ goto bad;
601
+ Py_DECREF(cobj);
602
+ return 0;
603
+ bad:
604
+ Py_XDECREF(cobj);
605
+ return -1;
606
+ }
607
+
608
+ /////////////// PxdImportShared ///////////////
609
+ //@substitute: naming
610
+
611
+ #ifndef __PYX_HAVE_RT_ImportFromPxd_$cyversion
612
+ #define __PYX_HAVE_RT_ImportFromPxd_$cyversion
613
+ static int __Pyx_ImportFromPxd_$cyversion(PyObject *module, const char *name, void **p, const char *sig, const char *what, int optional) {
614
+ PyObject *d = 0;
615
+ PyObject *cobj = 0;
616
+
617
+ d = PyObject_GetAttrString(module, "$api_name");
618
+ if (!d)
619
+ goto bad;
620
+ // potentially defined in headers so we can't rely on __PYX_LIMITED_VERSION_HEX
621
+ #if (defined(Py_LIMITED_API) && Py_LIMITED_API >= 0x030d0000) || (!defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030d0000)
622
+ PyDict_GetItemStringRef(d, name, &cobj);
623
+ #else
624
+ cobj = PyDict_GetItemString(d, name);
625
+ Py_XINCREF(cobj);
626
+ #endif
627
+ if (!cobj) {
628
+ if (optional && !PyErr_Occurred()) {
629
+ PyErr_Clear();
630
+ *p = NULL;
631
+ goto allowed_failure;
632
+ } else {
633
+ PyErr_Format(PyExc_ImportError,
634
+ "%.200s does not export expected C %.8s %.200s",
635
+ PyModule_GetName(module), what, name);
636
+ goto bad;
637
+ }
638
+ }
639
+ if (!PyCapsule_IsValid(cobj, sig)) {
640
+ PyErr_Format(PyExc_TypeError,
641
+ "C %.8s %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
642
+ what, PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
643
+ goto bad;
644
+ }
645
+ *p = PyCapsule_GetPointer(cobj, sig);
646
+ if (!(*p))
647
+ goto bad;
648
+ Py_DECREF(cobj);
649
+ allowed_failure:
650
+ Py_DECREF(d);
651
+ return 0;
652
+ bad:
653
+ Py_XDECREF(d);
654
+ Py_XDECREF(cobj);
655
+ return -1;
656
+ }
657
+ #endif
658
+
659
+ /////////////// VoidPtrImport.proto ///////////////
660
+ //@substitute: naming
661
+
662
+ static int __Pyx_ImportVoidPtr_$cyversion(PyObject *module, const char *name, void **p, const char *sig); /*proto*/
663
+
664
+ /////////////// VoidPtrImport ///////////////
665
+ //@substitute: naming
666
+ //@requires: PxdImportShared
667
+
668
+ #ifndef __PYX_HAVE_RT_ImportVoidPtr_$cyversion
669
+ #define __PYX_HAVE_RT_ImportVoidPtr_$cyversion
670
+ static int __Pyx_ImportVoidPtr_$cyversion(PyObject *module, const char *name, void **p, const char *sig) {
671
+ return __Pyx_ImportFromPxd_$cyversion(module, name, p, sig, "variable", 0);
672
+ }
673
+ #endif
674
+
675
+
676
+ /////////////// VoidPtrExport.proto ///////////////
677
+
678
+ static int __Pyx_ExportVoidPtr(PyObject *api_dict, const char *name, void *p, const char *sig); /*proto*/
679
+
680
+ /////////////// VoidPtrExport ///////////////
681
+
682
+ static int __Pyx_ExportVoidPtr(PyObject *api_dict, const char *name, void *p, const char *sig) {
683
+ PyObject *cobj;
684
+
685
+ cobj = PyCapsule_New(p, sig, 0);
686
+ if (!cobj)
687
+ goto bad;
688
+ if (PyDict_SetItemString(api_dict, name, cobj) < 0)
689
+ goto bad;
690
+ Py_DECREF(cobj);
691
+ return 0;
692
+ bad:
693
+ Py_XDECREF(cobj);
694
+ return -1;
695
+ }
696
+
697
+
698
+ /////////////// SetVTable.export ///////////////
699
+ //@feature: ExtensionTypes
700
+ //@requires: MergeVTables
701
+
702
+ static int __Pyx_SetVtable(PyTypeObject* typeptr , void* vtable); /*proto*/
703
+
704
+ /////////////// SetVTable ///////////////
705
+
706
+ static int __Pyx_SetVtable(PyTypeObject *type, void *vtable) {
707
+ PyObject *ob = PyCapsule_New(vtable, 0, 0);
708
+ if (unlikely(!ob))
709
+ goto bad;
710
+ #if CYTHON_COMPILING_IN_LIMITED_API
711
+ if (unlikely(PyObject_SetAttr((PyObject *) type, PYIDENT("__pyx_vtable__"), ob) < 0))
712
+ #else
713
+ if (unlikely(PyDict_SetItem(type->tp_dict, PYIDENT("__pyx_vtable__"), ob) < 0))
714
+ #endif
715
+ goto bad;
716
+ Py_DECREF(ob);
717
+
718
+ return __Pyx_MergeVtables(type);
719
+
720
+ bad:
721
+ Py_XDECREF(ob);
722
+ return -1;
723
+ }
724
+
725
+
726
+ /////////////// GetVTable.proto ///////////////
727
+
728
+ // Returns
729
+ // 0 (with an exception set) for "not found".
730
+ // 1 for "found".
731
+ // -1 (with an exception set) for another error.
732
+ static int __Pyx_GetVtable(PyTypeObject *type, void** table); /*proto*/
733
+
734
+ /////////////// GetVTable ///////////////
735
+
736
+ static int __Pyx_GetVtable(PyTypeObject *type, void** table) {
737
+ void* ptr;
738
+ *table = NULL;
739
+ #if CYTHON_COMPILING_IN_LIMITED_API
740
+ PyObject *ob = PyObject_GetAttr((PyObject *)type, PYIDENT("__pyx_vtable__"));
741
+ #else
742
+ PyObject *ob = PyObject_GetItem(type->tp_dict, PYIDENT("__pyx_vtable__"));
743
+ #endif
744
+ if (!ob)
745
+ goto no_attr;
746
+ ptr = PyCapsule_GetPointer(ob, 0);
747
+ if (!ptr && !PyErr_Occurred())
748
+ PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
749
+ Py_DECREF(ob);
750
+ *table = ptr;
751
+ return 1;
752
+ no_attr:
753
+ if (PyErr_ExceptionMatches(CYTHON_COMPILING_IN_LIMITED_API ? PyExc_AttributeError : PyExc_KeyError)) {
754
+ return 0;
755
+ }
756
+ Py_XDECREF(ob);
757
+ return -1;
758
+ }
759
+
760
+
761
+ /////////////// MergeVTables.proto ///////////////
762
+
763
+ static int __Pyx_MergeVtables(PyTypeObject *type); /*proto*/
764
+
765
+ /////////////// MergeVTables ///////////////
766
+ //@requires: ObjectHandling.c::RaiseErrorWithObjectTypes
767
+ //@requires: GetVTable
768
+
769
+ static int __Pyx_MergeVtables(PyTypeObject *type) {
770
+ int i=0;
771
+ Py_ssize_t size;
772
+ void** base_vtables;
773
+ void* unknown = (void*)-1;
774
+ PyObject* bases = __Pyx_PyType_GetSlot(type, tp_bases, PyObject*);
775
+ int base_depth = 0;
776
+ {
777
+ PyTypeObject* base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
778
+ while (base) {
779
+ base_depth += 1;
780
+ base = __Pyx_PyType_TryGetSlot(base, tp_base, PyTypeObject*);
781
+ }
782
+ }
783
+ base_vtables = (void**) PyMem_Malloc(sizeof(void*) * (size_t)(base_depth + 1));
784
+ if (unlikely(!base_vtables)) {
785
+ PyErr_NoMemory();
786
+ return -1;
787
+ }
788
+ base_vtables[0] = unknown;
789
+ // Could do MRO resolution of individual methods in the future, assuming
790
+ // compatible vtables, but for now simply require a common vtable base.
791
+ // Note that if the vtables of various bases are extended separately,
792
+ // resolution isn't possible and we must reject it just as when the
793
+ // instance struct is so extended. (It would be good to also do this
794
+ // check when a multiple-base class is created in pure Python as well.)
795
+ #if CYTHON_COMPILING_IN_LIMITED_API
796
+ size = PyTuple_Size(bases);
797
+ if (size < 0) goto other_failure;
798
+ #else
799
+ size = PyTuple_GET_SIZE(bases);
800
+ #endif
801
+ for (i = 1; i < size; i++) {
802
+ PyObject *basei;
803
+ void* base_vtable;
804
+ #if CYTHON_AVOID_BORROWED_REFS
805
+ basei = PySequence_GetItem(bases, i);
806
+ if (unlikely(!basei)) goto other_failure;
807
+ #elif !CYTHON_ASSUME_SAFE_MACROS
808
+ basei = PyTuple_GetItem(bases, i);
809
+ if (unlikely(!basei)) goto other_failure;
810
+ #else
811
+ basei = PyTuple_GET_ITEM(bases, i);
812
+ #endif
813
+ int get_vtable_result = __Pyx_GetVtable((PyTypeObject*)basei, &base_vtable);
814
+ #if CYTHON_AVOID_BORROWED_REFS
815
+ Py_DECREF(basei);
816
+ #endif
817
+ if (get_vtable_result != 1) {
818
+ if (get_vtable_result == -1) {
819
+ goto other_failure;
820
+ }
821
+ PyErr_Clear(); // Class doesn't have a vtable.
822
+ } else {
823
+ assert(base_vtable != NULL);
824
+ int j;
825
+ PyTypeObject* base = __Pyx_PyType_TryGetSlot(type, tp_base, PyTypeObject*);
826
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
827
+ if (!base) goto bad;
828
+ #endif
829
+ for (j = 0; j < base_depth; j++) {
830
+ if (base_vtables[j] == unknown) {
831
+ switch (__Pyx_GetVtable(base, &base_vtables[j])) {
832
+ case 1:
833
+ assert(base_vtables[j] == NULL);
834
+ break;
835
+ case 0:
836
+ // No more potential matching bases (with vtables).
837
+ goto bad;
838
+ case -1:
839
+ default:
840
+ goto other_failure;
841
+ }
842
+ base_vtables[j + 1] = unknown;
843
+ }
844
+ if (base_vtables[j] == base_vtable) {
845
+ break;
846
+ }
847
+ base = __Pyx_PyType_TryGetSlot(base, tp_base, PyTypeObject*);
848
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
849
+ if (!base) goto bad;
850
+ #endif
851
+ }
852
+ }
853
+ }
854
+ PyMem_Free(base_vtables);
855
+ return 0;
856
+ bad:
857
+ {
858
+ PyTypeObject* tp_base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
859
+ PyTypeObject* basei;
860
+ #if CYTHON_AVOID_BORROWED_REFS
861
+ basei = (PyTypeObject*)PySequence_GetItem(bases, i);
862
+ if (unlikely(!basei)) goto other_failure;
863
+ #elif !CYTHON_ASSUME_SAFE_MACROS
864
+ basei = (PyTypeObject*)PyTuple_GetItem(bases, i);
865
+ if (unlikely(!basei)) goto other_failure;
866
+ #else
867
+ basei = (PyTypeObject*)PyTuple_GET_ITEM(bases, i);
868
+ #endif
869
+
870
+ __Pyx_RaiseTypeErrorWithTypes(
871
+ "multiple bases have vtable conflict: '" __Pyx_FMT_TYPENAME "' and '" __Pyx_FMT_TYPENAME "'", tp_base, basei);
872
+
873
+ #if CYTHON_AVOID_BORROWED_REFS
874
+ Py_DECREF(basei);
875
+ #endif
876
+ }
877
+ other_failure:
878
+ PyMem_Free(base_vtables);
879
+ return -1;
880
+ }
881
+
882
+ /////////////// ImportNumPyArray.module_state_decls //////////////
883
+ //@requires: Synchronization.c::Atomics
884
+
885
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
886
+ __pyx_atomic_ptr_type __pyx_numpy_ndarray;
887
+ #else
888
+ // If freethreading but not atomics, then this is guarded by ndarray_mutex
889
+ // in __Pyx__ImportNumPyArrayTypeIfAvailable
890
+ PyObject *__pyx_numpy_ndarray;
891
+ #endif
892
+
893
+ /////////////// ImportNumPyArray.proto ///////////////
894
+
895
+ static PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void); /*proto*/
896
+
897
+ /////////////// ImportNumPyArray.cleanup ///////////////
898
+
899
+ // I'm not actually worried about thread-safety in the cleanup function.
900
+ // The CYTHON_ATOMICS code is only for the type-casting.
901
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
902
+ {
903
+ PyObject* old = (PyObject*)__pyx_atomic_pointer_exchange(&CGLOBAL(__pyx_numpy_ndarray), NULL);
904
+ Py_XDECREF(old);
905
+ }
906
+ #else
907
+ Py_CLEAR(CGLOBAL(__pyx_numpy_ndarray));
908
+ #endif
909
+
910
+ /////////////// ImportNumPyArray ///////////////
911
+ //@requires: ImportExport.c::Import
912
+ //@requires: Exceptions.c::IgnoreException
913
+
914
+ static PyObject* __Pyx__ImportNumPyArray(void) {
915
+ PyObject *numpy_module, *ndarray_object = NULL;
916
+ numpy_module = __Pyx_Import(PYIDENT("numpy"), NULL, 0, NULL, 0);
917
+ if (likely(numpy_module)) {
918
+ ndarray_object = PyObject_GetAttrString(numpy_module, "ndarray");
919
+ Py_DECREF(numpy_module);
920
+ }
921
+ if (unlikely(!ndarray_object)) {
922
+ if (!__Pyx_IgnoreException(PyExc_Exception)) {
923
+ return NULL;
924
+ }
925
+ }
926
+ if (unlikely(!ndarray_object || !PyObject_TypeCheck(ndarray_object, &PyType_Type))) {
927
+ Py_XDECREF(ndarray_object);
928
+ Py_INCREF(Py_None);
929
+ ndarray_object = Py_None;
930
+ }
931
+ return ndarray_object;
932
+ }
933
+
934
+ // Returns a borrowed reference, and encapsulates all thread safety stuff needed
935
+ static CYTHON_INLINE PyObject* __Pyx__ImportNumPyArrayTypeIfAvailable(void) {
936
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
937
+ static PyMutex ndarray_mutex = {0};
938
+ #endif
939
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
940
+ PyObject *result = (PyObject*)__pyx_atomic_pointer_load_relaxed(&CGLOBAL(__pyx_numpy_ndarray));
941
+ if (unlikely(!result)) {
942
+ PyMutex_Lock(&ndarray_mutex);
943
+ // Now we've got the lock and know that no-one else is modifying it, check again
944
+ // that it hasn't already been set.
945
+ result = (PyObject*)__pyx_atomic_pointer_load_acquire(&CGLOBAL(__pyx_numpy_ndarray));
946
+ if (!result) {
947
+ result = __Pyx__ImportNumPyArray();
948
+ __pyx_atomic_pointer_exchange(&CGLOBAL(__pyx_numpy_ndarray), result);
949
+ }
950
+ PyMutex_Unlock(&ndarray_mutex);
951
+ }
952
+ return result;
953
+ #else
954
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING // but not atomics
955
+ PyMutex_Lock(&ndarray_mutex);
956
+ #endif
957
+ if (unlikely(!CGLOBAL(__pyx_numpy_ndarray)))
958
+ {
959
+ CGLOBAL(__pyx_numpy_ndarray) = __Pyx__ImportNumPyArray();
960
+ }
961
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING // but not atomics
962
+ PyMutex_Unlock(&ndarray_mutex);
963
+ #endif
964
+ return CGLOBAL(__pyx_numpy_ndarray);
965
+ #endif
966
+ }
967
+
968
+ static CYTHON_INLINE PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void) {
969
+ PyObject *result = __Pyx__ImportNumPyArrayTypeIfAvailable();
970
+ Py_XINCREF(result);
971
+ return result;
972
+ }