Cython 3.1.0a1__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 (301) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +250 -0
  4. Cython/Build/Dependencies.py +1275 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +342 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/Tests/TestCyCache.py +119 -0
  9. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  10. Cython/Build/Tests/TestDependencies.py +133 -0
  11. Cython/Build/Tests/TestInline.py +112 -0
  12. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  13. Cython/Build/Tests/TestRecythonize.py +212 -0
  14. Cython/Build/Tests/TestStripLiterals.py +155 -0
  15. Cython/Build/Tests/__init__.py +1 -0
  16. Cython/Build/__init__.py +8 -0
  17. Cython/CodeWriter.py +811 -0
  18. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  19. Cython/Compiler/Annotate.py +326 -0
  20. Cython/Compiler/AutoDocTransforms.py +314 -0
  21. Cython/Compiler/Buffer.py +680 -0
  22. Cython/Compiler/Builtin.py +862 -0
  23. Cython/Compiler/CmdLine.py +243 -0
  24. Cython/Compiler/Code.pxd +145 -0
  25. Cython/Compiler/Code.py +3328 -0
  26. Cython/Compiler/CodeGeneration.py +33 -0
  27. Cython/Compiler/CythonScope.py +179 -0
  28. Cython/Compiler/Dataclass.py +868 -0
  29. Cython/Compiler/DebugFlags.py +21 -0
  30. Cython/Compiler/Errors.py +295 -0
  31. Cython/Compiler/ExprNodes.py +15051 -0
  32. Cython/Compiler/FlowControl.pxd +97 -0
  33. Cython/Compiler/FlowControl.py +1438 -0
  34. Cython/Compiler/FusedNode.py +998 -0
  35. Cython/Compiler/Future.py +16 -0
  36. Cython/Compiler/Interpreter.py +57 -0
  37. Cython/Compiler/Lexicon.py +340 -0
  38. Cython/Compiler/LineTable.py +114 -0
  39. Cython/Compiler/Main.py +779 -0
  40. Cython/Compiler/MatchCaseNodes.py +259 -0
  41. Cython/Compiler/MemoryView.py +860 -0
  42. Cython/Compiler/ModuleNode.py +4065 -0
  43. Cython/Compiler/Naming.py +369 -0
  44. Cython/Compiler/Nodes.py +10557 -0
  45. Cython/Compiler/Optimize.py +5269 -0
  46. Cython/Compiler/Options.py +828 -0
  47. Cython/Compiler/ParseTreeTransforms.pxd +78 -0
  48. Cython/Compiler/ParseTreeTransforms.py +4441 -0
  49. Cython/Compiler/Parsing.pxd +9 -0
  50. Cython/Compiler/Parsing.py +4797 -0
  51. Cython/Compiler/Pipeline.py +425 -0
  52. Cython/Compiler/PyrexTypes.py +5572 -0
  53. Cython/Compiler/Pythran.py +223 -0
  54. Cython/Compiler/Scanning.pxd +40 -0
  55. Cython/Compiler/Scanning.py +574 -0
  56. Cython/Compiler/StringEncoding.py +347 -0
  57. Cython/Compiler/Symtab.py +2998 -0
  58. Cython/Compiler/Tests/TestBuffer.py +105 -0
  59. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  60. Cython/Compiler/Tests/TestCmdLine.py +573 -0
  61. Cython/Compiler/Tests/TestCode.py +86 -0
  62. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  63. Cython/Compiler/Tests/TestGrammar.py +202 -0
  64. Cython/Compiler/Tests/TestMemView.py +71 -0
  65. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  66. Cython/Compiler/Tests/TestScanning.py +134 -0
  67. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  68. Cython/Compiler/Tests/TestStringEncoding.py +33 -0
  69. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  70. Cython/Compiler/Tests/TestTreePath.py +93 -0
  71. Cython/Compiler/Tests/TestTypes.py +75 -0
  72. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  73. Cython/Compiler/Tests/TestVisitor.py +61 -0
  74. Cython/Compiler/Tests/Utils.py +36 -0
  75. Cython/Compiler/Tests/__init__.py +1 -0
  76. Cython/Compiler/TreeFragment.py +278 -0
  77. Cython/Compiler/TreePath.py +290 -0
  78. Cython/Compiler/TypeInference.py +584 -0
  79. Cython/Compiler/TypeSlots.py +1181 -0
  80. Cython/Compiler/UFuncs.py +311 -0
  81. Cython/Compiler/UtilNodes.py +387 -0
  82. Cython/Compiler/UtilityCode.py +274 -0
  83. Cython/Compiler/Version.py +8 -0
  84. Cython/Compiler/Visitor.pxd +53 -0
  85. Cython/Compiler/Visitor.py +861 -0
  86. Cython/Compiler/__init__.py +1 -0
  87. Cython/Coverage.py +443 -0
  88. Cython/Debugger/Cygdb.py +179 -0
  89. Cython/Debugger/DebugWriter.py +82 -0
  90. Cython/Debugger/Tests/TestLibCython.py +275 -0
  91. Cython/Debugger/Tests/__init__.py +1 -0
  92. Cython/Debugger/Tests/cfuncs.c +8 -0
  93. Cython/Debugger/Tests/codefile +49 -0
  94. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  95. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  96. Cython/Debugger/__init__.py +1 -0
  97. Cython/Debugger/libcython.py +1549 -0
  98. Cython/Debugger/libpython.py +2821 -0
  99. Cython/Debugging.py +20 -0
  100. Cython/Distutils/__init__.py +2 -0
  101. Cython/Distutils/build_ext.py +137 -0
  102. Cython/Distutils/extension.py +96 -0
  103. Cython/Distutils/old_build_ext.py +351 -0
  104. Cython/Includes/cpython/__init__.pxd +173 -0
  105. Cython/Includes/cpython/array.pxd +174 -0
  106. Cython/Includes/cpython/bool.pxd +37 -0
  107. Cython/Includes/cpython/buffer.pxd +112 -0
  108. Cython/Includes/cpython/bytearray.pxd +33 -0
  109. Cython/Includes/cpython/bytes.pxd +200 -0
  110. Cython/Includes/cpython/cellobject.pxd +35 -0
  111. Cython/Includes/cpython/ceval.pxd +8 -0
  112. Cython/Includes/cpython/codecs.pxd +121 -0
  113. Cython/Includes/cpython/complex.pxd +55 -0
  114. Cython/Includes/cpython/contextvars.pxd +141 -0
  115. Cython/Includes/cpython/conversion.pxd +36 -0
  116. Cython/Includes/cpython/datetime.pxd +384 -0
  117. Cython/Includes/cpython/descr.pxd +26 -0
  118. Cython/Includes/cpython/dict.pxd +187 -0
  119. Cython/Includes/cpython/exc.pxd +263 -0
  120. Cython/Includes/cpython/fileobject.pxd +57 -0
  121. Cython/Includes/cpython/float.pxd +47 -0
  122. Cython/Includes/cpython/function.pxd +65 -0
  123. Cython/Includes/cpython/genobject.pxd +25 -0
  124. Cython/Includes/cpython/getargs.pxd +12 -0
  125. Cython/Includes/cpython/instance.pxd +25 -0
  126. Cython/Includes/cpython/iterator.pxd +36 -0
  127. Cython/Includes/cpython/iterobject.pxd +24 -0
  128. Cython/Includes/cpython/list.pxd +92 -0
  129. Cython/Includes/cpython/long.pxd +149 -0
  130. Cython/Includes/cpython/longintrepr.pxd +19 -0
  131. Cython/Includes/cpython/mapping.pxd +63 -0
  132. Cython/Includes/cpython/marshal.pxd +66 -0
  133. Cython/Includes/cpython/mem.pxd +120 -0
  134. Cython/Includes/cpython/memoryview.pxd +50 -0
  135. Cython/Includes/cpython/method.pxd +49 -0
  136. Cython/Includes/cpython/module.pxd +208 -0
  137. Cython/Includes/cpython/number.pxd +258 -0
  138. Cython/Includes/cpython/object.pxd +433 -0
  139. Cython/Includes/cpython/pycapsule.pxd +143 -0
  140. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  141. Cython/Includes/cpython/pyport.pxd +8 -0
  142. Cython/Includes/cpython/pystate.pxd +95 -0
  143. Cython/Includes/cpython/pythread.pxd +53 -0
  144. Cython/Includes/cpython/ref.pxd +67 -0
  145. Cython/Includes/cpython/sequence.pxd +134 -0
  146. Cython/Includes/cpython/set.pxd +119 -0
  147. Cython/Includes/cpython/slice.pxd +70 -0
  148. Cython/Includes/cpython/time.pxd +129 -0
  149. Cython/Includes/cpython/tuple.pxd +72 -0
  150. Cython/Includes/cpython/type.pxd +53 -0
  151. Cython/Includes/cpython/unicode.pxd +639 -0
  152. Cython/Includes/cpython/version.pxd +32 -0
  153. Cython/Includes/cpython/weakref.pxd +42 -0
  154. Cython/Includes/libc/__init__.pxd +1 -0
  155. Cython/Includes/libc/complex.pxd +35 -0
  156. Cython/Includes/libc/errno.pxd +127 -0
  157. Cython/Includes/libc/float.pxd +43 -0
  158. Cython/Includes/libc/limits.pxd +28 -0
  159. Cython/Includes/libc/locale.pxd +46 -0
  160. Cython/Includes/libc/math.pxd +209 -0
  161. Cython/Includes/libc/setjmp.pxd +10 -0
  162. Cython/Includes/libc/signal.pxd +64 -0
  163. Cython/Includes/libc/stddef.pxd +9 -0
  164. Cython/Includes/libc/stdint.pxd +105 -0
  165. Cython/Includes/libc/stdio.pxd +80 -0
  166. Cython/Includes/libc/stdlib.pxd +72 -0
  167. Cython/Includes/libc/string.pxd +50 -0
  168. Cython/Includes/libc/time.pxd +47 -0
  169. Cython/Includes/libcpp/__init__.pxd +4 -0
  170. Cython/Includes/libcpp/algorithm.pxd +320 -0
  171. Cython/Includes/libcpp/any.pxd +16 -0
  172. Cython/Includes/libcpp/atomic.pxd +59 -0
  173. Cython/Includes/libcpp/bit.pxd +29 -0
  174. Cython/Includes/libcpp/cast.pxd +12 -0
  175. Cython/Includes/libcpp/cmath.pxd +518 -0
  176. Cython/Includes/libcpp/complex.pxd +106 -0
  177. Cython/Includes/libcpp/deque.pxd +165 -0
  178. Cython/Includes/libcpp/execution.pxd +15 -0
  179. Cython/Includes/libcpp/forward_list.pxd +63 -0
  180. Cython/Includes/libcpp/functional.pxd +26 -0
  181. Cython/Includes/libcpp/iterator.pxd +34 -0
  182. Cython/Includes/libcpp/limits.pxd +61 -0
  183. Cython/Includes/libcpp/list.pxd +117 -0
  184. Cython/Includes/libcpp/map.pxd +252 -0
  185. Cython/Includes/libcpp/memory.pxd +115 -0
  186. Cython/Includes/libcpp/numbers.pxd +15 -0
  187. Cython/Includes/libcpp/numeric.pxd +131 -0
  188. Cython/Includes/libcpp/optional.pxd +34 -0
  189. Cython/Includes/libcpp/pair.pxd +1 -0
  190. Cython/Includes/libcpp/queue.pxd +25 -0
  191. Cython/Includes/libcpp/random.pxd +166 -0
  192. Cython/Includes/libcpp/set.pxd +228 -0
  193. Cython/Includes/libcpp/stack.pxd +11 -0
  194. Cython/Includes/libcpp/string.pxd +333 -0
  195. Cython/Includes/libcpp/typeindex.pxd +15 -0
  196. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  197. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  198. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  199. Cython/Includes/libcpp/utility.pxd +30 -0
  200. Cython/Includes/libcpp/vector.pxd +167 -0
  201. Cython/Includes/openmp.pxd +50 -0
  202. Cython/Includes/posix/__init__.pxd +1 -0
  203. Cython/Includes/posix/dlfcn.pxd +14 -0
  204. Cython/Includes/posix/fcntl.pxd +86 -0
  205. Cython/Includes/posix/ioctl.pxd +4 -0
  206. Cython/Includes/posix/mman.pxd +101 -0
  207. Cython/Includes/posix/resource.pxd +57 -0
  208. Cython/Includes/posix/select.pxd +21 -0
  209. Cython/Includes/posix/signal.pxd +73 -0
  210. Cython/Includes/posix/stat.pxd +98 -0
  211. Cython/Includes/posix/stdio.pxd +37 -0
  212. Cython/Includes/posix/stdlib.pxd +29 -0
  213. Cython/Includes/posix/strings.pxd +9 -0
  214. Cython/Includes/posix/time.pxd +71 -0
  215. Cython/Includes/posix/types.pxd +30 -0
  216. Cython/Includes/posix/uio.pxd +26 -0
  217. Cython/Includes/posix/unistd.pxd +271 -0
  218. Cython/Includes/posix/wait.pxd +38 -0
  219. Cython/Plex/Actions.pxd +24 -0
  220. Cython/Plex/Actions.py +119 -0
  221. Cython/Plex/DFA.pxd +14 -0
  222. Cython/Plex/DFA.py +164 -0
  223. Cython/Plex/Errors.py +48 -0
  224. Cython/Plex/Lexicons.py +178 -0
  225. Cython/Plex/Machines.pxd +36 -0
  226. Cython/Plex/Machines.py +238 -0
  227. Cython/Plex/Regexps.py +539 -0
  228. Cython/Plex/Scanners.pxd +47 -0
  229. Cython/Plex/Scanners.py +360 -0
  230. Cython/Plex/Transitions.pxd +14 -0
  231. Cython/Plex/Transitions.py +239 -0
  232. Cython/Plex/__init__.py +34 -0
  233. Cython/Runtime/__init__.py +1 -0
  234. Cython/Runtime/refnanny.pyx +261 -0
  235. Cython/Shadow.py +656 -0
  236. Cython/Shadow.pyi +521 -0
  237. Cython/StringIOTree.py +170 -0
  238. Cython/Tempita/__init__.py +4 -0
  239. Cython/Tempita/_looper.py +154 -0
  240. Cython/Tempita/_tempita.py +1091 -0
  241. Cython/TestUtils.py +417 -0
  242. Cython/Tests/TestCodeWriter.py +128 -0
  243. Cython/Tests/TestCythonUtils.py +202 -0
  244. Cython/Tests/TestJediTyper.py +223 -0
  245. Cython/Tests/TestShadow.py +114 -0
  246. Cython/Tests/TestStringIOTree.py +67 -0
  247. Cython/Tests/TestTestUtils.py +90 -0
  248. Cython/Tests/__init__.py +1 -0
  249. Cython/Tests/xmlrunner.py +390 -0
  250. Cython/Utility/AsyncGen.c +1263 -0
  251. Cython/Utility/Buffer.c +875 -0
  252. Cython/Utility/Builtins.c +660 -0
  253. Cython/Utility/CConvert.pyx +134 -0
  254. Cython/Utility/CMath.c +95 -0
  255. Cython/Utility/CommonStructures.c +139 -0
  256. Cython/Utility/Complex.c +378 -0
  257. Cython/Utility/Coroutine.c +2413 -0
  258. Cython/Utility/CpdefEnums.pyx +108 -0
  259. Cython/Utility/CppConvert.pyx +279 -0
  260. Cython/Utility/CppSupport.cpp +133 -0
  261. Cython/Utility/CythonFunction.c +1851 -0
  262. Cython/Utility/Dataclasses.c +185 -0
  263. Cython/Utility/Dataclasses.py +112 -0
  264. Cython/Utility/Embed.c +125 -0
  265. Cython/Utility/Exceptions.c +1017 -0
  266. Cython/Utility/ExtensionTypes.c +797 -0
  267. Cython/Utility/FunctionArguments.c +573 -0
  268. Cython/Utility/ImportExport.c +912 -0
  269. Cython/Utility/MemoryView.pyx +1478 -0
  270. Cython/Utility/MemoryView_C.c +992 -0
  271. Cython/Utility/ModuleSetupCode.c +2501 -0
  272. Cython/Utility/NumpyImportArray.c +46 -0
  273. Cython/Utility/ObjectHandling.c +3054 -0
  274. Cython/Utility/Optimize.c +1533 -0
  275. Cython/Utility/Overflow.c +404 -0
  276. Cython/Utility/Printing.c +86 -0
  277. Cython/Utility/Profile.c +660 -0
  278. Cython/Utility/StringTools.c +1206 -0
  279. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  280. Cython/Utility/TestCythonScope.pyx +75 -0
  281. Cython/Utility/TestUtilityLoader.c +12 -0
  282. Cython/Utility/TypeConversion.c +1329 -0
  283. Cython/Utility/UFuncs.pyx +50 -0
  284. Cython/Utility/UFuncs_C.c +89 -0
  285. Cython/Utility/__init__.py +28 -0
  286. Cython/Utility/arrayarray.h +143 -0
  287. Cython/Utils.py +687 -0
  288. Cython/__init__.py +10 -0
  289. Cython/__init__.pyi +7 -0
  290. Cython/py.typed +0 -0
  291. Cython-3.1.0a1.dist-info/COPYING.txt +19 -0
  292. Cython-3.1.0a1.dist-info/LICENSE.txt +176 -0
  293. Cython-3.1.0a1.dist-info/METADATA +67 -0
  294. Cython-3.1.0a1.dist-info/RECORD +301 -0
  295. Cython-3.1.0a1.dist-info/WHEEL +5 -0
  296. Cython-3.1.0a1.dist-info/entry_points.txt +4 -0
  297. Cython-3.1.0a1.dist-info/top_level.txt +3 -0
  298. cython.py +29 -0
  299. pyximport/__init__.py +4 -0
  300. pyximport/pyxbuild.py +160 -0
  301. pyximport/pyximport.py +482 -0
@@ -0,0 +1,912 @@
1
+ /////////////// ImportDottedModule.proto ///////////////
2
+
3
+ static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple); /*proto*/
4
+ static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple); /*proto*/
5
+
6
+
7
+ /////////////// ImportDottedModule ///////////////
8
+ //@requires: Import
9
+
10
+ static PyObject *__Pyx__ImportDottedModule_Error(PyObject *name, PyObject *parts_tuple, Py_ssize_t count) {
11
+ PyObject *partial_name = NULL, *slice = NULL, *sep = NULL;
12
+ Py_ssize_t size;
13
+ if (unlikely(PyErr_Occurred())) {
14
+ PyErr_Clear();
15
+ }
16
+ #if CYTHON_ASSUME_SAFE_SIZE
17
+ size = PyTuple_GET_SIZE(parts_tuple);
18
+ #else
19
+ size = PyTuple_Size(parts_tuple);
20
+ if (size < 0) goto bad;
21
+ #endif
22
+ if (likely(size == count)) {
23
+ partial_name = name;
24
+ } else {
25
+ slice = PySequence_GetSlice(parts_tuple, 0, count);
26
+ if (unlikely(!slice))
27
+ goto bad;
28
+ sep = PyUnicode_FromStringAndSize(".", 1);
29
+ if (unlikely(!sep))
30
+ goto bad;
31
+ partial_name = PyUnicode_Join(sep, slice);
32
+ }
33
+
34
+ PyErr_Format(
35
+ PyExc_ModuleNotFoundError,
36
+ "No module named '%U'", partial_name);
37
+
38
+ bad:
39
+ Py_XDECREF(sep);
40
+ Py_XDECREF(slice);
41
+ Py_XDECREF(partial_name);
42
+ return NULL;
43
+ }
44
+
45
+ static PyObject *__Pyx__ImportDottedModule_Lookup(PyObject *name) {
46
+ PyObject *imported_module;
47
+ #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) || \
48
+ CYTHON_COMPILING_IN_GRAAL
49
+ PyObject *modules = PyImport_GetModuleDict();
50
+ if (unlikely(!modules))
51
+ return NULL;
52
+ imported_module = __Pyx_PyDict_GetItemStr(modules, name);
53
+ Py_XINCREF(imported_module);
54
+ #else
55
+ imported_module = PyImport_GetModule(name);
56
+ #endif
57
+ return imported_module;
58
+ }
59
+
60
+ static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple) {
61
+ Py_ssize_t i, nparts;
62
+ #if CYTHON_ASSUME_SAFE_SIZE
63
+ nparts = PyTuple_GET_SIZE(parts_tuple);
64
+ #else
65
+ nparts = PyTuple_Size(parts_tuple);
66
+ if (nparts < 0) return NULL;
67
+ #endif
68
+ for (i=1; i < nparts && module; i++) {
69
+ PyObject *part, *submodule;
70
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
71
+ part = PyTuple_GET_ITEM(parts_tuple, i);
72
+ #else
73
+ part = __Pyx_PySequence_ITEM(parts_tuple, i);
74
+ if (!part) return NULL;
75
+ #endif
76
+ submodule = __Pyx_PyObject_GetAttrStrNoError(module, part);
77
+ // We stop if the attribute isn't found, i.e. if submodule is NULL here.
78
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
79
+ Py_DECREF(part);
80
+ #endif
81
+ Py_DECREF(module);
82
+ module = submodule;
83
+ }
84
+ if (unlikely(!module)) {
85
+ return __Pyx__ImportDottedModule_Error(name, parts_tuple, i);
86
+ }
87
+ return module;
88
+ }
89
+
90
+ static PyObject *__Pyx__ImportDottedModule(PyObject *name, PyObject *parts_tuple) {
91
+ PyObject *imported_module;
92
+ PyObject *module = __Pyx_Import(name, NULL, 0);
93
+ if (!parts_tuple || unlikely(!module))
94
+ return module;
95
+
96
+ // Look up module in sys.modules, which is safer than the attribute lookups below.
97
+ imported_module = __Pyx__ImportDottedModule_Lookup(name);
98
+ if (likely(imported_module)) {
99
+ Py_DECREF(module);
100
+ return imported_module;
101
+ }
102
+ PyErr_Clear();
103
+ return __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple);
104
+ }
105
+
106
+ static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple) {
107
+ #if CYTHON_COMPILING_IN_CPYTHON
108
+ PyObject *module = __Pyx__ImportDottedModule_Lookup(name);
109
+ if (likely(module)) {
110
+ // CPython guards against thread-concurrent initialisation in importlib.
111
+ // In this case, we let PyImport_ImportModuleLevelObject() handle the locking.
112
+ PyObject *spec = __Pyx_PyObject_GetAttrStrNoError(module, PYIDENT("__spec__"));
113
+ if (likely(spec)) {
114
+ PyObject *unsafe = __Pyx_PyObject_GetAttrStrNoError(spec, PYIDENT("_initializing"));
115
+ if (likely(!unsafe || !__Pyx_PyObject_IsTrue(unsafe))) {
116
+ Py_DECREF(spec);
117
+ spec = NULL;
118
+ }
119
+ Py_XDECREF(unsafe);
120
+ }
121
+ if (likely(!spec)) {
122
+ // Not in initialisation phase => use modules as is.
123
+ PyErr_Clear();
124
+ return module;
125
+ }
126
+ Py_DECREF(spec);
127
+ Py_DECREF(module);
128
+ } else if (PyErr_Occurred()) {
129
+ PyErr_Clear();
130
+ }
131
+ #endif
132
+
133
+ return __Pyx__ImportDottedModule(name, parts_tuple);
134
+ }
135
+
136
+
137
+ /////////////// ImportDottedModuleRelFirst.proto ///////////////
138
+
139
+ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple); /*proto*/
140
+
141
+ /////////////// ImportDottedModuleRelFirst ///////////////
142
+ //@requires: ImportDottedModule
143
+ //@requires: Import
144
+
145
+ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple) {
146
+ PyObject *module;
147
+ PyObject *from_list = NULL;
148
+ module = __Pyx_Import(name, from_list, -1);
149
+ Py_XDECREF(from_list);
150
+ if (module) {
151
+ if (parts_tuple) {
152
+ module = __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple);
153
+ }
154
+ return module;
155
+ }
156
+ if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
157
+ return NULL;
158
+ PyErr_Clear();
159
+ // try absolute import
160
+ return __Pyx_ImportDottedModule(name, parts_tuple);
161
+ }
162
+
163
+
164
+ /////////////// Import.proto ///////////////
165
+
166
+ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/
167
+
168
+ /////////////// Import ///////////////
169
+ //@requires: ObjectHandling.c::PyObjectGetAttrStr
170
+ //@requires:StringTools.c::IncludeStringH
171
+
172
+ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
173
+ PyObject *module = 0;
174
+ PyObject *empty_dict = 0;
175
+ PyObject *empty_list = 0;
176
+ empty_dict = PyDict_New();
177
+ if (unlikely(!empty_dict))
178
+ goto bad;
179
+ if (level == -1) {
180
+ if (strchr(__Pyx_MODULE_NAME, '.') != (0)) {
181
+ /* try package relative import first */
182
+ module = PyImport_ImportModuleLevelObject(
183
+ name, NAMED_CGLOBAL(moddict_cname), empty_dict, from_list, 1);
184
+ if (unlikely(!module)) {
185
+ if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
186
+ goto bad;
187
+ PyErr_Clear();
188
+ }
189
+ }
190
+ level = 0; /* try absolute import on failure */
191
+ }
192
+ if (!module) {
193
+ module = PyImport_ImportModuleLevelObject(
194
+ name, NAMED_CGLOBAL(moddict_cname), empty_dict, from_list, level);
195
+ }
196
+ bad:
197
+ Py_XDECREF(empty_dict);
198
+ Py_XDECREF(empty_list);
199
+ return module;
200
+ }
201
+
202
+
203
+ /////////////// ImportFrom.proto ///////////////
204
+
205
+ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/
206
+
207
+ /////////////// ImportFrom ///////////////
208
+ //@requires: ObjectHandling.c::PyObjectGetAttrStr
209
+
210
+ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
211
+ PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
212
+ if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
213
+ // 'name' may refer to a (sub-)module which has not finished initialization
214
+ // yet, and may not be assigned as an attribute to its parent, so try
215
+ // finding it by full name.
216
+ const char* module_name_str = 0;
217
+ PyObject* module_name = 0;
218
+ PyObject* module_dot = 0;
219
+ PyObject* full_name = 0;
220
+ PyErr_Clear();
221
+ module_name_str = PyModule_GetName(module);
222
+ if (unlikely(!module_name_str)) { goto modbad; }
223
+ module_name = PyUnicode_FromString(module_name_str);
224
+ if (unlikely(!module_name)) { goto modbad; }
225
+ module_dot = PyUnicode_Concat(module_name, PYUNICODE("."));
226
+ if (unlikely(!module_dot)) { goto modbad; }
227
+ full_name = PyUnicode_Concat(module_dot, name);
228
+ if (unlikely(!full_name)) { goto modbad; }
229
+ #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) || \
230
+ CYTHON_COMPILING_IN_GRAAL
231
+ {
232
+ PyObject *modules = PyImport_GetModuleDict();
233
+ if (unlikely(!modules))
234
+ goto modbad;
235
+ value = PyObject_GetItem(modules, full_name);
236
+ }
237
+ #else
238
+ value = PyImport_GetModule(full_name);
239
+ #endif
240
+
241
+ modbad:
242
+ Py_XDECREF(full_name);
243
+ Py_XDECREF(module_dot);
244
+ Py_XDECREF(module_name);
245
+ }
246
+ if (unlikely(!value)) {
247
+ PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
248
+ }
249
+ return value;
250
+ }
251
+
252
+
253
+ /////////////// ImportStar ///////////////
254
+ //@substitute: naming
255
+
256
+ /* import_all_from is an unexposed function from ceval.c */
257
+
258
+ static int
259
+ __Pyx_import_all_from(PyObject *locals, PyObject *v)
260
+ {
261
+ PyObject *all = PyObject_GetAttrString(v, "__all__");
262
+ PyObject *dict, *name, *value;
263
+ int skip_leading_underscores = 0;
264
+ int pos, err;
265
+
266
+ if (all == NULL) {
267
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError))
268
+ return -1; /* Unexpected error */
269
+ PyErr_Clear();
270
+ dict = PyObject_GetAttrString(v, "__dict__");
271
+ if (dict == NULL) {
272
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError))
273
+ return -1;
274
+ PyErr_SetString(PyExc_ImportError,
275
+ "from-import-* object has no __dict__ and no __all__");
276
+ return -1;
277
+ }
278
+ all = PyMapping_Keys(dict);
279
+ Py_DECREF(dict);
280
+ if (all == NULL)
281
+ return -1;
282
+ skip_leading_underscores = 1;
283
+ }
284
+
285
+ for (pos = 0, err = 0; ; pos++) {
286
+ name = PySequence_GetItem(all, pos);
287
+ if (name == NULL) {
288
+ if (!PyErr_ExceptionMatches(PyExc_IndexError))
289
+ err = -1;
290
+ else
291
+ PyErr_Clear();
292
+ break;
293
+ }
294
+ if (skip_leading_underscores && likely(PyUnicode_Check(name))) {
295
+ Py_ssize_t length = __Pyx_PyUnicode_GET_LENGTH(name);
296
+ #if !CYTHON_ASSUME_SAFE_SIZE
297
+ if (unlikely(length < 0)) {
298
+ Py_DECREF(name);
299
+ return -1;
300
+ }
301
+ #endif
302
+ if (likely(length) && __Pyx_PyUnicode_READ_CHAR(name, 0) == '_') {
303
+ Py_DECREF(name);
304
+ continue;
305
+ }
306
+ }
307
+ value = PyObject_GetAttr(v, name);
308
+ if (value == NULL)
309
+ err = -1;
310
+ else if (PyDict_CheckExact(locals))
311
+ err = PyDict_SetItem(locals, name, value);
312
+ else
313
+ err = PyObject_SetItem(locals, name, value);
314
+ Py_DECREF(name);
315
+ Py_XDECREF(value);
316
+ if (err != 0)
317
+ break;
318
+ }
319
+ Py_DECREF(all);
320
+ return err;
321
+ }
322
+
323
+
324
+ static int ${import_star}(PyObject* m) {
325
+
326
+ int i;
327
+ int ret = -1;
328
+ const char* s;
329
+ PyObject *locals = 0;
330
+ PyObject *list = 0;
331
+ PyObject *utf8_name = 0;
332
+ PyObject *name;
333
+ PyObject *item;
334
+ PyObject *import_obj;
335
+ Py_ssize_t size;
336
+ ${modulestatetype_cname} *mstate = __Pyx_PyModule_GetState(m);
337
+
338
+ locals = PyDict_New(); if (!locals) goto bad;
339
+ if (__Pyx_import_all_from(locals, m) < 0) goto bad;
340
+ list = PyDict_Items(locals); if (!list) goto bad;
341
+
342
+ size = __Pyx_PyList_GET_SIZE(list);
343
+ #if !CYTHON_ASSUME_SAFE_SIZE
344
+ if (size < 0) goto bad;
345
+ #endif
346
+ for(i=0; i<size; i++) {
347
+ import_obj = __Pyx_PyList_GET_ITEM(list, i); if (!import_obj) goto bad;
348
+ name = __Pyx_PyTuple_GET_ITEM(import_obj, 0); if (!name) goto bad;
349
+ item = __Pyx_PyTuple_GET_ITEM(import_obj, 1); if (!item) goto bad;
350
+
351
+ utf8_name = PyUnicode_AsUTF8String(name);
352
+ if (!utf8_name) goto bad;
353
+ s = __Pyx_PyBytes_AsString(utf8_name); if (!s) goto bad;
354
+ if (${import_star_set}(mstate, item, name, s) < 0) goto bad;
355
+ Py_DECREF(utf8_name); utf8_name = 0;
356
+ }
357
+ ret = 0;
358
+
359
+ bad:
360
+ Py_XDECREF(locals);
361
+ Py_XDECREF(list);
362
+ Py_XDECREF(utf8_name);
363
+ return ret;
364
+ }
365
+
366
+
367
+ /////////////// SetPackagePathFromImportLib.proto ///////////////
368
+
369
+ #if !CYTHON_PEP489_MULTI_PHASE_INIT
370
+ static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name);
371
+ #else
372
+ #define __Pyx_SetPackagePathFromImportLib(a) 0
373
+ #endif
374
+
375
+ /////////////// SetPackagePathFromImportLib ///////////////
376
+ //@substitute: naming
377
+
378
+ #if !CYTHON_PEP489_MULTI_PHASE_INIT
379
+ static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name) {
380
+ PyObject *importlib, *osmod, *ossep, *parts, *package_path;
381
+ PyObject *file_path = NULL;
382
+ PyObject *item;
383
+ int result;
384
+ PyObject *spec;
385
+ // package_path = [importlib.util.find_spec(module_name).origin.rsplit(os.sep, 1)[0]]
386
+ importlib = PyImport_ImportModule("importlib.util");
387
+ if (unlikely(!importlib))
388
+ goto bad;
389
+ spec = PyObject_CallMethod(importlib, "find_spec", "(O)", module_name);
390
+ Py_DECREF(importlib);
391
+ if (unlikely(!spec))
392
+ goto bad;
393
+ file_path = PyObject_GetAttrString(spec, "origin");
394
+ Py_DECREF(spec);
395
+ if (unlikely(!file_path))
396
+ goto bad;
397
+
398
+ if (unlikely(PyObject_SetAttrString($module_cname, "__file__", file_path) < 0))
399
+ goto bad;
400
+
401
+ osmod = PyImport_ImportModule("os");
402
+ if (unlikely(!osmod))
403
+ goto bad;
404
+ ossep = PyObject_GetAttrString(osmod, "sep");
405
+ Py_DECREF(osmod);
406
+ if (unlikely(!ossep))
407
+ goto bad;
408
+ parts = PyObject_CallMethod(file_path, "rsplit", "(Oi)", ossep, 1);
409
+ Py_DECREF(file_path); file_path = NULL;
410
+ Py_DECREF(ossep);
411
+ if (unlikely(!parts))
412
+ goto bad;
413
+ #if CYTHON_ASSUME_SAFE_MACROS
414
+ package_path = Py_BuildValue("[O]", PyList_GET_ITEM(parts, 0));
415
+ #else
416
+ item = PyList_GetItem(parts, 0);
417
+ if (unlikely(!item))
418
+ goto bad;
419
+ package_path = Py_BuildValue("[O]", item);
420
+ #endif
421
+ Py_DECREF(parts);
422
+ if (unlikely(!package_path))
423
+ goto bad;
424
+ goto set_path;
425
+
426
+ bad:
427
+ PyErr_WriteUnraisable(module_name);
428
+ Py_XDECREF(file_path);
429
+
430
+ // set an empty path list on failure
431
+ PyErr_Clear();
432
+ package_path = PyList_New(0);
433
+ if (unlikely(!package_path))
434
+ return -1;
435
+
436
+ set_path:
437
+ result = PyObject_SetAttrString($module_cname, "__path__", package_path);
438
+ Py_DECREF(package_path);
439
+ return result;
440
+ }
441
+ #endif
442
+
443
+
444
+ /////////////// TypeImport.proto ///////////////
445
+ //@substitute: naming
446
+
447
+ #ifndef __PYX_HAVE_RT_ImportType_proto_$cyversion
448
+ #define __PYX_HAVE_RT_ImportType_proto_$cyversion
449
+
450
+ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
451
+ #include <stdalign.h>
452
+ #endif
453
+
454
+ #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L
455
+ #define __PYX_GET_STRUCT_ALIGNMENT_$cyversion(s) alignof(s)
456
+ #else
457
+ // best guess at what the alignment could be since we can't measure it
458
+ #define __PYX_GET_STRUCT_ALIGNMENT_$cyversion(s) sizeof(void*)
459
+ #endif
460
+
461
+ enum __Pyx_ImportType_CheckSize_$cyversion {
462
+ __Pyx_ImportType_CheckSize_Error_$cyversion = 0,
463
+ __Pyx_ImportType_CheckSize_Warn_$cyversion = 1,
464
+ __Pyx_ImportType_CheckSize_Ignore_$cyversion = 2
465
+ };
466
+
467
+ 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*/
468
+
469
+ #endif
470
+
471
+ /////////////// TypeImport ///////////////
472
+ //@substitute: naming
473
+
474
+ #ifndef __PYX_HAVE_RT_ImportType_$cyversion
475
+ #define __PYX_HAVE_RT_ImportType_$cyversion
476
+ static PyTypeObject *__Pyx_ImportType_$cyversion(PyObject *module, const char *module_name, const char *class_name,
477
+ size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_$cyversion check_size)
478
+ {
479
+ PyObject *result = 0;
480
+ char warning[200];
481
+ Py_ssize_t basicsize;
482
+ Py_ssize_t itemsize;
483
+ #if CYTHON_COMPILING_IN_LIMITED_API
484
+ PyObject *py_basicsize;
485
+ PyObject *py_itemsize;
486
+ #endif
487
+
488
+ result = PyObject_GetAttrString(module, class_name);
489
+ if (!result)
490
+ goto bad;
491
+ if (!PyType_Check(result)) {
492
+ PyErr_Format(PyExc_TypeError,
493
+ "%.200s.%.200s is not a type object",
494
+ module_name, class_name);
495
+ goto bad;
496
+ }
497
+ #if !CYTHON_COMPILING_IN_LIMITED_API
498
+ basicsize = ((PyTypeObject *)result)->tp_basicsize;
499
+ itemsize = ((PyTypeObject *)result)->tp_itemsize;
500
+ #else
501
+ py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
502
+ if (!py_basicsize)
503
+ goto bad;
504
+ basicsize = PyLong_AsSsize_t(py_basicsize);
505
+ Py_DECREF(py_basicsize);
506
+ py_basicsize = 0;
507
+ if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
508
+ goto bad;
509
+ py_itemsize = PyObject_GetAttrString(result, "__itemsize__");
510
+ if (!py_itemsize)
511
+ goto bad;
512
+ itemsize = PyLong_AsSsize_t(py_itemsize);
513
+ Py_DECREF(py_itemsize);
514
+ py_itemsize = 0;
515
+ if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred())
516
+ goto bad;
517
+ #endif
518
+ if (itemsize) {
519
+ // If itemsize is smaller than the alignment the struct can end up with some extra
520
+ // padding at the end. In this case we need to work out the maximum size that
521
+ // the padding could be when calculating the range of valid struct sizes.
522
+ if (size % alignment) {
523
+ // if this is true we've probably calculated the alignment wrongly
524
+ // (most likely because alignof isn't available)
525
+ alignment = size % alignment;
526
+ }
527
+ if (itemsize < (Py_ssize_t)alignment)
528
+ itemsize = (Py_ssize_t)alignment;
529
+ }
530
+ if ((size_t)(basicsize + itemsize) < size) {
531
+ PyErr_Format(PyExc_ValueError,
532
+ "%.200s.%.200s size changed, may indicate binary incompatibility. "
533
+ "Expected %zd from C header, got %zd from PyObject",
534
+ module_name, class_name, size, basicsize+itemsize);
535
+ goto bad;
536
+ }
537
+ // varobjects almost have structs between basicsize and basicsize + itemsize
538
+ // but the struct isn't always one of the two limiting values
539
+ if (check_size == __Pyx_ImportType_CheckSize_Error_$cyversion &&
540
+ ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) {
541
+ PyErr_Format(PyExc_ValueError,
542
+ "%.200s.%.200s size changed, may indicate binary incompatibility. "
543
+ "Expected %zd from C header, got %zd-%zd from PyObject",
544
+ module_name, class_name, size, basicsize, basicsize+itemsize);
545
+ goto bad;
546
+ }
547
+ else if (check_size == __Pyx_ImportType_CheckSize_Warn_$cyversion && (size_t)basicsize > size) {
548
+ PyOS_snprintf(warning, sizeof(warning),
549
+ "%s.%s size changed, may indicate binary incompatibility. "
550
+ "Expected %zd from C header, got %zd from PyObject",
551
+ module_name, class_name, size, basicsize);
552
+ if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
553
+ }
554
+ /* check_size == __Pyx_ImportType_CheckSize_Ignore does not warn nor error */
555
+ return (PyTypeObject *)result;
556
+ bad:
557
+ Py_XDECREF(result);
558
+ return NULL;
559
+ }
560
+ #endif
561
+
562
+ /////////////// FunctionImport.proto ///////////////
563
+ //@substitute: naming
564
+
565
+ static int __Pyx_ImportFunction_$cyversion(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
566
+
567
+ /////////////// FunctionImport ///////////////
568
+ //@substitute: naming
569
+ //@requires: TypeConversion.c::CFuncPtrFromPy
570
+
571
+ #ifndef __PYX_HAVE_RT_ImportFunction_$cyversion
572
+ #define __PYX_HAVE_RT_ImportFunction_$cyversion
573
+ static int __Pyx_ImportFunction_$cyversion(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
574
+ PyObject *d = 0;
575
+ PyObject *cobj = 0;
576
+
577
+ d = PyObject_GetAttrString(module, "$api_name");
578
+ if (!d)
579
+ goto bad;
580
+ cobj = PyDict_GetItemString(d, funcname);
581
+ if (!cobj) {
582
+ PyErr_Format(PyExc_ImportError,
583
+ "%.200s does not export expected C function %.200s",
584
+ PyModule_GetName(module), funcname);
585
+ goto bad;
586
+ }
587
+ if (!PyCapsule_IsValid(cobj, sig)) {
588
+ PyErr_Format(PyExc_TypeError,
589
+ "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
590
+ PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
591
+ goto bad;
592
+ }
593
+ *f = __Pyx_capsule_to_c_func_ptr_$cyversion(cobj, sig);
594
+ if (!(*f))
595
+ goto bad;
596
+ Py_DECREF(d);
597
+ return 0;
598
+ bad:
599
+ Py_XDECREF(d);
600
+ return -1;
601
+ }
602
+ #endif
603
+
604
+ /////////////// FunctionExport.proto ///////////////
605
+
606
+ static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /*proto*/
607
+
608
+ /////////////// FunctionExport ///////////////
609
+ //@substitute: naming
610
+ //@requires: TypeConversion.c::CFuncPtrToPy
611
+
612
+ static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
613
+ PyObject *d = 0;
614
+ PyObject *cobj = 0;
615
+
616
+ d = PyObject_GetAttrString($module_cname, "$api_name");
617
+ if (!d) {
618
+ PyErr_Clear();
619
+ d = PyDict_New();
620
+ if (!d)
621
+ goto bad;
622
+ Py_INCREF(d);
623
+ if (PyModule_AddObject($module_cname, "$api_name", d) < 0)
624
+ goto bad;
625
+ }
626
+ cobj = __Pyx_c_func_ptr_to_capsule(f, sig);
627
+ if (!cobj)
628
+ goto bad;
629
+ if (PyDict_SetItemString(d, name, cobj) < 0)
630
+ goto bad;
631
+ Py_DECREF(cobj);
632
+ Py_DECREF(d);
633
+ return 0;
634
+ bad:
635
+ Py_XDECREF(cobj);
636
+ Py_XDECREF(d);
637
+ return -1;
638
+ }
639
+
640
+ /////////////// VoidPtrImport.proto ///////////////
641
+ //@substitute: naming
642
+
643
+ static int __Pyx_ImportVoidPtr_$cyversion(PyObject *module, const char *name, void **p, const char *sig); /*proto*/
644
+
645
+ /////////////// VoidPtrImport ///////////////
646
+ //@substitute: naming
647
+
648
+ #ifndef __PYX_HAVE_RT_ImportVoidPtr_$cyversion
649
+ #define __PYX_HAVE_RT_ImportVoidPtr_$cyversion
650
+ static int __Pyx_ImportVoidPtr_$cyversion(PyObject *module, const char *name, void **p, const char *sig) {
651
+ PyObject *d = 0;
652
+ PyObject *cobj = 0;
653
+
654
+ d = PyObject_GetAttrString(module, "$api_name");
655
+ if (!d)
656
+ goto bad;
657
+ cobj = PyDict_GetItemString(d, name);
658
+ if (!cobj) {
659
+ PyErr_Format(PyExc_ImportError,
660
+ "%.200s does not export expected C variable %.200s",
661
+ PyModule_GetName(module), name);
662
+ goto bad;
663
+ }
664
+ if (!PyCapsule_IsValid(cobj, sig)) {
665
+ PyErr_Format(PyExc_TypeError,
666
+ "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
667
+ PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
668
+ goto bad;
669
+ }
670
+ *p = PyCapsule_GetPointer(cobj, sig);
671
+ if (!(*p))
672
+ goto bad;
673
+ Py_DECREF(d);
674
+ return 0;
675
+ bad:
676
+ Py_XDECREF(d);
677
+ return -1;
678
+ }
679
+ #endif
680
+
681
+ /////////////// VoidPtrExport.proto ///////////////
682
+
683
+ static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig); /*proto*/
684
+
685
+ /////////////// VoidPtrExport ///////////////
686
+ //@substitute: naming
687
+ //@requires: ObjectHandling.c::PyObjectSetAttrStr
688
+
689
+ static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
690
+ PyObject *d;
691
+ PyObject *cobj = 0;
692
+
693
+ d = PyDict_GetItem(NAMED_CGLOBAL(moddict_cname), PYIDENT("$api_name"));
694
+ Py_XINCREF(d);
695
+ if (!d) {
696
+ d = PyDict_New();
697
+ if (!d)
698
+ goto bad;
699
+ if (__Pyx_PyObject_SetAttrStr($module_cname, PYIDENT("$api_name"), d) < 0)
700
+ goto bad;
701
+ }
702
+ cobj = PyCapsule_New(p, sig, 0);
703
+ if (!cobj)
704
+ goto bad;
705
+ if (PyDict_SetItem(d, name, cobj) < 0)
706
+ goto bad;
707
+ Py_DECREF(cobj);
708
+ Py_DECREF(d);
709
+ return 0;
710
+ bad:
711
+ Py_XDECREF(cobj);
712
+ Py_XDECREF(d);
713
+ return -1;
714
+ }
715
+
716
+
717
+ /////////////// SetVTable.proto ///////////////
718
+
719
+ static int __Pyx_SetVtable(PyTypeObject* typeptr , void* vtable); /*proto*/
720
+
721
+ /////////////// SetVTable ///////////////
722
+
723
+ static int __Pyx_SetVtable(PyTypeObject *type, void *vtable) {
724
+ PyObject *ob = PyCapsule_New(vtable, 0, 0);
725
+ if (unlikely(!ob))
726
+ goto bad;
727
+ #if CYTHON_COMPILING_IN_LIMITED_API
728
+ if (unlikely(PyObject_SetAttr((PyObject *) type, PYIDENT("__pyx_vtable__"), ob) < 0))
729
+ #else
730
+ if (unlikely(PyDict_SetItem(type->tp_dict, PYIDENT("__pyx_vtable__"), ob) < 0))
731
+ #endif
732
+ goto bad;
733
+ Py_DECREF(ob);
734
+ return 0;
735
+ bad:
736
+ Py_XDECREF(ob);
737
+ return -1;
738
+ }
739
+
740
+
741
+ /////////////// GetVTable.proto ///////////////
742
+
743
+ static void* __Pyx_GetVtable(PyTypeObject *type); /*proto*/
744
+
745
+ /////////////// GetVTable ///////////////
746
+
747
+ static void* __Pyx_GetVtable(PyTypeObject *type) {
748
+ void* ptr;
749
+ #if CYTHON_COMPILING_IN_LIMITED_API
750
+ PyObject *ob = PyObject_GetAttr((PyObject *)type, PYIDENT("__pyx_vtable__"));
751
+ #else
752
+ PyObject *ob = PyObject_GetItem(type->tp_dict, PYIDENT("__pyx_vtable__"));
753
+ #endif
754
+ if (!ob)
755
+ goto bad;
756
+ ptr = PyCapsule_GetPointer(ob, 0);
757
+ if (!ptr && !PyErr_Occurred())
758
+ PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
759
+ Py_DECREF(ob);
760
+ return ptr;
761
+ bad:
762
+ Py_XDECREF(ob);
763
+ return NULL;
764
+ }
765
+
766
+
767
+ /////////////// MergeVTables.proto ///////////////
768
+ //@requires: GetVTable
769
+
770
+ static int __Pyx_MergeVtables(PyTypeObject *type); /*proto*/
771
+
772
+ /////////////// MergeVTables ///////////////
773
+
774
+ static int __Pyx_MergeVtables(PyTypeObject *type) {
775
+ int i=0;
776
+ Py_ssize_t size;
777
+ void** base_vtables;
778
+ __Pyx_TypeName tp_base_name = NULL;
779
+ __Pyx_TypeName base_name = NULL;
780
+ void* unknown = (void*)-1;
781
+ PyObject* bases = __Pyx_PyType_GetSlot(type, tp_bases, PyObject*);
782
+ int base_depth = 0;
783
+ {
784
+ PyTypeObject* base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
785
+ while (base) {
786
+ base_depth += 1;
787
+ base = __Pyx_PyType_GetSlot(base, tp_base, PyTypeObject*);
788
+ }
789
+ }
790
+ base_vtables = (void**) PyMem_Malloc(sizeof(void*) * (size_t)(base_depth + 1));
791
+ base_vtables[0] = unknown;
792
+ // Could do MRO resolution of individual methods in the future, assuming
793
+ // compatible vtables, but for now simply require a common vtable base.
794
+ // Note that if the vtables of various bases are extended separately,
795
+ // resolution isn't possible and we must reject it just as when the
796
+ // instance struct is so extended. (It would be good to also do this
797
+ // check when a multiple-base class is created in pure Python as well.)
798
+ #if CYTHON_COMPILING_IN_LIMITED_API
799
+ size = PyTuple_Size(bases);
800
+ if (size < 0) goto other_failure;
801
+ #else
802
+ size = PyTuple_GET_SIZE(bases);
803
+ #endif
804
+ for (i = 1; i < size; i++) {
805
+ PyObject *basei;
806
+ void* base_vtable;
807
+ #if CYTHON_AVOID_BORROWED_REFS
808
+ basei = PySequence_GetItem(bases, i);
809
+ if (unlikely(!basei)) goto other_failure;
810
+ #elif !CYTHON_ASSUME_SAFE_MACROS
811
+ basei = PyTuple_GetItem(bases, i);
812
+ if (unlikely(!basei)) goto other_failure;
813
+ #else
814
+ basei = PyTuple_GET_ITEM(bases, i);
815
+ #endif
816
+ base_vtable = __Pyx_GetVtable((PyTypeObject*)basei);
817
+ #if CYTHON_AVOID_BORROWED_REFS
818
+ Py_DECREF(basei);
819
+ #endif
820
+ if (base_vtable != NULL) {
821
+ int j;
822
+ PyTypeObject* base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
823
+ for (j = 0; j < base_depth; j++) {
824
+ if (base_vtables[j] == unknown) {
825
+ base_vtables[j] = __Pyx_GetVtable(base);
826
+ base_vtables[j + 1] = unknown;
827
+ }
828
+ if (base_vtables[j] == base_vtable) {
829
+ break;
830
+ } else if (base_vtables[j] == NULL) {
831
+ // No more potential matching bases (with vtables).
832
+ goto bad;
833
+ }
834
+ base = __Pyx_PyType_GetSlot(base, tp_base, PyTypeObject*);
835
+ }
836
+ }
837
+ }
838
+ PyErr_Clear();
839
+ PyMem_Free(base_vtables);
840
+ return 0;
841
+ bad:
842
+ {
843
+ PyTypeObject* basei = NULL;
844
+ PyTypeObject* tp_base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
845
+ tp_base_name = __Pyx_PyType_GetName(tp_base);
846
+ #if CYTHON_AVOID_BORROWED_REFS
847
+ basei = (PyTypeObject*)PySequence_GetItem(bases, i);
848
+ if (unlikely(!basei)) goto really_bad;
849
+ #elif !CYTHON_ASSUME_SAFE_MACROS
850
+ basei = (PyTypeObject*)PyTuple_GetItem(bases, i);
851
+ if (unlikely(!basei)) goto really_bad;
852
+ #else
853
+ basei = (PyTypeObject*)PyTuple_GET_ITEM(bases, i);
854
+ #endif
855
+ base_name = __Pyx_PyType_GetName(basei);
856
+ #if CYTHON_AVOID_BORROWED_REFS
857
+ Py_DECREF(basei);
858
+ #endif
859
+ }
860
+ PyErr_Format(PyExc_TypeError,
861
+ "multiple bases have vtable conflict: '" __Pyx_FMT_TYPENAME "' and '" __Pyx_FMT_TYPENAME "'", tp_base_name, base_name);
862
+ #if CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS
863
+ really_bad: // bad has failed!
864
+ #endif
865
+ __Pyx_DECREF_TypeName(tp_base_name);
866
+ __Pyx_DECREF_TypeName(base_name);
867
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS
868
+ other_failure:
869
+ #endif
870
+ PyMem_Free(base_vtables);
871
+ return -1;
872
+ }
873
+
874
+
875
+ /////////////// ImportNumPyArray.proto ///////////////
876
+
877
+ static PyObject *__pyx_numpy_ndarray = NULL;
878
+
879
+ static PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void); /*proto*/
880
+
881
+ /////////////// ImportNumPyArray.cleanup ///////////////
882
+ Py_CLEAR(__pyx_numpy_ndarray);
883
+
884
+ /////////////// ImportNumPyArray ///////////////
885
+ //@requires: ImportExport.c::Import
886
+
887
+ static PyObject* __Pyx__ImportNumPyArray(void) {
888
+ PyObject *numpy_module, *ndarray_object = NULL;
889
+ numpy_module = __Pyx_Import(PYIDENT("numpy"), NULL, 0);
890
+ if (likely(numpy_module)) {
891
+ ndarray_object = PyObject_GetAttrString(numpy_module, "ndarray");
892
+ Py_DECREF(numpy_module);
893
+ }
894
+ if (unlikely(!ndarray_object)) {
895
+ // ImportError, AttributeError, ...
896
+ PyErr_Clear();
897
+ }
898
+ if (unlikely(!ndarray_object || !PyObject_TypeCheck(ndarray_object, &PyType_Type))) {
899
+ Py_XDECREF(ndarray_object);
900
+ Py_INCREF(Py_None);
901
+ ndarray_object = Py_None;
902
+ }
903
+ return ndarray_object;
904
+ }
905
+
906
+ static CYTHON_INLINE PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void) {
907
+ if (unlikely(!__pyx_numpy_ndarray)) {
908
+ __pyx_numpy_ndarray = __Pyx__ImportNumPyArray();
909
+ }
910
+ Py_INCREF(__pyx_numpy_ndarray);
911
+ return __pyx_numpy_ndarray;
912
+ }