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,1052 @@
1
+ //////////////////// ArgTypeTest.proto ////////////////////
2
+
3
+ // Exact is 0 (False), 1 (True) or 2 (True and from annotation)
4
+ // The latter gives a small amount of extra error diagnostics
5
+ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact); /*proto*/
6
+
7
+ //////////////////// ArgTypeTest ////////////////////
8
+ //@requires: ArgTypeTestError
9
+ //@requires: ModuleSetupCode.c::FastTypeChecks
10
+
11
+ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact) {
12
+ if (likely(Py_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None))))
13
+ return 1;
14
+ if (!exact && likely(type) && likely(__Pyx_TypeCheck(obj, type)))
15
+ return 1;
16
+ __Pyx_ArgTypeError(obj, type, name, exact);
17
+ return 0;
18
+ }
19
+
20
+
21
+ //////////////////// ArgTypeTestError.export ////////////////////
22
+ //@feature: DEFAULTS
23
+
24
+ static void __Pyx_ArgTypeError(PyObject *obj, PyTypeObject *type, const char *name, int exact); /*proto*/
25
+
26
+ //////////////////// ArgTypeTestError ////////////////////
27
+ //@requires: ModuleSetupCode.c::FastTypeChecks
28
+
29
+ static void __Pyx_ArgTypeError(PyObject *obj, PyTypeObject *type, const char *name, int exact)
30
+ {
31
+ __Pyx_TypeName type_name;
32
+ __Pyx_TypeName obj_type_name;
33
+ PyObject *extra_info = EMPTY(unicode);
34
+ int from_annotation_subclass = 0;
35
+ if (unlikely(!type)) {
36
+ PyErr_SetString(PyExc_SystemError, "Missing type object");
37
+ return;
38
+ } else if (exact == 2) {
39
+ // type from annotation
40
+ if (__Pyx_TypeCheck(obj, type)) {
41
+ from_annotation_subclass = 1;
42
+ extra_info = PYUNICODE("Note that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.");
43
+ }
44
+ }
45
+
46
+ type_name = __Pyx_PyType_GetFullyQualifiedName(type);
47
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
48
+ if (unlikely(!type_name)) return;
49
+ #endif
50
+ obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
51
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
52
+ if (unlikely(!obj_type_name)) goto obj_type_name_failed;
53
+ #endif
54
+
55
+ PyErr_Format(PyExc_TypeError,
56
+ "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME ", got " __Pyx_FMT_TYPENAME ")"
57
+ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
58
+ "%s%U"
59
+ #endif
60
+ , name, type_name, obj_type_name
61
+ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
62
+ , (from_annotation_subclass ? ". " : ""), extra_info
63
+ #endif
64
+ );
65
+
66
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
67
+ // Set the extra_info as a note instead. In principle it'd be possible to do this
68
+ // from Python 3.11 up, but PyErr_GetRaisedException makes it much easier so do it
69
+ // from Python 3.12 instead.
70
+ if (exact == 2 && from_annotation_subclass) {
71
+ PyObject *res;
72
+ PyObject *vargs[2];
73
+ vargs[0] = PyErr_GetRaisedException();
74
+ vargs[1] = extra_info;
75
+ res = PyObject_VectorcallMethod(PYUNICODE("add_note"), vargs, 2, NULL);
76
+ Py_XDECREF(res);
77
+ PyErr_SetRaisedException(vargs[0]);
78
+ }
79
+ #endif
80
+
81
+ __Pyx_DECREF_TypeName(obj_type_name);
82
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
83
+ obj_type_name_failed:
84
+ #endif
85
+ __Pyx_DECREF_TypeName(type_name);
86
+ return;
87
+ }
88
+
89
+
90
+ //////////////////// RaiseArgTupleInvalid.export ////////////////////
91
+ //@feature: DEFAULTS
92
+
93
+ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
94
+ Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
95
+
96
+ //////////////////// RaiseArgTupleInvalid ////////////////////
97
+
98
+ // __Pyx_RaiseArgtupleInvalid raises the correct exception when too
99
+ // many or too few positional arguments were found. This handles
100
+ // Py_ssize_t formatting correctly.
101
+
102
+ static void __Pyx_RaiseArgtupleInvalid(
103
+ const char* func_name,
104
+ int exact,
105
+ Py_ssize_t num_min,
106
+ Py_ssize_t num_max,
107
+ Py_ssize_t num_found)
108
+ {
109
+ Py_ssize_t num_expected;
110
+ const char *more_or_less;
111
+
112
+ if (num_found < num_min) {
113
+ num_expected = num_min;
114
+ more_or_less = "at least";
115
+ } else {
116
+ num_expected = num_max;
117
+ more_or_less = "at most";
118
+ }
119
+ if (exact) {
120
+ more_or_less = "exactly";
121
+ }
122
+ PyErr_Format(PyExc_TypeError,
123
+ "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
124
+ func_name, more_or_less, num_expected,
125
+ (num_expected == 1) ? "" : "s", num_found);
126
+ }
127
+
128
+
129
+ //////////////////// RaiseKeywordRequired.proto ////////////////////
130
+
131
+ static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name); /*proto*/
132
+
133
+ //////////////////// RaiseKeywordRequired ////////////////////
134
+
135
+ static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name) {
136
+ PyErr_Format(PyExc_TypeError,
137
+ "%s() needs keyword-only argument %U", func_name, kw_name);
138
+ }
139
+
140
+
141
+ //////////////////// RaiseDoubleKeywords.proto ////////////////////
142
+
143
+ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
144
+
145
+ //////////////////// RaiseDoubleKeywords ////////////////////
146
+
147
+ static void __Pyx_RaiseDoubleKeywordsError(
148
+ const char* func_name,
149
+ PyObject* kw_name)
150
+ {
151
+ PyErr_Format(PyExc_TypeError,
152
+ "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
153
+ }
154
+
155
+
156
+ //////////////////// RaiseMappingExpected.proto ////////////////////
157
+
158
+ static void __Pyx_RaiseMappingExpectedError(PyObject* arg); /*proto*/
159
+
160
+ //////////////////// RaiseMappingExpected ////////////////////
161
+ //@requires: ObjectHandling.c::RaiseErrorWithObjectType
162
+
163
+ static void __Pyx_RaiseMappingExpectedError(PyObject* arg) {
164
+ __Pyx_RaiseTypeErrorWithObjectType(
165
+ "'" __Pyx_FMT_TYPENAME "' object is not a mapping", arg);
166
+ }
167
+
168
+
169
+ //////////////////// KeywordStringCheck.proto ////////////////////
170
+
171
+ static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kw); /*proto*/
172
+
173
+ //////////////////// KeywordStringCheck ////////////////////
174
+
175
+ // __Pyx_CheckKeywordStrings raises an error if non-string keywords
176
+ // were passed to a function.
177
+ //
178
+ // The "kw" argument is either a dict (for METH_VARARGS) or a tuple
179
+ // (for METH_FASTCALL), both non-empty.
180
+
181
+ static int __Pyx_CheckKeywordStrings(PyObject *kw) {
182
+ // PyPy appears to check keyword types at call time, not at unpacking time.
183
+ #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x030C0000 && !defined(PyArg_ValidateKeywordArguments)
184
+ CYTHON_UNUSED_VAR(kw);
185
+ return 0;
186
+ #else
187
+
188
+ // Validate keyword types.
189
+ if (CYTHON_VECTORCALL && likely(PyTuple_Check(kw))) {
190
+ // On CPython >= 3.9, the FASTCALL protocol guarantees that keyword
191
+ // names are strings (see https://github.com/python/cpython/issues/81721)
192
+ } else {
193
+ // Otherwise, 'kw' is a dict: check if it's unicode-keys-only and let Python set the error otherwise.
194
+ if (unlikely(!PyArg_ValidateKeywordArguments(kw))) return -1;
195
+ }
196
+
197
+ return 0;
198
+ #endif
199
+ }
200
+
201
+
202
+ //////////////////// RejectKeywords.export ////////////////////
203
+ //@feature: DEFAULTS
204
+
205
+ static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds); /*proto*/
206
+
207
+ //////////////////// RejectKeywords ////////////////////
208
+ //@requires: ObjectHandling.c::OwnedDictNext
209
+
210
+ static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds) {
211
+ // Get the first keyword argument (there is at least one) and raise a TypeError for it.
212
+ PyObject *key = NULL;
213
+ if (CYTHON_VECTORCALL && likely(PyTuple_Check(kwds))) {
214
+ key = __Pyx_PySequence_ITEM(kwds, 0);
215
+ } else {
216
+ #if CYTHON_AVOID_BORROWED_REFS
217
+ PyObject *pos = NULL;
218
+ #else
219
+ Py_ssize_t pos = 0;
220
+ #endif
221
+ #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
222
+ // Check if dict is unicode-keys-only and let Python set the error otherwise.
223
+ if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return;
224
+ #endif
225
+ // Read first key.
226
+ __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL);
227
+ #if CYTHON_AVOID_BORROWED_REFS
228
+ Py_XDECREF(pos);
229
+ #endif
230
+ }
231
+
232
+ if (likely(key)) {
233
+ PyErr_Format(PyExc_TypeError,
234
+ "%s() got an unexpected keyword argument '%U'",
235
+ function_name, key);
236
+ Py_DECREF(key);
237
+ }
238
+ }
239
+
240
+
241
+ //////////////////// ParseKeywords.proto ////////////////////
242
+ //@requires: ParseKeywordsImpl
243
+
244
+ static CYTHON_INLINE int __Pyx_ParseKeywords(
245
+ PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[],
246
+ PyObject *kwds2, PyObject *values[],
247
+ Py_ssize_t num_pos_args, Py_ssize_t num_kwargs,
248
+ const char* function_name,
249
+ int ignore_unknown_kwargs
250
+ ); /*proto*/
251
+
252
+ //////////////////// ParseKeywords ////////////////////
253
+ // __Pyx_ParseOptionalKeywords copies the optional/unknown keyword
254
+ // arguments from kwds into the dict kwds2. If kwds2 is NULL, unknown
255
+ // keywords will raise an invalid keyword error.
256
+ //
257
+ // When not using METH_FASTCALL, kwds is a dict and kwvalues is NULL.
258
+ // Otherwise, kwds is a tuple with keyword names and kwvalues is a C
259
+ // array with the corresponding values.
260
+ //
261
+ // Three kinds of errors are checked: 1) non-string keywords, 2)
262
+ // unexpected keywords and 3) overlap with positional arguments.
263
+ //
264
+ // If num_posargs is greater 0, it denotes the number of positional
265
+ // arguments that were passed and that must therefore not appear
266
+ // amongst the keywords as well.
267
+ //
268
+ // This method does not check for required keyword arguments.
269
+
270
+ static int __Pyx_ParseKeywords(
271
+ PyObject *kwds,
272
+ PyObject * const *kwvalues,
273
+ PyObject ** const argnames[],
274
+ PyObject *kwds2,
275
+ PyObject *values[],
276
+ Py_ssize_t num_pos_args,
277
+ Py_ssize_t num_kwargs,
278
+ const char* function_name,
279
+ int ignore_unknown_kwargs)
280
+ {
281
+ // Only called if kwds contains at least one optional keyword argument.
282
+ if (CYTHON_VECTORCALL && likely(PyTuple_Check(kwds)))
283
+ return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
284
+ else if (kwds2)
285
+ return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name);
286
+ else
287
+ return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
288
+ }
289
+
290
+
291
+ //////////////////// ParseKeywordsImpl.export ////////////////////
292
+ //@feature: DEFAULTS
293
+ //@requires: RaiseDoubleKeywords
294
+ //@requires: Synchronization.c::CriticalSections
295
+ //@requires: ObjectHandling.c::OwnedDictNext
296
+
297
+
298
+ static int __Pyx_ParseKeywordsTuple(
299
+ PyObject *kwds,
300
+ PyObject * const *kwvalues,
301
+ PyObject ** const argnames[],
302
+ PyObject *kwds2,
303
+ PyObject *values[],
304
+ Py_ssize_t num_pos_args,
305
+ Py_ssize_t num_kwargs,
306
+ const char* function_name,
307
+ int ignore_unknown_kwargs
308
+ );
309
+
310
+ static int __Pyx_ParseKeywordDictToDict(
311
+ PyObject *kwds,
312
+ PyObject ** const argnames[],
313
+ PyObject *kwds2,
314
+ PyObject *values[],
315
+ Py_ssize_t num_pos_args,
316
+ const char* function_name
317
+ );
318
+
319
+ static int __Pyx_ParseKeywordDict(
320
+ PyObject *kwds,
321
+ PyObject ** const argnames[],
322
+ PyObject *values[],
323
+ Py_ssize_t num_pos_args,
324
+ Py_ssize_t num_kwargs,
325
+ const char* function_name,
326
+ int ignore_unknown_kwargs
327
+ );
328
+
329
+ //////////////////// ParseKeywordsImpl ////////////////////
330
+
331
+ static int __Pyx_ValidateDuplicatePosArgs(
332
+ PyObject *kwds,
333
+ PyObject ** const argnames[],
334
+ PyObject ** const *first_kw_arg,
335
+ const char* function_name)
336
+ {
337
+ PyObject ** const *name = argnames;
338
+ while (name != first_kw_arg) {
339
+ PyObject *key = **name;
340
+ int found = PyDict_Contains(kwds, key);
341
+ if (unlikely(found)) {
342
+ if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key);
343
+ goto bad;
344
+ }
345
+ name++;
346
+ }
347
+ return 0;
348
+
349
+ bad:
350
+ return -1;
351
+ }
352
+
353
+ #if CYTHON_USE_UNICODE_INTERNALS
354
+ static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) {
355
+ int kind;
356
+ Py_ssize_t len = PyUnicode_GET_LENGTH(s1);
357
+ if (len != PyUnicode_GET_LENGTH(s2)) return 0;
358
+
359
+ kind = PyUnicode_KIND(s1);
360
+ if (kind != PyUnicode_KIND(s2)) return 0;
361
+
362
+ const void *data1 = PyUnicode_DATA(s1);
363
+ const void *data2 = PyUnicode_DATA(s2);
364
+ return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0);
365
+ }
366
+ #endif
367
+
368
+ static int __Pyx_MatchKeywordArg_str(
369
+ PyObject *key,
370
+ PyObject ** const argnames[],
371
+ PyObject ** const *first_kw_arg,
372
+ size_t *index_found,
373
+ const char *function_name)
374
+ {
375
+ PyObject ** const *name;
376
+ #if CYTHON_USE_UNICODE_INTERNALS
377
+ // The key hash is probably pre-calculated.
378
+ Py_hash_t key_hash = ((PyASCIIObject*)key)->hash;
379
+ if (unlikely(key_hash == -1)) {
380
+ key_hash = PyObject_Hash(key);
381
+ if (unlikely(key_hash == -1))
382
+ goto bad;
383
+ }
384
+ #endif
385
+
386
+ // Compare strings for non-interned matches.
387
+ name = first_kw_arg;
388
+ while (*name) {
389
+ PyObject *name_str = **name;
390
+
391
+ #if CYTHON_USE_UNICODE_INTERNALS
392
+ // The hash value of our interned argument name is definitely pre-calculated.
393
+ if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) {
394
+ *index_found = (size_t) (name - argnames);
395
+ return 1;
396
+ }
397
+ #else
398
+
399
+ #if CYTHON_ASSUME_SAFE_SIZE
400
+ if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
401
+ #endif
402
+ {
403
+ int cmp = PyUnicode_Compare(name_str, key);
404
+ if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
405
+ if (cmp == 0) {
406
+ *index_found = (size_t) (name - argnames);
407
+ return 1;
408
+ }
409
+ }
410
+ #endif
411
+ name++;
412
+ }
413
+
414
+ // Not found in keyword parameters, check for (unlikely) duplicate positional argument.
415
+ name = argnames;
416
+ while (name != first_kw_arg) {
417
+ PyObject *name_str = **name;
418
+
419
+ #if CYTHON_USE_UNICODE_INTERNALS
420
+ if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) {
421
+ if (__Pyx_UnicodeKeywordsEqual(name_str, key))
422
+ goto arg_passed_twice;
423
+ }
424
+
425
+ #else
426
+
427
+ #if CYTHON_ASSUME_SAFE_SIZE
428
+ if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
429
+ #endif
430
+ {
431
+ if (unlikely(name_str == key)) goto arg_passed_twice;
432
+ int cmp = PyUnicode_Compare(name_str, key);
433
+ if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
434
+ if (cmp == 0) goto arg_passed_twice;
435
+ }
436
+
437
+ #endif
438
+ name++;
439
+ }
440
+
441
+ return 0;
442
+
443
+ arg_passed_twice:
444
+ __Pyx_RaiseDoubleKeywordsError(function_name, key);
445
+ goto bad;
446
+ bad:
447
+ return -1;
448
+ }
449
+
450
+ static int __Pyx_MatchKeywordArg_nostr(
451
+ PyObject *key,
452
+ PyObject ** const argnames[],
453
+ PyObject ** const *first_kw_arg,
454
+ size_t *index_found,
455
+ const char *function_name)
456
+ {
457
+ // Conservatively handle str subclasses.
458
+ PyObject ** const *name;
459
+
460
+ if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type;
461
+
462
+ // Match keyword argument names.
463
+ name = first_kw_arg;
464
+ while (*name) {
465
+ int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
466
+ if (cmp == 1) {
467
+ *index_found = (size_t) (name - argnames);
468
+ return 1;
469
+ }
470
+ if (unlikely(cmp == -1)) goto bad;
471
+ name++;
472
+ }
473
+ // Reject collisions with positional arguments.
474
+ name = argnames;
475
+ while (name != first_kw_arg) {
476
+ int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
477
+ if (unlikely(cmp != 0)) {
478
+ if (cmp == 1) goto arg_passed_twice;
479
+ else goto bad;
480
+ }
481
+ name++;
482
+ }
483
+ return 0;
484
+
485
+ arg_passed_twice:
486
+ __Pyx_RaiseDoubleKeywordsError(function_name, key);
487
+ goto bad;
488
+ invalid_keyword_type:
489
+ PyErr_Format(PyExc_TypeError,
490
+ "%.200s() keywords must be strings", function_name);
491
+ goto bad;
492
+ bad:
493
+ return -1;
494
+ }
495
+
496
+ static CYTHON_INLINE int __Pyx_MatchKeywordArg(
497
+ PyObject *key,
498
+ PyObject ** const argnames[],
499
+ PyObject ** const *first_kw_arg,
500
+ size_t *index_found,
501
+ const char *function_name)
502
+ {
503
+ // Optimise for plain str behaviour.
504
+ return likely(PyUnicode_CheckExact(key)) ?
505
+ __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) :
506
+ __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name);
507
+ }
508
+
509
+ static void __Pyx_RejectUnknownKeyword(
510
+ PyObject *kwds,
511
+ PyObject ** const argnames[],
512
+ PyObject ** const *first_kw_arg,
513
+ const char *function_name)
514
+ {
515
+ // Find the first unknown keyword and raise an error. There must be at least one.
516
+ #if CYTHON_AVOID_BORROWED_REFS
517
+ PyObject *pos = NULL;
518
+ #else
519
+ Py_ssize_t pos = 0;
520
+ #endif
521
+
522
+ PyObject *key = NULL;
523
+
524
+ __Pyx_BEGIN_CRITICAL_SECTION(kwds);
525
+ #if CYTHON_AVOID_BORROWED_REFS
526
+ while (__Pyx_PyDict_NextRef(kwds, &pos, &key, NULL))
527
+ #else
528
+ (void) &__Pyx_PyDict_NextRef;
529
+ while (PyDict_Next(kwds, &pos, &key, NULL))
530
+ #endif
531
+ {
532
+ // Quickly exclude the 'obviously' valid/known keyword arguments (exact pointer match).
533
+ PyObject** const *name = first_kw_arg;
534
+ while (*name && (**name != key)) name++;
535
+
536
+ if (!*name) {
537
+ // No exact match found:
538
+ // compare against positional (always reject) and keyword (reject unknown) names.
539
+
540
+ size_t index_found = 0;
541
+ int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
542
+ if (cmp != 1) {
543
+ if (cmp == 0) {
544
+ PyErr_Format(PyExc_TypeError,
545
+ "%s() got an unexpected keyword argument '%U'",
546
+ function_name, key);
547
+ }
548
+ #if CYTHON_AVOID_BORROWED_REFS
549
+ Py_DECREF(key);
550
+ #endif
551
+
552
+ break;
553
+ }
554
+ }
555
+ #if CYTHON_AVOID_BORROWED_REFS
556
+ Py_DECREF(key);
557
+ #endif
558
+ }
559
+ __Pyx_END_CRITICAL_SECTION();
560
+ #if CYTHON_AVOID_BORROWED_REFS
561
+ Py_XDECREF(pos);
562
+ #endif
563
+
564
+ assert(PyErr_Occurred());
565
+ }
566
+
567
+ static int __Pyx_ParseKeywordDict(
568
+ PyObject *kwds,
569
+ PyObject ** const argnames[],
570
+ PyObject *values[],
571
+ Py_ssize_t num_pos_args,
572
+ Py_ssize_t num_kwargs,
573
+ const char* function_name,
574
+ int ignore_unknown_kwargs)
575
+ {
576
+ PyObject** const *name;
577
+ PyObject** const *first_kw_arg = argnames + num_pos_args;
578
+ Py_ssize_t extracted = 0;
579
+
580
+ #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
581
+ // Check if dict is unicode-keys-only and let Python set the error otherwise.
582
+ if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
583
+ #endif
584
+
585
+ // Extract declared keyword arguments.
586
+ name = first_kw_arg;
587
+ while (*name && num_kwargs > extracted) {
588
+ PyObject * key = **name;
589
+ PyObject *value;
590
+ int found = 0;
591
+
592
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
593
+ found = PyDict_GetItemRef(kwds, key, &value);
594
+ #else
595
+ value = PyDict_GetItemWithError(kwds, key);
596
+ if (value) {
597
+ Py_INCREF(value);
598
+ found = 1;
599
+ } else {
600
+ if (unlikely(PyErr_Occurred())) goto bad;
601
+ }
602
+ #endif
603
+
604
+ if (found) {
605
+ if (unlikely(found < 0)) goto bad;
606
+ values[name-argnames] = value;
607
+ extracted++;
608
+ }
609
+
610
+ name++;
611
+ }
612
+
613
+ if (num_kwargs > extracted) {
614
+ if (ignore_unknown_kwargs) {
615
+ // Make sure the remaining kwargs are not duplicate posargs.
616
+ if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1))
617
+ goto bad;
618
+ } else {
619
+ // Any remaining kwarg is an error.
620
+ __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name);
621
+ goto bad;
622
+ }
623
+ }
624
+ return 0;
625
+
626
+ bad:
627
+ return -1;
628
+ }
629
+
630
+ static int __Pyx_ParseKeywordDictToDict(
631
+ PyObject *kwds,
632
+ PyObject ** const argnames[],
633
+ PyObject *kwds2,
634
+ PyObject *values[],
635
+ Py_ssize_t num_pos_args,
636
+ const char* function_name)
637
+ {
638
+ // Validate and parse keyword arguments from kwds dict.
639
+ PyObject** const *name;
640
+ PyObject** const *first_kw_arg = argnames + num_pos_args;
641
+ Py_ssize_t len;
642
+
643
+ #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
644
+ // Check if dict is unicode-keys-only and let Python set the error otherwise.
645
+ if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
646
+ #endif
647
+
648
+ // Fast copy of all kwargs.
649
+ if (PyDict_Update(kwds2, kwds) < 0) goto bad;
650
+
651
+ // Extract declared keyword arguments (if any).
652
+ name = first_kw_arg;
653
+ while (*name) {
654
+ PyObject *key = **name;
655
+ PyObject *value;
656
+
657
+ #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop))
658
+ int found = PyDict_Pop(kwds2, key, &value);
659
+ if (found) {
660
+ if (unlikely(found < 0)) goto bad;
661
+ values[name-argnames] = value;
662
+ }
663
+ #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
664
+ int found = PyDict_GetItemRef(kwds2, key, &value);
665
+ if (found) {
666
+ if (unlikely(found < 0)) goto bad;
667
+ values[name-argnames] = value;
668
+ if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad;
669
+ }
670
+ #else
671
+ // We use 'kwds2' as sentinel value to dict.pop() to avoid an exception on missing key.
672
+ #if CYTHON_COMPILING_IN_CPYTHON
673
+ value = _PyDict_Pop(kwds2, key, kwds2);
674
+ #else
675
+ value = CALL_UNBOUND_METHOD(PyDict_Type, "pop", kwds2, key, kwds2);
676
+ #endif
677
+ if (value == kwds2) {
678
+ // Not found.
679
+ Py_DECREF(value);
680
+ } else {
681
+ if (unlikely(!value)) goto bad;
682
+ values[name-argnames] = value;
683
+ }
684
+ #endif
685
+ name++;
686
+ }
687
+
688
+ // If unmatched keywords remain, check for duplicates of positional arguments.
689
+ len = PyDict_Size(kwds2);
690
+ if (len > 0) {
691
+ return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name);
692
+ } else if (unlikely(len == -1)) {
693
+ goto bad;
694
+ }
695
+
696
+ return 0;
697
+
698
+ bad:
699
+ return -1;
700
+ }
701
+
702
+ static int __Pyx_ParseKeywordsTuple(
703
+ PyObject *kwds,
704
+ PyObject * const *kwvalues,
705
+ PyObject ** const argnames[],
706
+ PyObject *kwds2,
707
+ PyObject *values[],
708
+ Py_ssize_t num_pos_args,
709
+ Py_ssize_t num_kwargs,
710
+ const char* function_name,
711
+ int ignore_unknown_kwargs)
712
+ {
713
+ PyObject *key = NULL;
714
+ PyObject** const * name;
715
+ PyObject** const *first_kw_arg = argnames + num_pos_args;
716
+
717
+ for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
718
+ #if CYTHON_AVOID_BORROWED_REFS
719
+ key = __Pyx_PySequence_ITEM(kwds, pos);
720
+ #else
721
+ key = __Pyx_PyTuple_GET_ITEM(kwds, pos);
722
+ #endif
723
+ #if !CYTHON_ASSUME_SAFE_MACROS
724
+ if (unlikely(!key)) goto bad;
725
+ #endif
726
+
727
+ // Quick pointer search for interned parameter matches (will usually succeed).
728
+ name = first_kw_arg;
729
+ while (*name && (**name != key)) name++;
730
+ if (*name) {
731
+ // Declared keyword: **name == key
732
+ PyObject *value = kwvalues[pos];
733
+ values[name-argnames] = __Pyx_NewRef(value);
734
+ } else {
735
+ size_t index_found = 0;
736
+ int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
737
+
738
+ if (cmp == 1) {
739
+ // Found in declared keywords => assign value.
740
+ PyObject *value = kwvalues[pos];
741
+ values[index_found] = __Pyx_NewRef(value);
742
+ } else {
743
+ if (unlikely(cmp == -1)) goto bad;
744
+ if (kwds2) {
745
+ PyObject *value = kwvalues[pos];
746
+ if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
747
+ } else if (!ignore_unknown_kwargs) {
748
+ goto invalid_keyword;
749
+ }
750
+ }
751
+ }
752
+
753
+ #if CYTHON_AVOID_BORROWED_REFS
754
+ Py_DECREF(key);
755
+ key = NULL;
756
+ #endif
757
+ }
758
+ return 0;
759
+
760
+ invalid_keyword:
761
+ PyErr_Format(PyExc_TypeError,
762
+ "%s() got an unexpected keyword argument '%U'",
763
+ function_name, key);
764
+ goto bad;
765
+ bad:
766
+ #if CYTHON_AVOID_BORROWED_REFS
767
+ Py_XDECREF(key);
768
+ #endif
769
+ return -1;
770
+ }
771
+
772
+
773
+ //////////////////// MergeKeywords.proto ////////////////////
774
+
775
+ static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping); /*proto*/
776
+
777
+ //////////////////// MergeKeywords ////////////////////
778
+ //@requires: RaiseDoubleKeywords
779
+ //@requires: Optimize.c::dict_iter
780
+ //@requires: ObjectHandling.c::OwnedDictNext
781
+ //@requires: Synchronization.c::CriticalSections
782
+ //@requires: Builtins.c::PyFrozenDict
783
+
784
+ static int __Pyx_MergeKeywords_dict(PyObject *kwdict, PyObject *source_dict) {
785
+ Py_ssize_t len1, len2;
786
+
787
+ len2 = PyDict_Size(source_dict);
788
+ if (unlikely(len2 == -1)) return -1;
789
+ if (len2 == 0) {
790
+ // There's nothing to copy from an empty dict.
791
+ return 0;
792
+ }
793
+
794
+ len1 = PyDict_Size(kwdict);
795
+ if (unlikely(len1 == -1)) return -1;
796
+
797
+ if (len1 > 0) {
798
+ PyObject *key, *smaller_dict, *larger_dict;
799
+ #if CYTHON_AVOID_BORROWED_REFS
800
+ PyObject *ppos = NULL;
801
+ #else
802
+ Py_ssize_t ppos = 0;
803
+ #endif
804
+ int duplicates_found = 0;
805
+
806
+ if (len1 <= len2) {
807
+ smaller_dict = kwdict;
808
+ larger_dict = source_dict;
809
+ } else {
810
+ smaller_dict = source_dict;
811
+ larger_dict = kwdict;
812
+ }
813
+
814
+ __Pyx_BEGIN_CRITICAL_SECTION(smaller_dict);
815
+ #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
816
+ while (__Pyx_PyDict_NextRef(smaller_dict, &ppos, &key, NULL))
817
+ #else
818
+ (void) &__Pyx_PyDict_NextRef;
819
+ while (PyDict_Next(smaller_dict, &ppos, &key, NULL))
820
+ #endif
821
+ {
822
+ if (unlikely(PyDict_Contains(larger_dict, key))) {
823
+ __Pyx_RaiseDoubleKeywordsError("function", key);
824
+ #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
825
+ Py_DECREF(key);
826
+ #endif
827
+ duplicates_found = 1;
828
+ break;
829
+ };
830
+ #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
831
+ Py_DECREF(key);
832
+ #endif
833
+ }
834
+ __Pyx_END_CRITICAL_SECTION();
835
+ #if CYTHON_AVOID_BORROWED_REFS
836
+ Py_XDECREF(ppos);
837
+ #endif
838
+
839
+ if (unlikely(duplicates_found))
840
+ return -1;
841
+ }
842
+
843
+ return PyDict_Update(kwdict, source_dict);
844
+ }
845
+
846
+ static int __Pyx_MergeKeywords_any(PyObject *kwdict, PyObject *source_mapping) {
847
+ PyObject *iter, *key = NULL, *value = NULL;
848
+ int source_is_dict, result;
849
+ Py_ssize_t orig_length, ppos = 0;
850
+
851
+ iter = __Pyx_dict_iterator(source_mapping, 0, PYIDENT("items"), &orig_length, &source_is_dict);
852
+ if (unlikely(!iter)) {
853
+ // slow fallback: try converting to dict, then iterate
854
+ PyObject *args;
855
+ if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) goto bad;
856
+ PyErr_Clear();
857
+ args = PyTuple_Pack(1, source_mapping);
858
+ if (likely(args)) {
859
+ PyObject *fallback = PyObject_Call((PyObject*)&PyDict_Type, args, NULL);
860
+ Py_DECREF(args);
861
+ if (likely(fallback)) {
862
+ result = __Pyx_MergeKeywords_dict(kwdict, fallback);
863
+ Py_DECREF(fallback);
864
+ return result;
865
+ }
866
+ }
867
+ goto bad;
868
+ }
869
+
870
+ while (1) {
871
+ result = __Pyx_dict_iter_next(iter, orig_length, &ppos, &key, &value, NULL, source_is_dict);
872
+ if (unlikely(result < 0)) goto bad;
873
+ if (!result) break;
874
+
875
+ #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
876
+ {
877
+ int inserted = PyDict_SetDefaultRef(kwdict, key, value, NULL);
878
+ if (unlikely(inserted != 0)) {
879
+ if (inserted == 1) __Pyx_RaiseDoubleKeywordsError("function", key);
880
+ result = -1;
881
+ }
882
+ }
883
+ #else
884
+ if (unlikely(PyDict_Contains(kwdict, key))) {
885
+ __Pyx_RaiseDoubleKeywordsError("function", key);
886
+ result = -1;
887
+ } else {
888
+ result = PyDict_SetItem(kwdict, key, value);
889
+ }
890
+ #endif
891
+
892
+ Py_DECREF(key);
893
+ Py_DECREF(value);
894
+ if (unlikely(result < 0)) goto bad;
895
+ }
896
+ Py_XDECREF(iter);
897
+ return 0;
898
+
899
+ bad:
900
+ Py_XDECREF(iter);
901
+ return -1;
902
+ }
903
+
904
+ static CYTHON_INLINE int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) {
905
+ assert(PyDict_Check(kwdict));
906
+ if (likely(__Pyx_PyAnyDict_Check(source_mapping))) {
907
+ return __Pyx_MergeKeywords_dict(kwdict, source_mapping);
908
+ } else {
909
+ return __Pyx_MergeKeywords_any(kwdict, source_mapping);
910
+ }
911
+ }
912
+
913
+
914
+ /////////////// fastcall.proto ///////////////
915
+
916
+ // We define various functions and macros with two variants:
917
+ //..._FASTCALL and ..._VARARGS
918
+
919
+ // The first is used when METH_FASTCALL is enabled and the second is used
920
+ // otherwise. If the Python implementation does not support METH_FASTCALL
921
+ // (because it's an old version of CPython or it's not CPython at all),
922
+ // then the ..._FASTCALL macros simply alias ..._VARARGS
923
+
924
+ #if CYTHON_AVOID_BORROWED_REFS
925
+ #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i)
926
+ #elif CYTHON_ASSUME_SAFE_MACROS
927
+ #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i))
928
+ #else
929
+ #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i))
930
+ #endif
931
+
932
+ #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
933
+ #define __Pyx_KwValues_VARARGS(args, nargs) NULL
934
+ #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
935
+ #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
936
+ #if CYTHON_VECTORCALL
937
+ #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i])
938
+ #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds)
939
+ #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
940
+ static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
941
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_GRAAL
942
+ CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);/*proto*/
943
+ #else
944
+ #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
945
+ #endif
946
+ #else
947
+ #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS
948
+ #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
949
+ #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
950
+ #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
951
+ #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
952
+ #endif
953
+ #if CYTHON_VECTORCALL_TPNEW
954
+ #if !CYTHON_VECTORCALL
955
+ #error Enabling CYTHON_VECTORCALL_TPNEW without CYTHON_VECTORCALL is not supported
956
+ #endif
957
+ #define __Pyx_ArgRef_FASTCALL_TPNEW __Pyx_ArgRef_FASTCALL
958
+ #define __Pyx_NumKwargs_FASTCALL_TPNEW __Pyx_NumKwargs_FASTCALL
959
+ #define __Pyx_KwValues_FASTCALL_TPNEW __Pyx_KwValues_FASTCALL
960
+ #define __Pyx_GetKwValue_FASTCALL_TPNEW __Pyx_GetKwValue_FASTCALL
961
+ #define __Pyx_KwargsAsDict_FASTCALL_TPNEW __Pyx_KwargsAsDict_FASTCALL
962
+ #else
963
+ #define __Pyx_ArgRef_FASTCALL_TPNEW __Pyx_ArgRef_VARARGS
964
+ #define __Pyx_NumKwargs_FASTCALL_TPNEW __Pyx_NumKwargs_VARARGS
965
+ #define __Pyx_KwValues_FASTCALL_TPNEW __Pyx_KwValues_VARARGS
966
+ #define __Pyx_GetKwValue_FASTCALL_TPNEW __Pyx_GetKwValue_VARARGS
967
+ #define __Pyx_KwargsAsDict_FASTCALL_TPNEW __Pyx_KwargsAsDict_VARARGS
968
+ #endif
969
+
970
+ #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
971
+
972
+ #if CYTHON_VECTORCALL
973
+ #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start)
974
+ #else
975
+ #define __Pyx_ArgsSlice_FASTCALL __Pyx_ArgsSlice_VARARGS
976
+ #endif
977
+
978
+ /////////////// fastcall ///////////////
979
+ //@requires: ObjectHandling.c::TupleFromArray
980
+ //@requires: Optimize.c::UnicodeEquals
981
+
982
+ #if CYTHON_VECTORCALL
983
+ // kwnames: tuple with names of keyword arguments
984
+ // kwvalues: C array with values of keyword arguments
985
+ // s: str with the keyword name to look for
986
+ static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
987
+ {
988
+ // Search the kwnames array for s and return the corresponding value.
989
+ // We do two loops: a first one to compare pointers (which will find a
990
+ // match if the name in kwnames is interned, given that s is interned
991
+ // by Cython). A second loop compares the actual strings.
992
+ Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames);
993
+ #if !CYTHON_ASSUME_SAFE_SIZE
994
+ if (unlikely(n == -1)) return NULL;
995
+ #endif
996
+ for (i = 0; i < n; i++)
997
+ {
998
+ PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
999
+ #if !CYTHON_ASSUME_SAFE_MACROS
1000
+ if (unlikely(!namei)) return NULL;
1001
+ #endif
1002
+ if (s == namei) return kwvalues[i];
1003
+ }
1004
+ for (i = 0; i < n; i++)
1005
+ {
1006
+ PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
1007
+ #if !CYTHON_ASSUME_SAFE_MACROS
1008
+ if (unlikely(!namei)) return NULL;
1009
+ #endif
1010
+ int eq = __Pyx_PyUnicode_Equals(s, namei);
1011
+ if (unlikely(eq != 0)) {
1012
+ if (unlikely(eq < 0)) return NULL; /* error */
1013
+ return kwvalues[i];
1014
+ }
1015
+ }
1016
+ return NULL; /* not found (no exception set) */
1017
+ }
1018
+
1019
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_GRAAL
1020
+ CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
1021
+ Py_ssize_t i, nkwargs;
1022
+ PyObject *dict;
1023
+ #if !CYTHON_ASSUME_SAFE_SIZE
1024
+ nkwargs = PyTuple_Size(kwnames);
1025
+ if (unlikely(nkwargs < 0)) return NULL;
1026
+ #else
1027
+ nkwargs = PyTuple_GET_SIZE(kwnames);
1028
+ #endif
1029
+
1030
+ dict = PyDict_New();
1031
+ if (unlikely(!dict))
1032
+ return NULL;
1033
+
1034
+ for (i=0; i<nkwargs; i++) {
1035
+ #if !CYTHON_ASSUME_SAFE_MACROS
1036
+ PyObject *key = PyTuple_GetItem(kwnames, i);
1037
+ if (!key) goto bad;
1038
+ #else
1039
+ PyObject *key = PyTuple_GET_ITEM(kwnames, i);
1040
+ #endif
1041
+ if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
1042
+ goto bad;
1043
+ }
1044
+ return dict;
1045
+
1046
+ bad:
1047
+ Py_DECREF(dict);
1048
+ return NULL;
1049
+ }
1050
+ #endif
1051
+
1052
+ #endif