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.
- Cython/Build/BuildExecutable.py +156 -0
- Cython/Build/Cache.py +198 -0
- Cython/Build/Cythonize.py +349 -0
- Cython/Build/Dependencies.py +1320 -0
- Cython/Build/Distutils.py +1 -0
- Cython/Build/Inline.py +467 -0
- Cython/Build/IpythonMagic.py +559 -0
- Cython/Build/SharedModule.py +165 -0
- Cython/Build/Tests/TestCyCache.py +222 -0
- Cython/Build/Tests/TestCythonizeArgsParser.py +480 -0
- Cython/Build/Tests/TestDependencies.py +133 -0
- Cython/Build/Tests/TestInline.py +177 -0
- Cython/Build/Tests/TestIpythonMagic.py +303 -0
- Cython/Build/Tests/TestRecythonize.py +212 -0
- Cython/Build/Tests/TestStripLiterals.py +155 -0
- Cython/Build/Tests/__init__.py +1 -0
- Cython/Build/__init__.py +11 -0
- Cython/CodeWriter.py +825 -0
- Cython/Compiler/AnalysedTreeTransforms.py +97 -0
- Cython/Compiler/Annotate.py +328 -0
- Cython/Compiler/AutoDocTransforms.py +320 -0
- Cython/Compiler/Buffer.py +679 -0
- Cython/Compiler/Builtin.py +1102 -0
- Cython/Compiler/CmdLine.py +373 -0
- Cython/Compiler/Code.pxd +154 -0
- Cython/Compiler/Code.py +3760 -0
- Cython/Compiler/CodeGeneration.py +33 -0
- Cython/Compiler/CythonScope.py +208 -0
- Cython/Compiler/Dataclass.py +890 -0
- Cython/Compiler/DebugFlags.py +24 -0
- Cython/Compiler/Errors.py +310 -0
- Cython/Compiler/ExprNodes.py +16319 -0
- Cython/Compiler/FlowControl.pxd +112 -0
- Cython/Compiler/FlowControl.py +1575 -0
- Cython/Compiler/FusedNode.py +978 -0
- Cython/Compiler/Future.py +16 -0
- Cython/Compiler/Interpreter.py +57 -0
- Cython/Compiler/Lexicon.py +442 -0
- Cython/Compiler/LineTable.py +114 -0
- Cython/Compiler/Main.py +879 -0
- Cython/Compiler/MatchCaseNodes.py +2200 -0
- Cython/Compiler/MemoryView.py +930 -0
- Cython/Compiler/ModuleNode.py +4558 -0
- Cython/Compiler/Naming.py +370 -0
- Cython/Compiler/Nodes.py +11334 -0
- Cython/Compiler/Optimize.py +5563 -0
- Cython/Compiler/Options.py +841 -0
- Cython/Compiler/ParseTreeTransforms.pxd +80 -0
- Cython/Compiler/ParseTreeTransforms.py +4808 -0
- Cython/Compiler/Parsing.pxd +9 -0
- Cython/Compiler/Parsing.py +5442 -0
- Cython/Compiler/Pipeline.py +439 -0
- Cython/Compiler/PyrexTypes.py +6588 -0
- Cython/Compiler/Pythran.py +232 -0
- Cython/Compiler/Scanning.pxd +74 -0
- Cython/Compiler/Scanning.py +771 -0
- Cython/Compiler/StringEncoding.py +354 -0
- Cython/Compiler/Symtab.py +3122 -0
- Cython/Compiler/Tests/TestBuffer.py +105 -0
- Cython/Compiler/Tests/TestBuiltin.py +196 -0
- Cython/Compiler/Tests/TestCmdLine.py +652 -0
- Cython/Compiler/Tests/TestCode.py +145 -0
- Cython/Compiler/Tests/TestFlowControl.py +65 -0
- Cython/Compiler/Tests/TestGrammar.py +202 -0
- Cython/Compiler/Tests/TestMemView.py +71 -0
- Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
- Cython/Compiler/Tests/TestScanning.py +132 -0
- Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
- Cython/Compiler/Tests/TestStringEncoding.py +20 -0
- Cython/Compiler/Tests/TestTreeFragment.py +63 -0
- Cython/Compiler/Tests/TestTreePath.py +103 -0
- Cython/Compiler/Tests/TestTypes.py +119 -0
- Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
- Cython/Compiler/Tests/TestVisitor.py +119 -0
- Cython/Compiler/Tests/Utils.py +36 -0
- Cython/Compiler/Tests/__init__.py +1 -0
- Cython/Compiler/TreeFragment.py +279 -0
- Cython/Compiler/TreePath.py +303 -0
- Cython/Compiler/TypeInference.py +626 -0
- Cython/Compiler/TypeSlots.py +1330 -0
- Cython/Compiler/UFuncs.py +317 -0
- Cython/Compiler/UtilNodes.py +389 -0
- Cython/Compiler/UtilityCode.py +354 -0
- Cython/Compiler/Version.py +8 -0
- Cython/Compiler/Visitor.pxd +52 -0
- Cython/Compiler/Visitor.py +914 -0
- Cython/Compiler/__init__.py +1 -0
- Cython/Coverage.py +448 -0
- Cython/Debugger/Cygdb.py +214 -0
- Cython/Debugger/DebugWriter.py +82 -0
- Cython/Debugger/Tests/TestLibCython.py +280 -0
- Cython/Debugger/Tests/__init__.py +1 -0
- Cython/Debugger/Tests/cfuncs.c +8 -0
- Cython/Debugger/Tests/codefile +49 -0
- Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
- Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
- Cython/Debugger/__init__.py +1 -0
- Cython/Debugger/libcython.py +1548 -0
- Cython/Debugger/libpython.py +2821 -0
- Cython/Debugging.py +20 -0
- Cython/Distutils/__init__.py +2 -0
- Cython/Distutils/build_ext.py +143 -0
- Cython/Distutils/extension.py +96 -0
- Cython/Distutils/old_build_ext.py +351 -0
- Cython/Includes/cpython/__init__.pxd +173 -0
- Cython/Includes/cpython/array.pxd +159 -0
- Cython/Includes/cpython/bool.pxd +37 -0
- Cython/Includes/cpython/buffer.pxd +112 -0
- Cython/Includes/cpython/bytearray.pxd +33 -0
- Cython/Includes/cpython/bytes.pxd +200 -0
- Cython/Includes/cpython/cellobject.pxd +35 -0
- Cython/Includes/cpython/ceval.pxd +8 -0
- Cython/Includes/cpython/codecs.pxd +121 -0
- Cython/Includes/cpython/complex.pxd +60 -0
- Cython/Includes/cpython/contextvars.pxd +145 -0
- Cython/Includes/cpython/conversion.pxd +36 -0
- Cython/Includes/cpython/datetime.pxd +395 -0
- Cython/Includes/cpython/descr.pxd +26 -0
- Cython/Includes/cpython/dict.pxd +268 -0
- Cython/Includes/cpython/exc.pxd +263 -0
- Cython/Includes/cpython/fileobject.pxd +57 -0
- Cython/Includes/cpython/float.pxd +56 -0
- Cython/Includes/cpython/frozendict.pxd +37 -0
- Cython/Includes/cpython/function.pxd +65 -0
- Cython/Includes/cpython/genobject.pxd +25 -0
- Cython/Includes/cpython/getargs.pxd +12 -0
- Cython/Includes/cpython/instance.pxd +25 -0
- Cython/Includes/cpython/iterator.pxd +36 -0
- Cython/Includes/cpython/iterobject.pxd +24 -0
- Cython/Includes/cpython/list.pxd +144 -0
- Cython/Includes/cpython/long.pxd +180 -0
- Cython/Includes/cpython/longintrepr.pxd +14 -0
- Cython/Includes/cpython/mapping.pxd +63 -0
- Cython/Includes/cpython/marshal.pxd +66 -0
- Cython/Includes/cpython/mem.pxd +120 -0
- Cython/Includes/cpython/memoryview.pxd +50 -0
- Cython/Includes/cpython/method.pxd +49 -0
- Cython/Includes/cpython/module.pxd +208 -0
- Cython/Includes/cpython/number.pxd +258 -0
- Cython/Includes/cpython/object.pxd +430 -0
- Cython/Includes/cpython/pycapsule.pxd +143 -0
- Cython/Includes/cpython/pylifecycle.pxd +68 -0
- Cython/Includes/cpython/pyport.pxd +8 -0
- Cython/Includes/cpython/pystate.pxd +95 -0
- Cython/Includes/cpython/pythread.pxd +53 -0
- Cython/Includes/cpython/ref.pxd +141 -0
- Cython/Includes/cpython/sentinel.pxd +17 -0
- Cython/Includes/cpython/sequence.pxd +134 -0
- Cython/Includes/cpython/set.pxd +119 -0
- Cython/Includes/cpython/slice.pxd +70 -0
- Cython/Includes/cpython/time.pxd +129 -0
- Cython/Includes/cpython/tuple.pxd +72 -0
- Cython/Includes/cpython/type.pxd +146 -0
- Cython/Includes/cpython/unicode.pxd +639 -0
- Cython/Includes/cpython/version.pxd +32 -0
- Cython/Includes/cpython/weakref.pxd +78 -0
- Cython/Includes/libc/__init__.pxd +1 -0
- Cython/Includes/libc/complex.pxd +35 -0
- Cython/Includes/libc/errno.pxd +127 -0
- Cython/Includes/libc/float.pxd +43 -0
- Cython/Includes/libc/limits.pxd +28 -0
- Cython/Includes/libc/locale.pxd +46 -0
- Cython/Includes/libc/math.pxd +209 -0
- Cython/Includes/libc/setjmp.pxd +10 -0
- Cython/Includes/libc/signal.pxd +64 -0
- Cython/Includes/libc/stdbool.pxd +5 -0
- Cython/Includes/libc/stddef.pxd +9 -0
- Cython/Includes/libc/stdint.pxd +105 -0
- Cython/Includes/libc/stdio.pxd +80 -0
- Cython/Includes/libc/stdlib.pxd +72 -0
- Cython/Includes/libc/string.pxd +50 -0
- Cython/Includes/libc/threads.pxd +234 -0
- Cython/Includes/libc/time.pxd +52 -0
- Cython/Includes/libcpp/__init__.pxd +4 -0
- Cython/Includes/libcpp/algorithm.pxd +320 -0
- Cython/Includes/libcpp/any.pxd +16 -0
- Cython/Includes/libcpp/atomic.pxd +59 -0
- Cython/Includes/libcpp/barrier.pxd +22 -0
- Cython/Includes/libcpp/bit.pxd +29 -0
- Cython/Includes/libcpp/cast.pxd +12 -0
- Cython/Includes/libcpp/cmath.pxd +518 -0
- Cython/Includes/libcpp/complex.pxd +106 -0
- Cython/Includes/libcpp/condition_variable.pxd +322 -0
- Cython/Includes/libcpp/deque.pxd +165 -0
- Cython/Includes/libcpp/exception.pxd +216 -0
- Cython/Includes/libcpp/execution.pxd +15 -0
- Cython/Includes/libcpp/forward_list.pxd +63 -0
- Cython/Includes/libcpp/functional.pxd +26 -0
- Cython/Includes/libcpp/future.pxd +103 -0
- Cython/Includes/libcpp/iterator.pxd +34 -0
- Cython/Includes/libcpp/latch.pxd +17 -0
- Cython/Includes/libcpp/limits.pxd +61 -0
- Cython/Includes/libcpp/list.pxd +117 -0
- Cython/Includes/libcpp/map.pxd +252 -0
- Cython/Includes/libcpp/memory.pxd +115 -0
- Cython/Includes/libcpp/mutex.pxd +387 -0
- Cython/Includes/libcpp/numbers.pxd +15 -0
- Cython/Includes/libcpp/numeric.pxd +131 -0
- Cython/Includes/libcpp/optional.pxd +34 -0
- Cython/Includes/libcpp/pair.pxd +1 -0
- Cython/Includes/libcpp/queue.pxd +25 -0
- Cython/Includes/libcpp/random.pxd +166 -0
- Cython/Includes/libcpp/semaphore.pxd +43 -0
- Cython/Includes/libcpp/set.pxd +228 -0
- Cython/Includes/libcpp/shared_mutex.pxd +96 -0
- Cython/Includes/libcpp/span.pxd +87 -0
- Cython/Includes/libcpp/stack.pxd +11 -0
- Cython/Includes/libcpp/stop_token.pxd +117 -0
- Cython/Includes/libcpp/string.pxd +355 -0
- Cython/Includes/libcpp/string_view.pxd +183 -0
- Cython/Includes/libcpp/typeindex.pxd +15 -0
- Cython/Includes/libcpp/typeinfo.pxd +10 -0
- Cython/Includes/libcpp/unordered_map.pxd +193 -0
- Cython/Includes/libcpp/unordered_set.pxd +152 -0
- Cython/Includes/libcpp/utility.pxd +30 -0
- Cython/Includes/libcpp/vector.pxd +186 -0
- Cython/Includes/numpy/math.pxd +150 -0
- Cython/Includes/openmp.pxd +50 -0
- Cython/Includes/posix/__init__.pxd +1 -0
- Cython/Includes/posix/dlfcn.pxd +14 -0
- Cython/Includes/posix/fcntl.pxd +86 -0
- Cython/Includes/posix/ioctl.pxd +4 -0
- Cython/Includes/posix/mman.pxd +101 -0
- Cython/Includes/posix/resource.pxd +57 -0
- Cython/Includes/posix/select.pxd +21 -0
- Cython/Includes/posix/signal.pxd +73 -0
- Cython/Includes/posix/stat.pxd +98 -0
- Cython/Includes/posix/stdio.pxd +37 -0
- Cython/Includes/posix/stdlib.pxd +29 -0
- Cython/Includes/posix/strings.pxd +9 -0
- Cython/Includes/posix/time.pxd +71 -0
- Cython/Includes/posix/types.pxd +30 -0
- Cython/Includes/posix/uio.pxd +26 -0
- Cython/Includes/posix/unistd.pxd +271 -0
- Cython/Includes/posix/wait.pxd +38 -0
- Cython/LZSS.py +184 -0
- Cython/Plex/Actions.pxd +24 -0
- Cython/Plex/Actions.py +119 -0
- Cython/Plex/DFA.pxd +14 -0
- Cython/Plex/DFA.py +164 -0
- Cython/Plex/Errors.py +48 -0
- Cython/Plex/Lexicons.py +178 -0
- Cython/Plex/Machines.pxd +36 -0
- Cython/Plex/Machines.py +238 -0
- Cython/Plex/Regexps.py +535 -0
- Cython/Plex/Scanners.pxd +45 -0
- Cython/Plex/Scanners.py +328 -0
- Cython/Plex/Transitions.pxd +14 -0
- Cython/Plex/Transitions.py +239 -0
- Cython/Plex/__init__.py +34 -0
- Cython/Runtime/__init__.py +1 -0
- Cython/Runtime/refnanny.pyx +237 -0
- Cython/Shadow.py +1172 -0
- Cython/StringIOTree.py +169 -0
- Cython/Tempita/__init__.py +4 -0
- Cython/Tempita/_looper.py +154 -0
- Cython/Tempita/_tempita.py +1087 -0
- Cython/TestUtils.py +472 -0
- Cython/Tests/TestCodeWriter.py +128 -0
- Cython/Tests/TestCythonUtils.py +237 -0
- Cython/Tests/TestJediTyper.py +223 -0
- Cython/Tests/TestShadow.py +125 -0
- Cython/Tests/TestStringIOTree.py +68 -0
- Cython/Tests/TestTestUtils.py +89 -0
- Cython/Tests/__init__.py +1 -0
- Cython/Tests/xmlrunner.py +390 -0
- Cython/Utility/AsyncGen.c +1152 -0
- Cython/Utility/Buffer.c +866 -0
- Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
- Cython/Utility/Builtins.c +1068 -0
- Cython/Utility/CConvert.pyx +153 -0
- Cython/Utility/CMath.c +104 -0
- Cython/Utility/CommonStructures.c +244 -0
- Cython/Utility/Complex.c +378 -0
- Cython/Utility/Coroutine.c +2344 -0
- Cython/Utility/CpdefEnums.pyx +119 -0
- Cython/Utility/CppConvert.pyx +284 -0
- Cython/Utility/CppSupport.cpp +151 -0
- Cython/Utility/CythonFunction.c +2143 -0
- Cython/Utility/Dataclasses.c +101 -0
- Cython/Utility/Embed.c +129 -0
- Cython/Utility/Exceptions.c +1331 -0
- Cython/Utility/Exceptions_Cy.pyx +109 -0
- Cython/Utility/ExtensionTypes.c +1199 -0
- Cython/Utility/FunctionArguments.c +1052 -0
- Cython/Utility/FusedFunction.pyx +44 -0
- Cython/Utility/ImportExport.c +972 -0
- Cython/Utility/MatchCase.c +985 -0
- Cython/Utility/MatchCase_Cy.pyx +12 -0
- Cython/Utility/MemoryView.pxd +108 -0
- Cython/Utility/MemoryView.pyx +1499 -0
- Cython/Utility/MemoryView_C.c +1056 -0
- Cython/Utility/ModuleSetupCode.c +3349 -0
- Cython/Utility/NumpyImportArray.c +46 -0
- Cython/Utility/ObjectHandling.c +3404 -0
- Cython/Utility/Optimize.c +2575 -0
- Cython/Utility/Overflow.c +378 -0
- Cython/Utility/Profile.c +736 -0
- Cython/Utility/StringTools.c +1534 -0
- Cython/Utility/Synchronization.c +438 -0
- Cython/Utility/TString.c +369 -0
- Cython/Utility/TestCyUtilityLoader.pyx +8 -0
- Cython/Utility/TestCythonScope.pyx +75 -0
- Cython/Utility/TestUtilityLoader.c +12 -0
- Cython/Utility/TypeConversion.c +1588 -0
- Cython/Utility/UFuncs.pyx +50 -0
- Cython/Utility/UFuncs_C.c +89 -0
- Cython/Utility/__init__.py +28 -0
- Cython/Utility/arrayarray.h +190 -0
- Cython/Utils.py +682 -0
- Cython/__init__.py +12 -0
- Cython/py.typed +0 -0
- cython.py +29 -0
- oxython-0.1.0.dist-info/METADATA +138 -0
- oxython-0.1.0.dist-info/RECORD +321 -0
- oxython-0.1.0.dist-info/WHEEL +5 -0
- oxython-0.1.0.dist-info/entry_points.txt +4 -0
- oxython-0.1.0.dist-info/top_level.txt +3 -0
- pyximport/__init__.py +4 -0
- pyximport/pyxbuild.py +160 -0
- pyximport/pyximport.py +482 -0
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
/////////////// ValidateBasesTuple.proto ///////////////
|
|
2
|
+
|
|
3
|
+
#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
|
|
4
|
+
static int __Pyx_validate_bases_tuple(const char *type_name, int has_dictoffset, PyObject *bases); /*proto*/
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
/////////////// ValidateBasesTuple ///////////////
|
|
8
|
+
//@requires: GetTypeDictOffset
|
|
9
|
+
//@requires: ObjectHandling.c::RaiseErrorWithObjectType
|
|
10
|
+
//@requires: ObjectHandling.c::RaiseErrorWithObjectType1
|
|
11
|
+
|
|
12
|
+
#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
|
|
13
|
+
static int __Pyx_validate_bases_tuple(const char *type_name, int has_dictoffset, PyObject *bases) {
|
|
14
|
+
// Loop over all bases (except the first) and check that those
|
|
15
|
+
// really are heap types. Otherwise, it would not be safe to
|
|
16
|
+
// subclass them.
|
|
17
|
+
//
|
|
18
|
+
// We also check tp_dictoffset: it is unsafe to inherit
|
|
19
|
+
// tp_dictoffset from a base class because the object structures
|
|
20
|
+
// would not be compatible. So, if our extension type doesn't set
|
|
21
|
+
// tp_dictoffset (i.e. there is no __dict__ attribute in the object
|
|
22
|
+
// structure), we need to check that none of the base classes sets
|
|
23
|
+
// it either.
|
|
24
|
+
Py_ssize_t i, n;
|
|
25
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
26
|
+
n = PyTuple_GET_SIZE(bases);
|
|
27
|
+
#else
|
|
28
|
+
n = PyTuple_Size(bases);
|
|
29
|
+
if (unlikely(n < 0)) return -1;
|
|
30
|
+
#endif
|
|
31
|
+
if (!has_dictoffset) {
|
|
32
|
+
// maybe one of the direct first bases does
|
|
33
|
+
PyObject *b;
|
|
34
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
35
|
+
b = PySequence_GetItem(bases, 0);
|
|
36
|
+
if (!b) return -1;
|
|
37
|
+
#elif CYTHON_ASSUME_SAFE_MACROS
|
|
38
|
+
b = PyTuple_GET_ITEM(bases, 0);
|
|
39
|
+
#else
|
|
40
|
+
b = PyTuple_GetItem(bases, 0);
|
|
41
|
+
if (!b) return -1;
|
|
42
|
+
#endif
|
|
43
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
44
|
+
has_dictoffset = ((PyTypeObject*)b)->tp_dictoffset != 0;
|
|
45
|
+
#else
|
|
46
|
+
Py_ssize_t dictoffset = __Pyx_GetTypeDictOffset(b, 0);
|
|
47
|
+
has_dictoffset = dictoffset != 0;
|
|
48
|
+
#endif
|
|
49
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
50
|
+
Py_DECREF(b);
|
|
51
|
+
#endif
|
|
52
|
+
#if !CYTHON_USE_TYPE_SLOTS
|
|
53
|
+
if (dictoffset == -1 && PyErr_Occurred()) return -1;
|
|
54
|
+
#endif
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (i = 1; i < n; i++) /* Skip first base */
|
|
58
|
+
{
|
|
59
|
+
PyTypeObject *b;
|
|
60
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
61
|
+
PyObject *b0 = PySequence_GetItem(bases, i);
|
|
62
|
+
if (!b0) return -1;
|
|
63
|
+
#elif CYTHON_ASSUME_SAFE_MACROS
|
|
64
|
+
PyObject *b0 = PyTuple_GET_ITEM(bases, i);
|
|
65
|
+
#else
|
|
66
|
+
PyObject *b0 = PyTuple_GetItem(bases, i);
|
|
67
|
+
if (!b0) return -1;
|
|
68
|
+
#endif
|
|
69
|
+
b = (PyTypeObject*) b0;
|
|
70
|
+
if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
|
|
71
|
+
{
|
|
72
|
+
__Pyx_RaiseErrorWithType(
|
|
73
|
+
PyExc_TypeError, "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b);
|
|
74
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
75
|
+
Py_DECREF(b0);
|
|
76
|
+
#endif
|
|
77
|
+
return -1;
|
|
78
|
+
}
|
|
79
|
+
if (!has_dictoffset)
|
|
80
|
+
{
|
|
81
|
+
Py_ssize_t b_dictoffset = 0;
|
|
82
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
83
|
+
b_dictoffset = b->tp_dictoffset;
|
|
84
|
+
#else
|
|
85
|
+
b_dictoffset = __Pyx_GetTypeDictOffset((PyObject*)b, 0);
|
|
86
|
+
if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return;
|
|
87
|
+
#endif
|
|
88
|
+
if (b_dictoffset) {
|
|
89
|
+
__Pyx_RaiseErrorWithType1(
|
|
90
|
+
PyExc_TypeError,
|
|
91
|
+
"extension type '%.200s' has no __dict__ slot, "
|
|
92
|
+
"but base type '" __Pyx_FMT_TYPENAME "' has: "
|
|
93
|
+
"either add 'cdef dict __dict__' to the extension type "
|
|
94
|
+
"or add '__slots__ = [...]' to the base type",
|
|
95
|
+
type_name, b);
|
|
96
|
+
#if !CYTHON_USE_TYPE_SLOTS
|
|
97
|
+
dictoffset_return:
|
|
98
|
+
#endif
|
|
99
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
100
|
+
Py_DECREF(b0);
|
|
101
|
+
#endif
|
|
102
|
+
return -1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
106
|
+
Py_DECREF(b0);
|
|
107
|
+
#endif
|
|
108
|
+
}
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
#endif
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/////////////// PyType_Ready.export ///////////////
|
|
115
|
+
|
|
116
|
+
// unused when using type specs
|
|
117
|
+
CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t);/*proto*/
|
|
118
|
+
|
|
119
|
+
/////////////// PyType_Ready ///////////////
|
|
120
|
+
//@requires: ObjectHandling.c::PyObjectCallMethod0
|
|
121
|
+
//@requires: ValidateBasesTuple
|
|
122
|
+
|
|
123
|
+
CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) {
|
|
124
|
+
while (t) {
|
|
125
|
+
PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
|
|
126
|
+
if (bases) {
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*);
|
|
130
|
+
}
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Wrapper around PyType_Ready() with some runtime checks and fixes
|
|
135
|
+
// to deal with multiple inheritance.
|
|
136
|
+
static int __Pyx_PyType_Ready(PyTypeObject *t) {
|
|
137
|
+
|
|
138
|
+
#if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON
|
|
139
|
+
// avoid C warning about unused helper function
|
|
140
|
+
(void)&__Pyx_PyObject_CallMethod0;
|
|
141
|
+
#if CYTHON_USE_TYPE_SPECS
|
|
142
|
+
(void)&__Pyx_validate_bases_tuple;
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
return PyType_Ready(t);
|
|
146
|
+
|
|
147
|
+
#else
|
|
148
|
+
int r;
|
|
149
|
+
|
|
150
|
+
if (!__Pyx_PyType_HasMultipleInheritance(t)) {
|
|
151
|
+
// shortcut - if none of the base classes do multiple inheritance then we don't need to
|
|
152
|
+
// (and shouldn't) mess around with faking heaptypes.
|
|
153
|
+
return PyType_Ready(t);
|
|
154
|
+
}
|
|
155
|
+
PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
|
|
156
|
+
if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset != 0, bases) == -1))
|
|
157
|
+
return -1;
|
|
158
|
+
|
|
159
|
+
{
|
|
160
|
+
// Make sure GC does not pick up our non-heap type as heap type with this hack!
|
|
161
|
+
// For details, see https://github.com/cython/cython/issues/3603
|
|
162
|
+
int gc_was_enabled;
|
|
163
|
+
#if PY_VERSION_HEX >= 0x030A00b1
|
|
164
|
+
// finally added in Py3.10 :)
|
|
165
|
+
gc_was_enabled = PyGC_Disable();
|
|
166
|
+
(void)&__Pyx_PyObject_CallMethod0;
|
|
167
|
+
|
|
168
|
+
#else
|
|
169
|
+
// Call gc.disable() as a backwards compatible fallback, but only if needed.
|
|
170
|
+
PyObject *ret, *py_status;
|
|
171
|
+
PyObject *gc = NULL;
|
|
172
|
+
#if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) && \
|
|
173
|
+
!CYTHON_COMPILING_IN_GRAAL
|
|
174
|
+
// https://foss.heptapod.net/pypy/pypy/-/issues/3385
|
|
175
|
+
gc = PyImport_GetModule(PYUNICODE("gc"));
|
|
176
|
+
#endif
|
|
177
|
+
if (unlikely(!gc)) gc = PyImport_Import(PYUNICODE("gc"));
|
|
178
|
+
if (unlikely(!gc)) return -1;
|
|
179
|
+
py_status = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("isenabled"));
|
|
180
|
+
if (unlikely(!py_status)) {
|
|
181
|
+
Py_DECREF(gc);
|
|
182
|
+
return -1;
|
|
183
|
+
}
|
|
184
|
+
gc_was_enabled = __Pyx_PyObject_IsTrue(py_status);
|
|
185
|
+
Py_DECREF(py_status);
|
|
186
|
+
if (gc_was_enabled > 0) {
|
|
187
|
+
ret = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("disable"));
|
|
188
|
+
if (unlikely(!ret)) {
|
|
189
|
+
Py_DECREF(gc);
|
|
190
|
+
return -1;
|
|
191
|
+
}
|
|
192
|
+
Py_DECREF(ret);
|
|
193
|
+
} else if (unlikely(gc_was_enabled == -1)) {
|
|
194
|
+
Py_DECREF(gc);
|
|
195
|
+
return -1;
|
|
196
|
+
}
|
|
197
|
+
#endif
|
|
198
|
+
|
|
199
|
+
// As of https://github.com/python/cpython/issues/66277
|
|
200
|
+
// PyType_Ready enforces that all bases of a non-heap type are
|
|
201
|
+
// non-heap. We know that this is the case for the solid base but
|
|
202
|
+
// other bases are heap allocated and are kept alive through the
|
|
203
|
+
// tp_bases reference.
|
|
204
|
+
// Other than this check, the Py_TPFLAGS_HEAPTYPE flag is unused
|
|
205
|
+
// in PyType_Ready().
|
|
206
|
+
t->tp_flags |= Py_TPFLAGS_HEAPTYPE;
|
|
207
|
+
#if PY_VERSION_HEX >= 0x030A0000
|
|
208
|
+
// As of https://github.com/python/cpython/pull/25520
|
|
209
|
+
// PyType_Ready marks types as immutable if they are static types
|
|
210
|
+
// and requires the Py_TPFLAGS_IMMUTABLETYPE flag to mark types as
|
|
211
|
+
// immutable
|
|
212
|
+
// Manually set the Py_TPFLAGS_IMMUTABLETYPE flag, since the type
|
|
213
|
+
// is immutable
|
|
214
|
+
t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
|
|
215
|
+
#endif
|
|
216
|
+
|
|
217
|
+
r = PyType_Ready(t);
|
|
218
|
+
|
|
219
|
+
t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
|
|
220
|
+
|
|
221
|
+
#if PY_VERSION_HEX >= 0x030A00b1
|
|
222
|
+
if (gc_was_enabled)
|
|
223
|
+
PyGC_Enable();
|
|
224
|
+
#else
|
|
225
|
+
if (gc_was_enabled) {
|
|
226
|
+
PyObject *tp, *v, *tb;
|
|
227
|
+
PyErr_Fetch(&tp, &v, &tb);
|
|
228
|
+
ret = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("enable"));
|
|
229
|
+
if (likely(ret || r == -1)) {
|
|
230
|
+
Py_XDECREF(ret);
|
|
231
|
+
// do not overwrite exceptions raised by PyType_Ready() above
|
|
232
|
+
PyErr_Restore(tp, v, tb);
|
|
233
|
+
} else {
|
|
234
|
+
// PyType_Ready() succeeded, but gc.enable() failed.
|
|
235
|
+
Py_XDECREF(tp);
|
|
236
|
+
Py_XDECREF(v);
|
|
237
|
+
Py_XDECREF(tb);
|
|
238
|
+
r = -1;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
Py_DECREF(gc);
|
|
242
|
+
#endif
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return r;
|
|
246
|
+
#endif
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
/////////////// PyTrashcan.proto ///////////////
|
|
251
|
+
|
|
252
|
+
// These macros are taken from https://github.com/python/cpython/pull/11841
|
|
253
|
+
// Unlike the Py_TRASHCAN_SAFE_BEGIN/Py_TRASHCAN_SAFE_END macros, they
|
|
254
|
+
// allow dealing correctly with subclasses.
|
|
255
|
+
|
|
256
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
257
|
+
// https://github.com/python/cpython/pull/11841 merged so Cython reimplementation
|
|
258
|
+
// is no longer necessary
|
|
259
|
+
#define __Pyx_TRASHCAN_BEGIN Py_TRASHCAN_BEGIN
|
|
260
|
+
#define __Pyx_TRASHCAN_END Py_TRASHCAN_END
|
|
261
|
+
|
|
262
|
+
#elif CYTHON_COMPILING_IN_CPYTHON
|
|
263
|
+
|
|
264
|
+
#define __Pyx_TRASHCAN_BEGIN_CONDITION(op, cond) \
|
|
265
|
+
do { \
|
|
266
|
+
PyThreadState *_tstate = NULL; \
|
|
267
|
+
// If "cond" is false, then _tstate remains NULL and the deallocator
|
|
268
|
+
// is run normally without involving the trashcan
|
|
269
|
+
if (cond) { \
|
|
270
|
+
_tstate = PyThreadState_GET(); \
|
|
271
|
+
if (_tstate->trash_delete_nesting >= PyTrash_UNWIND_LEVEL) { \
|
|
272
|
+
// Store the object (to be deallocated later) and jump past
|
|
273
|
+
// Py_TRASHCAN_END, skipping the body of the deallocator
|
|
274
|
+
_PyTrash_thread_deposit_object((PyObject*)(op)); \
|
|
275
|
+
break; \
|
|
276
|
+
} \
|
|
277
|
+
++_tstate->trash_delete_nesting; \
|
|
278
|
+
}
|
|
279
|
+
// The body of the deallocator is here.
|
|
280
|
+
#define __Pyx_TRASHCAN_END \
|
|
281
|
+
if (_tstate) { \
|
|
282
|
+
--_tstate->trash_delete_nesting; \
|
|
283
|
+
if (_tstate->trash_delete_later && _tstate->trash_delete_nesting <= 0) \
|
|
284
|
+
_PyTrash_thread_destroy_chain(); \
|
|
285
|
+
} \
|
|
286
|
+
} while (0);
|
|
287
|
+
|
|
288
|
+
#define __Pyx_TRASHCAN_BEGIN(op, dealloc) __Pyx_TRASHCAN_BEGIN_CONDITION(op, \
|
|
289
|
+
__Pyx_PyObject_GetSlot(op, tp_dealloc, destructor) == (destructor)(dealloc))
|
|
290
|
+
|
|
291
|
+
#else
|
|
292
|
+
// The trashcan is a no-op on other Python implementations
|
|
293
|
+
// or old CPython versions
|
|
294
|
+
#define __Pyx_TRASHCAN_BEGIN(op, dealloc)
|
|
295
|
+
#define __Pyx_TRASHCAN_END
|
|
296
|
+
#endif
|
|
297
|
+
|
|
298
|
+
/////////////// DeallocKeepAlive.proto ///////////////
|
|
299
|
+
|
|
300
|
+
// Keep `o` alive across a call into user __dealloc__ code, to prevent the user
|
|
301
|
+
// code from triggering recursive deallocation, then drop the temporary reference.
|
|
302
|
+
//
|
|
303
|
+
// On the GIL build this is a plain refcount bump. On free-threading we must NOT
|
|
304
|
+
// use Py_SET_REFCNT(o, 1): the object reaching tp_dealloc is unowned and merged
|
|
305
|
+
// (ob_ref_shared == _Py_REF_MERGED), so Py_SET_REFCNT takes the unowned branch and
|
|
306
|
+
// writes ob_ref_shared = _Py_REF_SHARED(1, _Py_REF_MERGED), i.e. "merged, shared
|
|
307
|
+
// count 1" -- indistinguishable from a live object. A concurrent
|
|
308
|
+
// PyUnstable_TryIncRef() would then succeed and resurrect the dying object
|
|
309
|
+
// (use-after-free). Instead we mirror CPython's _PyObject_ResurrectStart/End:
|
|
310
|
+
// re-take ownership and keep the *shared* refcount at the refuse sentinel (0), so
|
|
311
|
+
// the bump is invisible to other threads and TryIncRef keeps refusing.
|
|
312
|
+
|
|
313
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
314
|
+
#define __Pyx_DeallocKeepAliveBegin(o) do { \
|
|
315
|
+
_Py_atomic_store_uintptr_relaxed(&(o)->ob_tid, _Py_ThreadId()); \
|
|
316
|
+
_Py_atomic_store_uint32_relaxed(&(o)->ob_ref_local, 1); \
|
|
317
|
+
_Py_atomic_store_ssize_relaxed(&(o)->ob_ref_shared, 0); \
|
|
318
|
+
} while (0)
|
|
319
|
+
#define __Pyx_DeallocKeepAliveEnd(o) \
|
|
320
|
+
_Py_atomic_store_uint32_relaxed(&(o)->ob_ref_local, 0)
|
|
321
|
+
#else
|
|
322
|
+
#define __Pyx_DeallocKeepAliveBegin(o) Py_SET_REFCNT(o, Py_REFCNT(o) + 1)
|
|
323
|
+
#define __Pyx_DeallocKeepAliveEnd(o) Py_SET_REFCNT(o, Py_REFCNT(o) - 1)
|
|
324
|
+
#endif
|
|
325
|
+
|
|
326
|
+
/////////////// CallNextTpDealloc.proto ///////////////
|
|
327
|
+
|
|
328
|
+
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
|
|
329
|
+
|
|
330
|
+
/////////////// CallNextTpDealloc ///////////////
|
|
331
|
+
|
|
332
|
+
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
|
|
333
|
+
PyTypeObject* type = Py_TYPE(obj);
|
|
334
|
+
destructor tp_dealloc = NULL;
|
|
335
|
+
/* try to find the first parent type that has a different tp_dealloc() function */
|
|
336
|
+
while (type && __Pyx_PyType_GetSlot(type, tp_dealloc, destructor) != current_tp_dealloc)
|
|
337
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
338
|
+
while (type && (tp_dealloc = __Pyx_PyType_GetSlot(type, tp_dealloc, destructor)) == current_tp_dealloc)
|
|
339
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
340
|
+
if (type)
|
|
341
|
+
tp_dealloc(obj);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/////////////// CallNextTpTraverse.proto ///////////////
|
|
345
|
+
|
|
346
|
+
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
|
|
347
|
+
|
|
348
|
+
/////////////// CallNextTpTraverse ///////////////
|
|
349
|
+
|
|
350
|
+
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
|
|
351
|
+
PyTypeObject* type = Py_TYPE(obj);
|
|
352
|
+
traverseproc tp_traverse = NULL;
|
|
353
|
+
/* try to find the first parent type that has a different tp_traverse() function */
|
|
354
|
+
while (type && __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc) != current_tp_traverse)
|
|
355
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
356
|
+
while (type && (tp_traverse = __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc)) == current_tp_traverse)
|
|
357
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
358
|
+
if (type && tp_traverse)
|
|
359
|
+
return tp_traverse(obj, v, a);
|
|
360
|
+
// FIXME: really ignore?
|
|
361
|
+
return 0;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/////////////// CallNextTpClear.proto ///////////////
|
|
365
|
+
|
|
366
|
+
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear);
|
|
367
|
+
|
|
368
|
+
/////////////// CallNextTpClear ///////////////
|
|
369
|
+
|
|
370
|
+
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
|
|
371
|
+
PyTypeObject* type = Py_TYPE(obj);
|
|
372
|
+
inquiry tp_clear = NULL;
|
|
373
|
+
/* try to find the first parent type that has a different tp_clear() function */
|
|
374
|
+
while (type && __Pyx_PyType_GetSlot(type, tp_clear, inquiry) != current_tp_clear)
|
|
375
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
376
|
+
while (type && (tp_clear = __Pyx_PyType_GetSlot(type, tp_clear, inquiry)) == current_tp_clear)
|
|
377
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
378
|
+
if (type && tp_clear)
|
|
379
|
+
tp_clear(obj);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
/////////////// SetupReduce.export ///////////////
|
|
384
|
+
//@feature: AutoPickle
|
|
385
|
+
|
|
386
|
+
static int __Pyx_setup_reduce(PyObject* type_obj);
|
|
387
|
+
|
|
388
|
+
/////////////// SetupReduce ///////////////
|
|
389
|
+
//@requires: ObjectHandling.c::PyObjectGetAttrStrNoError
|
|
390
|
+
//@requires: ObjectHandling.c::PyObjectGetAttrStr
|
|
391
|
+
//@requires: ObjectHandling.c::RaiseErrorWithObjectType
|
|
392
|
+
//@requires: Exceptions.c::IgnoreException
|
|
393
|
+
//@requires: SetItemOnTypeDict
|
|
394
|
+
//@requires: DelItemOnTypeDict
|
|
395
|
+
|
|
396
|
+
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
|
|
397
|
+
int ret;
|
|
398
|
+
PyObject *name_attr;
|
|
399
|
+
|
|
400
|
+
name_attr = __Pyx_PyObject_GetAttrStrNoError(meth, PYIDENT("__name__"));
|
|
401
|
+
if (likely(name_attr)) {
|
|
402
|
+
ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
|
|
403
|
+
} else {
|
|
404
|
+
ret = -1;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (unlikely(ret < 0) && __Pyx_IgnoreException(PyExc_Exception)) {
|
|
408
|
+
ret = 0; // But BaseException is still propagated.
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
Py_XDECREF(name_attr);
|
|
412
|
+
return ret;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Returns a borrowed reference with CYTHON_USE_PYTYPE_LOOKUP
|
|
416
|
+
static PyObject *__Pyx_setup_reduce_get_reduce_attribute(PyObject *type_obj, PyObject *name, int allow_not_present) {
|
|
417
|
+
#if CYTHON_USE_PYTYPE_LOOKUP
|
|
418
|
+
CYTHON_UNUSED_VAR(allow_not_present);
|
|
419
|
+
return _PyType_Lookup((PyTypeObject*)type_obj, name);
|
|
420
|
+
#else
|
|
421
|
+
if (allow_not_present) {
|
|
422
|
+
return __Pyx_PyObject_GetAttrStrNoError(type_obj, name);
|
|
423
|
+
} else {
|
|
424
|
+
return __Pyx_PyObject_GetAttrStr(type_obj, name);
|
|
425
|
+
}
|
|
426
|
+
#endif
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
static int __Pyx_setup_reduce(PyObject* type_obj) {
|
|
430
|
+
int ret = 0;
|
|
431
|
+
PyObject *object_reduce = NULL;
|
|
432
|
+
PyObject *object_getstate = NULL;
|
|
433
|
+
PyObject *object_reduce_ex = NULL;
|
|
434
|
+
PyObject *reduce = NULL;
|
|
435
|
+
PyObject *reduce_ex = NULL;
|
|
436
|
+
PyObject *reduce_cython = NULL;
|
|
437
|
+
PyObject *setstate = NULL;
|
|
438
|
+
PyObject *setstate_cython = NULL;
|
|
439
|
+
PyObject *getstate = NULL;
|
|
440
|
+
|
|
441
|
+
getstate = __Pyx_setup_reduce_get_reduce_attribute(type_obj, PYIDENT("__getstate__"), 1);
|
|
442
|
+
if (!getstate && PyErr_Occurred()) {
|
|
443
|
+
goto __PYX_BAD;
|
|
444
|
+
}
|
|
445
|
+
if (getstate) {
|
|
446
|
+
// Python 3.11 introduces object.__getstate__. Because it's version-specific failure to find it should not be an error
|
|
447
|
+
object_getstate = __Pyx_setup_reduce_get_reduce_attribute((PyObject*)&PyBaseObject_Type, PYIDENT("__getstate__"), 1);
|
|
448
|
+
if (!object_getstate && PyErr_Occurred()) {
|
|
449
|
+
goto __PYX_BAD;
|
|
450
|
+
}
|
|
451
|
+
if (object_getstate != getstate) {
|
|
452
|
+
goto __PYX_GOOD;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
object_reduce_ex = __Pyx_setup_reduce_get_reduce_attribute((PyObject*)&PyBaseObject_Type, PYIDENT("__reduce_ex__"), 0);
|
|
457
|
+
if (unlikely(!object_reduce_ex)) goto __PYX_BAD;
|
|
458
|
+
reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce_ex__")); if (unlikely(!reduce_ex)) goto __PYX_BAD;
|
|
459
|
+
if (reduce_ex == object_reduce_ex) {
|
|
460
|
+
object_reduce = __Pyx_setup_reduce_get_reduce_attribute((PyObject*)&PyBaseObject_Type, PYIDENT("__reduce__"), 0);
|
|
461
|
+
if (!object_reduce) goto __PYX_BAD;
|
|
462
|
+
reduce = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce__")); if (unlikely(!reduce)) goto __PYX_BAD;
|
|
463
|
+
|
|
464
|
+
int try_to_replace_reduce = (reduce == object_reduce);
|
|
465
|
+
if (!try_to_replace_reduce) {
|
|
466
|
+
try_to_replace_reduce = __Pyx_setup_reduce_is_named(reduce, PYIDENT("__reduce_cython__"));
|
|
467
|
+
if (unlikely(try_to_replace_reduce < 0)) {
|
|
468
|
+
goto __PYX_BAD;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (try_to_replace_reduce) {
|
|
473
|
+
reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__reduce_cython__"));
|
|
474
|
+
if (likely(reduce_cython)) {
|
|
475
|
+
ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__reduce__"), reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
476
|
+
ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__reduce_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
477
|
+
} else if (reduce == object_reduce || PyErr_Occurred()) {
|
|
478
|
+
// Ignore if we're done, i.e. if 'reduce' already has the right name and the original is gone.
|
|
479
|
+
// Otherwise: error.
|
|
480
|
+
goto __PYX_BAD;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
setstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__setstate__"));
|
|
484
|
+
int try_to_replace_setstate;
|
|
485
|
+
if (!setstate) {
|
|
486
|
+
PyObject *exc = PyErr_Occurred();
|
|
487
|
+
if (exc && !__Pyx_IgnoreGivenException(exc, PyExc_Exception)) {
|
|
488
|
+
goto __PYX_BAD;
|
|
489
|
+
}
|
|
490
|
+
try_to_replace_setstate = 1;
|
|
491
|
+
} else {
|
|
492
|
+
try_to_replace_setstate = __Pyx_setup_reduce_is_named(setstate, PYIDENT("__setstate_cython__"));
|
|
493
|
+
if (unlikely(try_to_replace_setstate < 0)) {
|
|
494
|
+
goto __PYX_BAD;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (try_to_replace_setstate) {
|
|
499
|
+
setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__setstate_cython__"));
|
|
500
|
+
if (likely(setstate_cython)) {
|
|
501
|
+
ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__setstate__"), setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
502
|
+
ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__setstate_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
503
|
+
} else if (!setstate || PyErr_Occurred()) {
|
|
504
|
+
// Ignore if we're done, i.e. if 'setstate' already has the right name and the original is gone.
|
|
505
|
+
// Otherwise: error.
|
|
506
|
+
goto __PYX_BAD;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
PyType_Modified((PyTypeObject*)type_obj);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
goto __PYX_GOOD;
|
|
513
|
+
|
|
514
|
+
__PYX_BAD:
|
|
515
|
+
if (!PyErr_Occurred()) {
|
|
516
|
+
__Pyx_RaiseErrorWithType(
|
|
517
|
+
PyExc_RuntimeError,
|
|
518
|
+
"Unable to initialize pickling for " __Pyx_FMT_TYPENAME,
|
|
519
|
+
(PyTypeObject*)type_obj);
|
|
520
|
+
}
|
|
521
|
+
ret = -1;
|
|
522
|
+
__PYX_GOOD:
|
|
523
|
+
#if !CYTHON_USE_PYTYPE_LOOKUP
|
|
524
|
+
Py_XDECREF(object_reduce);
|
|
525
|
+
Py_XDECREF(object_reduce_ex);
|
|
526
|
+
Py_XDECREF(object_getstate);
|
|
527
|
+
Py_XDECREF(getstate);
|
|
528
|
+
#endif
|
|
529
|
+
Py_XDECREF(reduce);
|
|
530
|
+
Py_XDECREF(reduce_ex);
|
|
531
|
+
Py_XDECREF(reduce_cython);
|
|
532
|
+
Py_XDECREF(setstate);
|
|
533
|
+
Py_XDECREF(setstate_cython);
|
|
534
|
+
return ret;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
/////////////// CheckUnpickleChecksum.proto ///////////////
|
|
539
|
+
|
|
540
|
+
static CYTHON_INLINE int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members); /*proto*/
|
|
541
|
+
|
|
542
|
+
/////////////// CheckUnpickleChecksum ///////////////
|
|
543
|
+
//@requires: CheckUnpickleChecksumError
|
|
544
|
+
|
|
545
|
+
static int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members) {
|
|
546
|
+
int found = 0;
|
|
547
|
+
found |= checksum1 == checksum;
|
|
548
|
+
found |= checksum2 == checksum;
|
|
549
|
+
found |= checksum3 == checksum;
|
|
550
|
+
if (likely(found))
|
|
551
|
+
return 0;
|
|
552
|
+
|
|
553
|
+
__Pyx_RaiseUnpickleChecksumError(checksum, checksum1, checksum2, checksum3, members);
|
|
554
|
+
return -1;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
/////////////// CheckUnpickleChecksumError.export ///////////////
|
|
559
|
+
//@feature: AutoPickle
|
|
560
|
+
|
|
561
|
+
static void __Pyx_RaiseUnpickleChecksumError(long checksum, long checksum1, long checksum2, long checksum3, const char *members); /*proto*/
|
|
562
|
+
|
|
563
|
+
/////////////// CheckUnpickleChecksumError ///////////////
|
|
564
|
+
|
|
565
|
+
static void __Pyx_RaiseUnpickleChecksumError(long checksum, long checksum1, long checksum2, long checksum3, const char *members) {
|
|
566
|
+
// This function always raises some kind of error, either the expected one or a different one.
|
|
567
|
+
PyObject *pickle_module = PyImport_ImportModule("pickle");
|
|
568
|
+
if (unlikely(!pickle_module)) return;
|
|
569
|
+
|
|
570
|
+
PyObject *pickle_error = PyObject_GetAttrString(pickle_module, "PickleError");
|
|
571
|
+
Py_DECREF(pickle_module);
|
|
572
|
+
if (unlikely(!pickle_error)) return;
|
|
573
|
+
|
|
574
|
+
if (checksum2 == checksum1) {
|
|
575
|
+
PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x) = (%s))",
|
|
576
|
+
checksum, checksum1, members);
|
|
577
|
+
} else if (checksum3 == checksum2) {
|
|
578
|
+
PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x) = (%s))",
|
|
579
|
+
checksum, checksum1, checksum2, members);
|
|
580
|
+
} else {
|
|
581
|
+
PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x, 0x%x) = (%s))",
|
|
582
|
+
checksum, checksum1, checksum2, checksum3, members);
|
|
583
|
+
}
|
|
584
|
+
Py_DECREF(pickle_error);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
/////////////// UpdateUnpickledDict.export ///////////////
|
|
589
|
+
//@feature: AutoPickle
|
|
590
|
+
|
|
591
|
+
static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index); /*proto*/
|
|
592
|
+
|
|
593
|
+
/////////////// UpdateUnpickledDict ///////////////
|
|
594
|
+
//@requires: ObjectHandling.c::PyObjectCallMethod1
|
|
595
|
+
|
|
596
|
+
static int __Pyx__UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) {
|
|
597
|
+
PyObject *state_dict = __Pyx_PySequence_ITEM(state, index);
|
|
598
|
+
if (unlikely(!state_dict)) {
|
|
599
|
+
return -1;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
int non_empty = PyObject_IsTrue(state_dict);
|
|
603
|
+
if (non_empty == 0) {
|
|
604
|
+
// Nothing to do.
|
|
605
|
+
Py_DECREF(state_dict);
|
|
606
|
+
return 0;
|
|
607
|
+
} else if (unlikely(non_empty == -1)) {
|
|
608
|
+
return -1;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// Since we received a non-empty dict from pickling,
|
|
612
|
+
// we assume that we're unpickling an object that has one, too.
|
|
613
|
+
PyObject *dict;
|
|
614
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
615
|
+
dict = PyObject_GetAttrString(obj, "__dict__");
|
|
616
|
+
#else
|
|
617
|
+
dict = PyObject_GenericGetDict(obj, NULL);
|
|
618
|
+
#endif
|
|
619
|
+
if (unlikely(!dict)) {
|
|
620
|
+
// It is debatable if it is a fatal error if we cannot reassign the state of the dict because
|
|
621
|
+
// the unpickled object does not have a '__dict__'. But the user should probably know.
|
|
622
|
+
Py_DECREF(state_dict);
|
|
623
|
+
return -1;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
int result;
|
|
627
|
+
if (likely(PyDict_CheckExact(dict))) {
|
|
628
|
+
result = PyDict_Update(dict, state_dict);
|
|
629
|
+
} else {
|
|
630
|
+
PyObject *obj_result = __Pyx_PyObject_CallMethod1(dict, PYIDENT("update"), state_dict);
|
|
631
|
+
if (likely(obj_result)) {
|
|
632
|
+
Py_DECREF(obj_result);
|
|
633
|
+
result = 0;
|
|
634
|
+
} else {
|
|
635
|
+
result = -1;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
Py_DECREF(state_dict);
|
|
639
|
+
Py_DECREF(dict);
|
|
640
|
+
return result;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) {
|
|
644
|
+
Py_ssize_t state_size = __Pyx_PyTuple_GET_SIZE(state);
|
|
645
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
646
|
+
if (unlikely(state_size == -1)) return -1;
|
|
647
|
+
#endif
|
|
648
|
+
if (state_size <= index) {
|
|
649
|
+
// No dict from pickling.
|
|
650
|
+
return 0;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
return __Pyx__UpdateUnpickledDict(obj, state, index);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
/////////////// BinopSlot ///////////////
|
|
658
|
+
//@requires: ModuleSetupCode.c::FastTypeChecks
|
|
659
|
+
|
|
660
|
+
static CYTHON_INLINE PyObject *{{func_name}}_maybe_call_slot(PyTypeObject* type, PyObject *left, PyObject *right {{extra_arg_decl}}) {
|
|
661
|
+
{{slot_type}} slot;
|
|
662
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
663
|
+
slot = type->tp_as_number ? type->tp_as_number->{{slot_name}} : NULL;
|
|
664
|
+
#else
|
|
665
|
+
slot = ({{slot_type}}) PyType_GetSlot(type, Py_{{slot_name}});
|
|
666
|
+
#endif
|
|
667
|
+
return slot ? slot(left, right {{extra_arg}}) : __Pyx_NewRef(Py_NotImplemented);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
static PyObject *{{func_name}}(PyObject *left, PyObject *right {{extra_arg_decl}}) {
|
|
671
|
+
int maybe_self_is_left, maybe_self_is_right = 0;
|
|
672
|
+
maybe_self_is_left = Py_TYPE(left) == Py_TYPE(right)
|
|
673
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
674
|
+
|| (Py_TYPE(left)->tp_as_number && Py_TYPE(left)->tp_as_number->{{slot_name}} == &{{func_name}})
|
|
675
|
+
#endif
|
|
676
|
+
|| __Pyx_TypeCheck(left, {{type_cname}});
|
|
677
|
+
|
|
678
|
+
// Optimize for the common case where the left operation is defined (and successful).
|
|
679
|
+
{{if not overloads_left}}
|
|
680
|
+
maybe_self_is_right = Py_TYPE(left) == Py_TYPE(right)
|
|
681
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
682
|
+
|| (Py_TYPE(right)->tp_as_number && Py_TYPE(right)->tp_as_number->{{slot_name}} == &{{func_name}})
|
|
683
|
+
#endif
|
|
684
|
+
|| __Pyx_TypeCheck(right, {{type_cname}});
|
|
685
|
+
{{endif}}
|
|
686
|
+
|
|
687
|
+
if (maybe_self_is_left) {
|
|
688
|
+
PyObject *res;
|
|
689
|
+
|
|
690
|
+
{{if overloads_right and not overloads_left}}
|
|
691
|
+
if (maybe_self_is_right) {
|
|
692
|
+
res = {{call_right}};
|
|
693
|
+
if (res != Py_NotImplemented) return res;
|
|
694
|
+
Py_DECREF(res);
|
|
695
|
+
// Don't bother calling it again.
|
|
696
|
+
maybe_self_is_right = 0;
|
|
697
|
+
}
|
|
698
|
+
{{endif}}
|
|
699
|
+
|
|
700
|
+
res = {{call_left}};
|
|
701
|
+
if (res != Py_NotImplemented) return res;
|
|
702
|
+
Py_DECREF(res);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
{{if overloads_left}}
|
|
706
|
+
maybe_self_is_right = Py_TYPE(left) == Py_TYPE(right)
|
|
707
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
708
|
+
|| (Py_TYPE(right)->tp_as_number && Py_TYPE(right)->tp_as_number->{{slot_name}} == &{{func_name}})
|
|
709
|
+
#endif
|
|
710
|
+
|| PyType_IsSubtype(Py_TYPE(right), {{type_cname}});
|
|
711
|
+
{{endif}}
|
|
712
|
+
|
|
713
|
+
if (maybe_self_is_right) {
|
|
714
|
+
return {{call_right}};
|
|
715
|
+
}
|
|
716
|
+
return __Pyx_NewRef(Py_NotImplemented);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
/////////////// ValidateExternBase.export ///////////////
|
|
721
|
+
|
|
722
|
+
static int __Pyx_validate_extern_base(PyTypeObject *base); /* proto */
|
|
723
|
+
|
|
724
|
+
/////////////// ValidateExternBase ///////////////
|
|
725
|
+
//@requires: ObjectHandling.c::FormatTypeName
|
|
726
|
+
//@requires: ObjectHandling.c::RaiseErrorWithObjectType
|
|
727
|
+
|
|
728
|
+
static int __Pyx_validate_extern_base(PyTypeObject *base) {
|
|
729
|
+
Py_ssize_t itemsize;
|
|
730
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
731
|
+
PyObject *py_itemsize;
|
|
732
|
+
#endif
|
|
733
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
734
|
+
itemsize = ((PyTypeObject *)base)->tp_itemsize;
|
|
735
|
+
#else
|
|
736
|
+
py_itemsize = PyObject_GetAttrString((PyObject*)base, "__itemsize__");
|
|
737
|
+
if (!py_itemsize)
|
|
738
|
+
return -1;
|
|
739
|
+
itemsize = PyLong_AsSsize_t(py_itemsize);
|
|
740
|
+
Py_DECREF(py_itemsize);
|
|
741
|
+
py_itemsize = 0;
|
|
742
|
+
if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred())
|
|
743
|
+
return -1;
|
|
744
|
+
#endif
|
|
745
|
+
if (itemsize) {
|
|
746
|
+
__Pyx_RaiseErrorWithType(
|
|
747
|
+
PyExc_TypeError,
|
|
748
|
+
"inheritance from PyVarObject types like '" __Pyx_FMT_TYPENAME "' not currently supported", base);
|
|
749
|
+
return -1;
|
|
750
|
+
}
|
|
751
|
+
return 0;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/////////////// CallTypeTraverse.proto /////////////////////
|
|
755
|
+
|
|
756
|
+
#if !CYTHON_USE_TYPE_SPECS
|
|
757
|
+
// Without type specs, we're never responsible for this.
|
|
758
|
+
#define __Pyx_call_type_traverse(o, always_call, visit, arg) 0
|
|
759
|
+
#else
|
|
760
|
+
static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg); /* proto */
|
|
761
|
+
#endif
|
|
762
|
+
|
|
763
|
+
/////////////// CallTypeTraverse ////////////////////////////
|
|
764
|
+
|
|
765
|
+
#if !CYTHON_USE_TYPE_SPECS
|
|
766
|
+
// nothing to do
|
|
767
|
+
#else
|
|
768
|
+
static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) {
|
|
769
|
+
if (!always_call) {
|
|
770
|
+
// Written with reference to https://docs.python.org/3/howto/isolating-extensions.html
|
|
771
|
+
PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*);
|
|
772
|
+
unsigned long flags = PyType_GetFlags(base);
|
|
773
|
+
if (flags & Py_TPFLAGS_HEAPTYPE) {
|
|
774
|
+
// The base class should have handled it
|
|
775
|
+
return 0;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
Py_VISIT((PyObject*)Py_TYPE(o));
|
|
779
|
+
return 0;
|
|
780
|
+
}
|
|
781
|
+
#endif
|
|
782
|
+
|
|
783
|
+
////////////////// GetTypeDictOffset.proto ////////////////
|
|
784
|
+
|
|
785
|
+
#if !CYTHON_USE_TYPE_SLOTS
|
|
786
|
+
CYTHON_UNUSED static Py_ssize_t __Pyx_GetTypeDictOffset(PyObject *tp, int require_cython_valid_result);
|
|
787
|
+
#endif
|
|
788
|
+
|
|
789
|
+
////////////////// GetTypeDictOffset //////////////////////
|
|
790
|
+
|
|
791
|
+
#if !CYTHON_USE_TYPE_SLOTS
|
|
792
|
+
CYTHON_UNUSED static Py_ssize_t __Pyx_GetTypeDictOffset(PyObject *tp, int require_cython_valid_result) {
|
|
793
|
+
PyObject *tp_dictoffset_o;
|
|
794
|
+
Py_ssize_t tp_dictoffset;
|
|
795
|
+
tp_dictoffset_o = PyObject_GetAttrString(tp, "__dictoffset__");
|
|
796
|
+
if (unlikely(!tp_dictoffset_o)) return -1;
|
|
797
|
+
tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o);
|
|
798
|
+
Py_DECREF(tp_dictoffset_o);
|
|
799
|
+
|
|
800
|
+
if (unlikely(require_cython_valid_result && tp_dictoffset == 0)) {
|
|
801
|
+
PyErr_SetString(
|
|
802
|
+
PyExc_TypeError,
|
|
803
|
+
"'type' doesn't have a dictoffset");
|
|
804
|
+
return -1;
|
|
805
|
+
} else if (unlikely(require_cython_valid_result && tp_dictoffset < 0)) {
|
|
806
|
+
// This isn't completely future proof. dictoffset can be
|
|
807
|
+
// negative, but isn't in Python <=3.13 (current at time
|
|
808
|
+
// of writing). It's awkward to calculate in the limited
|
|
809
|
+
// API because we need to know the object size. For now
|
|
810
|
+
// just raise an error and fix it if it every changes.
|
|
811
|
+
PyErr_SetString(
|
|
812
|
+
PyExc_TypeError,
|
|
813
|
+
"'type' has an unexpected negative dictoffset. "
|
|
814
|
+
"Please report this as Cython bug");
|
|
815
|
+
return -1;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
return tp_dictoffset;
|
|
819
|
+
}
|
|
820
|
+
#endif
|
|
821
|
+
|
|
822
|
+
////////////////// LimitedApiGetTypeTypeDict.proto //////////////////////
|
|
823
|
+
|
|
824
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
825
|
+
// This is a little hacky - the Limited API works quite hard to stop us getting
|
|
826
|
+
// the dict of a type object. But apparently not hard enough...
|
|
827
|
+
//
|
|
828
|
+
// In future we should prefer to work with mutable types, and then make them immutable
|
|
829
|
+
// once we're done (pending C API support for this).
|
|
830
|
+
static PyObject *__Pyx_GetTypeTypeDict(PyTypeObject *tp); /* proto */
|
|
831
|
+
#endif
|
|
832
|
+
|
|
833
|
+
////////////////// LimitedApiGetTypeTypeDict //////////////////////
|
|
834
|
+
//@requires: GetTypeDictOffset
|
|
835
|
+
|
|
836
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
837
|
+
static PyObject *__Pyx_GetTypeTypeDict(PyTypeObject *tp) {
|
|
838
|
+
// TODO - if we ever support custom metatypes for extension types then
|
|
839
|
+
// we have to modify this caching.
|
|
840
|
+
static Py_ssize_t tp_dictoffset = 0;
|
|
841
|
+
if (unlikely(tp_dictoffset == 0)) {
|
|
842
|
+
tp_dictoffset = __Pyx_GetTypeDictOffset((PyObject*)(&PyType_Type), 1);
|
|
843
|
+
// Note that negative dictoffsets are definitely allowed.
|
|
844
|
+
// A dictoffset of -1 seems unlikely but isn't obviously forbidden.
|
|
845
|
+
if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) {
|
|
846
|
+
tp_dictoffset = 0; // try again next time?
|
|
847
|
+
return NULL;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return *(PyObject**)((char*)tp + tp_dictoffset);
|
|
851
|
+
}
|
|
852
|
+
#endif
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
////////////////// SetItemOnTypeDict.export //////////////////////////
|
|
856
|
+
|
|
857
|
+
static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v); /* proto */
|
|
858
|
+
|
|
859
|
+
////////////////// SetItemOnTypeDict.proto //////////////////////////
|
|
860
|
+
//@requires: LimitedApiGetTypeTypeDict
|
|
861
|
+
|
|
862
|
+
#define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v)
|
|
863
|
+
|
|
864
|
+
////////////////// SetItemOnTypeDict //////////////////////////
|
|
865
|
+
|
|
866
|
+
static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) {
|
|
867
|
+
int result;
|
|
868
|
+
PyObject *tp_dict;
|
|
869
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
870
|
+
tp_dict = __Pyx_GetTypeTypeDict(tp);
|
|
871
|
+
if (unlikely(!tp_dict)) return -1;
|
|
872
|
+
#else
|
|
873
|
+
tp_dict = tp->tp_dict;
|
|
874
|
+
#endif
|
|
875
|
+
result = PyDict_SetItem(tp_dict, k, v);
|
|
876
|
+
if (likely(!result)) {
|
|
877
|
+
PyType_Modified(tp);
|
|
878
|
+
if (unlikely(PyObject_HasAttr(v, PYIDENT("__set_name__")))) {
|
|
879
|
+
PyObject *setNameResult = PyObject_CallMethodObjArgs(v, PYIDENT("__set_name__"), (PyObject *) tp, k, NULL);
|
|
880
|
+
if (!setNameResult) return -1;
|
|
881
|
+
Py_DECREF(setNameResult);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return result;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
////////////////// DelItemOnTypeDict.export //////////////////////////
|
|
888
|
+
|
|
889
|
+
static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k); /* proto */
|
|
890
|
+
|
|
891
|
+
////////////////// DelItemOnTypeDict.proto //////////////////////////
|
|
892
|
+
|
|
893
|
+
#define __Pyx_DelItemOnTypeDict(tp, k) __Pyx__DelItemOnTypeDict((PyTypeObject*)tp, k)
|
|
894
|
+
|
|
895
|
+
////////////////// DelItemOnTypeDict //////////////////////////
|
|
896
|
+
//@requires: LimitedApiGetTypeTypeDict
|
|
897
|
+
|
|
898
|
+
static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k) {
|
|
899
|
+
int result;
|
|
900
|
+
PyObject *tp_dict;
|
|
901
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
902
|
+
tp_dict = __Pyx_GetTypeTypeDict(tp);
|
|
903
|
+
if (unlikely(!tp_dict)) return -1;
|
|
904
|
+
#else
|
|
905
|
+
tp_dict = tp->tp_dict;
|
|
906
|
+
#endif
|
|
907
|
+
result = PyDict_DelItem(tp_dict, k);
|
|
908
|
+
if (likely(!result)) PyType_Modified(tp);
|
|
909
|
+
return result;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
////////////////// AllocateExtensionType.proto ///////////////////////
|
|
913
|
+
|
|
914
|
+
static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); /* proto */
|
|
915
|
+
|
|
916
|
+
////////////////// AllocateExtensionType ////////////////////////////
|
|
917
|
+
|
|
918
|
+
static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) {
|
|
919
|
+
if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) {
|
|
920
|
+
allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc);
|
|
921
|
+
return alloc_func(t, 0);
|
|
922
|
+
} else {
|
|
923
|
+
// Call PyBaseObject_Type.tp_new. This is is expected to fail, generating an appropriate
|
|
924
|
+
// error message about allocating an abstract type.
|
|
925
|
+
newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc);
|
|
926
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
927
|
+
if (!tp_new) {
|
|
928
|
+
PyObject *new_str = PyUnicode_FromString("__new__");
|
|
929
|
+
if (likely(new_str)) {
|
|
930
|
+
PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL);
|
|
931
|
+
Py_DECREF(new_str);
|
|
932
|
+
return o;
|
|
933
|
+
} else
|
|
934
|
+
return NULL;
|
|
935
|
+
} else
|
|
936
|
+
#endif
|
|
937
|
+
return tp_new(t, EMPTY(tuple), 0);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
///////////////////// CheckTypeForFreelists.proto ////////////////////////
|
|
942
|
+
|
|
943
|
+
#if CYTHON_USE_FREELISTS
|
|
944
|
+
#if CYTHON_USE_TYPE_SPECS
|
|
945
|
+
// with CYTHON_USE_TYPE_SPECS we can only reasonably use freelists for an exact type match,
|
|
946
|
+
// because it isn't easy to look up basicsize is the limited API, and because everything fails the heap-type check.
|
|
947
|
+
#define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t) == (expected_tp)))
|
|
948
|
+
#define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS Py_TPFLAGS_IS_ABSTRACT
|
|
949
|
+
#else
|
|
950
|
+
#define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t)->tp_basicsize == (expected_size)))
|
|
951
|
+
#define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)
|
|
952
|
+
#endif
|
|
953
|
+
|
|
954
|
+
#define __PYX_CHECK_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) \
|
|
955
|
+
(__PYX_CHECK_FINAL_TYPE_FOR_FREELISTS((t), (expected_tp), (expected_size)) & \
|
|
956
|
+
(int) (!__Pyx_PyType_HasFeature((t), __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS)))
|
|
957
|
+
#endif
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
////////////////// ClearFreelist.proto ///////////////////////
|
|
961
|
+
|
|
962
|
+
#if CYTHON_USE_FREELISTS
|
|
963
|
+
static void __Pyx_ClearFreelist(PyObject **freelist, int *count); /* proto */
|
|
964
|
+
#endif
|
|
965
|
+
|
|
966
|
+
////////////////// ClearFreelist ////////////////////////////
|
|
967
|
+
|
|
968
|
+
#if CYTHON_USE_FREELISTS
|
|
969
|
+
static void __Pyx_ClearFreelist(PyObject **freelist, int *count) {
|
|
970
|
+
while (*count > 0) {
|
|
971
|
+
PyObject* o = freelist[--*count];
|
|
972
|
+
PyTypeObject *tp = Py_TYPE(o);
|
|
973
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
974
|
+
(*tp->tp_free)(o);
|
|
975
|
+
#else
|
|
976
|
+
// Asking for PyType_GetSlot(..., Py_tp_free) seems to cause an error in pypy.
|
|
977
|
+
freefunc tp_free = (freefunc) PyType_GetSlot(tp, Py_tp_free);
|
|
978
|
+
if (tp_free) tp_free(o);
|
|
979
|
+
#endif
|
|
980
|
+
#if CYTHON_USE_TYPE_SPECS
|
|
981
|
+
// Release the reference that "o" owned for its type.
|
|
982
|
+
Py_DECREF(tp);
|
|
983
|
+
#endif
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
#endif
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
/////////////////// ApplySequenceOrMappingFlag.proto //////////////////////
|
|
990
|
+
|
|
991
|
+
#if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
|
|
992
|
+
int __Pyx_ApplySequenceOrMappingFlag(PyTypeObject *tp, int is_sequence);
|
|
993
|
+
#else
|
|
994
|
+
// No-op - the type flag is sufficient.
|
|
995
|
+
#define __Pyx_ApplySequenceOrMappingFlag(tp, is_sequence) (0)
|
|
996
|
+
#endif
|
|
997
|
+
|
|
998
|
+
/////////////////// ApplySequenceOrMappingFlag //////////////////////
|
|
999
|
+
|
|
1000
|
+
#if CYTHON_COMPILING_IN_LIMITED_API || (CYTHON_COMPILING_IN_PYPY && CYTHON_USE_TYPE_SPECS)
|
|
1001
|
+
int __Pyx_ApplySequenceOrMappingFlag(PyTypeObject *tp, int is_sequence) {
|
|
1002
|
+
PyObject *abc;
|
|
1003
|
+
PyObject *collections_abc = PyImport_ImportModule("collections.abc");
|
|
1004
|
+
if (unlikely(!collections_abc)) return -1;
|
|
1005
|
+
abc = PyObject_GetAttrString(collections_abc, is_sequence ? "Sequence": "Mapping");
|
|
1006
|
+
Py_DECREF(collections_abc);
|
|
1007
|
+
if (unlikely(!abc)) return -1;
|
|
1008
|
+
|
|
1009
|
+
PyObject *register_result = PyObject_CallMethod(abc, "register", "O", (PyObject*)tp);
|
|
1010
|
+
Py_DECREF(abc);
|
|
1011
|
+
if (unlikely(!register_result)) return -1;
|
|
1012
|
+
Py_DECREF(register_result);
|
|
1013
|
+
return 0;
|
|
1014
|
+
}
|
|
1015
|
+
#elif CYTHON_COMPILING_IN_PYPY // && !CYTHON_USE_TYPE_SPECS
|
|
1016
|
+
int __Pyx_ApplySequenceOrMappingFlag(PyTypeObject *tp, int is_sequence) {
|
|
1017
|
+
CYTHON_UNUSED_VAR(tp);
|
|
1018
|
+
CYTHON_UNUSED_VAR(is_sequence);
|
|
1019
|
+
return PyErr_WarnEx(
|
|
1020
|
+
PyExc_RuntimeWarning,
|
|
1021
|
+
"cython.collection_type only works on PyPy with the C flag CYTHON_USE_TYPE_SPECS=1",
|
|
1022
|
+
1
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
#endif
|
|
1026
|
+
|
|
1027
|
+
////////////////////////////// CallNewInitFromVectorcall.proto //////////////////////
|
|
1028
|
+
|
|
1029
|
+
#if CYTHON_VECTORCALL_TPNEW
|
|
1030
|
+
static PyObject *__Pyx_CallNewInitFromVectorcall(PyTypeObject *t, PyObject *const *args, size_t nargsf, PyObject *kwnames); /* proto */
|
|
1031
|
+
#endif
|
|
1032
|
+
|
|
1033
|
+
////////////////////////////// CallNewInitFromVectorcall //////////////////////
|
|
1034
|
+
//@requires: ObjectHandling.c::TupleFromArray
|
|
1035
|
+
//@requires: ObjectHandling.c::RaiseErrorWithObjectType
|
|
1036
|
+
|
|
1037
|
+
#if CYTHON_VECTORCALL_TPNEW
|
|
1038
|
+
static PyObject *__Pyx_CallNewInitFromVectorcall(PyTypeObject *t, PyObject *const *args, size_t nargsf, PyObject *kwnames) {
|
|
1039
|
+
newfunc tp_new = __Pyx_PyType_GetSlot(t, tp_new, newfunc);
|
|
1040
|
+
if (unlikely(!tp_new)) {
|
|
1041
|
+
__Pyx_RaiseErrorWithType(PyExc_TypeError, "cannot create " __Pyx_FMT_TYPENAME " instances", t);
|
|
1042
|
+
return NULL;
|
|
1043
|
+
}
|
|
1044
|
+
Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(nargsf);
|
|
1045
|
+
|
|
1046
|
+
PyObject *result = NULL, *args_tuple = NULL, *kwds_dict = NULL;
|
|
1047
|
+
Py_ssize_t kw_size = kwnames ? __Pyx_PyTuple_GET_SIZE(kwnames) : 0;
|
|
1048
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
1049
|
+
if (unlikely(kw_size == -1)) {
|
|
1050
|
+
return NULL;
|
|
1051
|
+
}
|
|
1052
|
+
#endif
|
|
1053
|
+
if (kw_size) {
|
|
1054
|
+
kwds_dict = __Pyx_PyDict_NewPresized(kw_size);
|
|
1055
|
+
if (unlikely(!kwds_dict)) {
|
|
1056
|
+
return NULL;
|
|
1057
|
+
}
|
|
1058
|
+
for (Py_ssize_t i=0; i<kw_size; ++i) {
|
|
1059
|
+
PyObject *v = args[nargs + i];
|
|
1060
|
+
PyObject *k = __Pyx_PyTuple_GET_ITEM(kwnames, i);
|
|
1061
|
+
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
1062
|
+
if (unlikely(!k)) {
|
|
1063
|
+
goto end;
|
|
1064
|
+
}
|
|
1065
|
+
#endif
|
|
1066
|
+
|
|
1067
|
+
if (unlikely(PyDict_SetItem(kwds_dict, k, v) < 0)) {
|
|
1068
|
+
goto end;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
if (nargs) {
|
|
1074
|
+
args_tuple = __Pyx_PyTuple_FromArray(args, nargs);
|
|
1075
|
+
if (unlikely(!args_tuple)) {
|
|
1076
|
+
goto end;
|
|
1077
|
+
}
|
|
1078
|
+
} else {
|
|
1079
|
+
args_tuple = __Pyx_NewRef(EMPTY(tuple));
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
result = tp_new(t, args_tuple, kwds_dict);
|
|
1083
|
+
if (unlikely(!result)) {
|
|
1084
|
+
goto end;
|
|
1085
|
+
}
|
|
1086
|
+
if (PyObject_TypeCheck(result, t)) {
|
|
1087
|
+
initproc tp_init = __Pyx_PyObject_GetSlot(result, tp_init, initproc);
|
|
1088
|
+
if (tp_init && unlikely(tp_init(result, args_tuple, kwds_dict) < 0)) {
|
|
1089
|
+
Py_CLEAR(result);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
end:
|
|
1093
|
+
Py_XDECREF(args_tuple);
|
|
1094
|
+
Py_XDECREF(kwds_dict);
|
|
1095
|
+
return result;
|
|
1096
|
+
}
|
|
1097
|
+
#endif
|
|
1098
|
+
|
|
1099
|
+
///////////////////////// CallSlotAsVectorcall.proto ////////////////////////////////////
|
|
1100
|
+
|
|
1101
|
+
#if CYTHON_VECTORCALL_TPNEW
|
|
1102
|
+
typedef {{ret_type}} (*__Pyx_{{name}}vectorcallfunc)({{obj_type}} o, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames);
|
|
1103
|
+
static {{ret_type}} __Pyx_Call{{name.title()}}AsVectorcall(__Pyx_{{name}}vectorcallfunc f, {{obj_type}} o, PyObject *a, PyObject *k);
|
|
1104
|
+
#endif
|
|
1105
|
+
|
|
1106
|
+
///////////////////////// CallSlotAsVectorcall ////////////////////////////////////
|
|
1107
|
+
//@requires: Synchronization.c::CriticalSections
|
|
1108
|
+
//@requires: CallSlotAsVectorcallUnpackDict
|
|
1109
|
+
|
|
1110
|
+
// Possible TODO - the !ASSUME_SAFE_MACROS case is inefficient due to a lot of
|
|
1111
|
+
// error checking, and the inability to optimize the common no-keywords case.
|
|
1112
|
+
// I think it might be possible to use a trampoline type and PyVectorcall_Call to
|
|
1113
|
+
// push this work into the Python interpreter (where they have access to the full C API).
|
|
1114
|
+
#if CYTHON_VECTORCALL_TPNEW
|
|
1115
|
+
static {{ret_type}} __Pyx_Call{{name.title()}}AsVectorcall(__Pyx_{{name}}vectorcallfunc f, {{obj_type}} o, PyObject *a, PyObject *k) {
|
|
1116
|
+
Py_ssize_t k_size = k ? __Pyx_PyDict_GET_SIZE(k) : 0;
|
|
1117
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
1118
|
+
if (unlikely(k_size < 0)) return {{error_value}};
|
|
1119
|
+
#endif
|
|
1120
|
+
Py_ssize_t a_size = __Pyx_PyTuple_GET_SIZE(a);
|
|
1121
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
1122
|
+
if (unlikely(a_size < 0)) return {{error_value}};
|
|
1123
|
+
#endif
|
|
1124
|
+
#if CYTHON_ASSUME_SAFE_MACROS
|
|
1125
|
+
if (k_size == 0) {
|
|
1126
|
+
return f(o, &PyTuple_GET_ITEM(a, 0), a_size, NULL);
|
|
1127
|
+
}
|
|
1128
|
+
#else
|
|
1129
|
+
if (k_size == 0 && a_size == 0) {
|
|
1130
|
+
return f(o, NULL, 0, NULL);
|
|
1131
|
+
}
|
|
1132
|
+
#endif
|
|
1133
|
+
PyObject *stack_args[5];
|
|
1134
|
+
PyObject **args = stack_args;
|
|
1135
|
+
Py_ssize_t maxnargs = PY_SSIZE_T_MAX / sizeof(PyObject*) - 1;
|
|
1136
|
+
if (a_size > maxnargs - k_size) {
|
|
1137
|
+
PyErr_NoMemory();
|
|
1138
|
+
return {{error_value}};
|
|
1139
|
+
}
|
|
1140
|
+
Py_ssize_t total_size = a_size + k_size;
|
|
1141
|
+
if (total_size > 5) {
|
|
1142
|
+
args = (PyObject**)PyMem_Malloc(((size_t)total_size)*sizeof(PyObject*));
|
|
1143
|
+
if (unlikely(!args)) {
|
|
1144
|
+
PyErr_NoMemory();
|
|
1145
|
+
return {{error_value}};
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
{{ret_type}} result = {{error_value}};
|
|
1149
|
+
PyObject *kwnames = NULL;
|
|
1150
|
+
int unpack_dict_result;
|
|
1151
|
+
Py_ssize_t i = 0;
|
|
1152
|
+
for (; i < a_size; ++i) {
|
|
1153
|
+
args[i] = __Pyx_PyTuple_GET_ITEM(a, i);
|
|
1154
|
+
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
1155
|
+
if (unlikely(!args[i])) goto cleanup;
|
|
1156
|
+
#endif
|
|
1157
|
+
}
|
|
1158
|
+
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
1159
|
+
if (k) // There's a specific shortcut earlier for ASSUME_SAFE_MACROS with no keywords
|
|
1160
|
+
#endif
|
|
1161
|
+
{
|
|
1162
|
+
kwnames = PyTuple_New(k_size);
|
|
1163
|
+
if (unlikely(!kwnames)) goto cleanup;
|
|
1164
|
+
__Pyx_BEGIN_CRITICAL_SECTION(k);
|
|
1165
|
+
unpack_dict_result = __Pyx_CallSlotAsVectorcallUnpackDict(a_size, k, args, kwnames);
|
|
1166
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
1167
|
+
if (unlikely(unpack_dict_result == -1)) goto cleanup;
|
|
1168
|
+
}
|
|
1169
|
+
result = f(o, args, a_size, kwnames);
|
|
1170
|
+
cleanup:
|
|
1171
|
+
Py_XDECREF(kwnames);
|
|
1172
|
+
for (i=a_size; i<total_size; ++i) {
|
|
1173
|
+
Py_XDECREF(args[i]);
|
|
1174
|
+
}
|
|
1175
|
+
if (args != stack_args) {
|
|
1176
|
+
PyMem_Free(args);
|
|
1177
|
+
}
|
|
1178
|
+
return result;
|
|
1179
|
+
}
|
|
1180
|
+
#endif
|
|
1181
|
+
|
|
1182
|
+
///////////////////////// CallSlotAsVectorcallUnpackDict ////////////////////////////////////
|
|
1183
|
+
|
|
1184
|
+
static CYTHON_INLINE int __Pyx_CallSlotAsVectorcallUnpackDict(Py_ssize_t args_size, PyObject *keys_dict, PyObject **args, PyObject *kwnames) {
|
|
1185
|
+
Py_ssize_t pos = 0, i = 0;
|
|
1186
|
+
PyObject *key, *value;
|
|
1187
|
+
while (PyDict_Next(keys_dict, &pos, &key, &value)) {
|
|
1188
|
+
Py_INCREF(value);
|
|
1189
|
+
args[args_size+i] = value;
|
|
1190
|
+
Py_INCREF(key);
|
|
1191
|
+
if (unlikely(__Pyx_PyTuple_SET_ITEM(kwnames, i, key) == -1)) {
|
|
1192
|
+
return -1;
|
|
1193
|
+
}
|
|
1194
|
+
// CPython puts a check that the key is a string here. Cython skips this
|
|
1195
|
+
// because it's checked later in our function wrappers.
|
|
1196
|
+
++i;
|
|
1197
|
+
}
|
|
1198
|
+
return 0;
|
|
1199
|
+
}
|