Cython 3.2.0__cp39-abi3-win32.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 +169 -0
- Cython/Build/Cache.py +199 -0
- Cython/Build/Cythonize.py +350 -0
- Cython/Build/Dependencies.py +1314 -0
- Cython/Build/Distutils.py +1 -0
- Cython/Build/Inline.py +463 -0
- Cython/Build/IpythonMagic.py +560 -0
- Cython/Build/SharedModule.py +94 -0
- Cython/Build/Tests/TestCyCache.py +194 -0
- Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
- Cython/Build/Tests/TestDependencies.py +133 -0
- Cython/Build/Tests/TestInline.py +177 -0
- Cython/Build/Tests/TestIpythonMagic.py +287 -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 +815 -0
- Cython/Compiler/AnalysedTreeTransforms.py +97 -0
- Cython/Compiler/Annotate.py +328 -0
- Cython/Compiler/AutoDocTransforms.py +320 -0
- Cython/Compiler/Buffer.py +680 -0
- Cython/Compiler/Builtin.py +984 -0
- Cython/Compiler/CmdLine.py +263 -0
- Cython/Compiler/Code.pxd +149 -0
- Cython/Compiler/Code.py +3746 -0
- Cython/Compiler/Code.pyd +0 -0
- Cython/Compiler/CodeGeneration.py +33 -0
- Cython/Compiler/CythonScope.py +191 -0
- Cython/Compiler/Dataclass.py +864 -0
- Cython/Compiler/DebugFlags.py +24 -0
- Cython/Compiler/Errors.py +297 -0
- Cython/Compiler/ExprNodes.py +15562 -0
- Cython/Compiler/FlowControl.pxd +97 -0
- Cython/Compiler/FlowControl.py +1451 -0
- Cython/Compiler/FlowControl.pyd +0 -0
- Cython/Compiler/FusedNode.py +971 -0
- Cython/Compiler/FusedNode.pyd +0 -0
- Cython/Compiler/Future.py +16 -0
- Cython/Compiler/Interpreter.py +57 -0
- Cython/Compiler/Lexicon.py +421 -0
- Cython/Compiler/LineTable.py +114 -0
- Cython/Compiler/LineTable.pyd +0 -0
- Cython/Compiler/Main.py +857 -0
- Cython/Compiler/MatchCaseNodes.py +259 -0
- Cython/Compiler/MemoryView.py +905 -0
- Cython/Compiler/ModuleNode.py +4235 -0
- Cython/Compiler/Naming.py +363 -0
- Cython/Compiler/Nodes.py +10831 -0
- Cython/Compiler/Optimize.py +5288 -0
- Cython/Compiler/Options.py +843 -0
- Cython/Compiler/ParseTreeTransforms.pxd +78 -0
- Cython/Compiler/ParseTreeTransforms.py +4638 -0
- Cython/Compiler/Parsing.pxd +9 -0
- Cython/Compiler/Parsing.py +4775 -0
- Cython/Compiler/Parsing.pyd +0 -0
- Cython/Compiler/Pipeline.py +439 -0
- Cython/Compiler/PyrexTypes.py +5870 -0
- Cython/Compiler/Pythran.py +232 -0
- Cython/Compiler/Scanning.pxd +48 -0
- Cython/Compiler/Scanning.py +701 -0
- Cython/Compiler/Scanning.pyd +0 -0
- Cython/Compiler/StringEncoding.py +298 -0
- Cython/Compiler/Symtab.py +3073 -0
- Cython/Compiler/Tests/TestBuffer.py +105 -0
- Cython/Compiler/Tests/TestBuiltin.py +72 -0
- Cython/Compiler/Tests/TestCmdLine.py +586 -0
- Cython/Compiler/Tests/TestCode.py +144 -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 +134 -0
- Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
- Cython/Compiler/Tests/TestStringEncoding.py +21 -0
- Cython/Compiler/Tests/TestTreeFragment.py +63 -0
- Cython/Compiler/Tests/TestTreePath.py +103 -0
- Cython/Compiler/Tests/TestTypes.py +75 -0
- Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
- Cython/Compiler/Tests/TestVisitor.py +61 -0
- Cython/Compiler/Tests/Utils.py +36 -0
- Cython/Compiler/Tests/__init__.py +1 -0
- Cython/Compiler/TreeFragment.py +278 -0
- Cython/Compiler/TreePath.py +303 -0
- Cython/Compiler/TypeInference.py +591 -0
- Cython/Compiler/TypeSlots.py +1174 -0
- Cython/Compiler/UFuncs.py +311 -0
- Cython/Compiler/UtilNodes.py +389 -0
- Cython/Compiler/UtilityCode.py +344 -0
- Cython/Compiler/Version.py +8 -0
- Cython/Compiler/Visitor.pxd +53 -0
- Cython/Compiler/Visitor.py +861 -0
- Cython/Compiler/Visitor.pyd +0 -0
- Cython/Compiler/__init__.py +1 -0
- Cython/Coverage.py +448 -0
- Cython/Debugger/Cygdb.py +177 -0
- Cython/Debugger/DebugWriter.py +82 -0
- Cython/Debugger/Tests/TestLibCython.py +275 -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 +578 -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 +139 -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 +178 -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 +187 -0
- Cython/Includes/cpython/exc.pxd +263 -0
- Cython/Includes/cpython/fileobject.pxd +57 -0
- Cython/Includes/cpython/float.pxd +47 -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 +92 -0
- Cython/Includes/cpython/long.pxd +149 -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 +433 -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/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 +53 -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/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 +86 -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/Plex/Actions.pxd +24 -0
- Cython/Plex/Actions.py +119 -0
- Cython/Plex/Actions.pyd +0 -0
- Cython/Plex/DFA.pxd +14 -0
- Cython/Plex/DFA.py +164 -0
- Cython/Plex/DFA.pyd +0 -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/Machines.pyd +0 -0
- Cython/Plex/Regexps.py +535 -0
- Cython/Plex/Scanners.pxd +45 -0
- Cython/Plex/Scanners.py +328 -0
- Cython/Plex/Scanners.pyd +0 -0
- Cython/Plex/Transitions.pxd +14 -0
- Cython/Plex/Transitions.py +239 -0
- Cython/Plex/Transitions.pyd +0 -0
- Cython/Plex/__init__.py +34 -0
- Cython/Runtime/__init__.py +1 -0
- Cython/Runtime/refnanny.pyd +0 -0
- Cython/Runtime/refnanny.pyx +237 -0
- Cython/Shadow.py +690 -0
- Cython/Shadow.pyi +521 -0
- Cython/StringIOTree.py +170 -0
- Cython/StringIOTree.pyd +0 -0
- Cython/Tempita/__init__.py +4 -0
- Cython/Tempita/_looper.py +154 -0
- Cython/Tempita/_tempita.py +1091 -0
- Cython/Tempita/_tempita.pyd +0 -0
- Cython/TestUtils.py +422 -0
- Cython/Tests/TestCodeWriter.py +128 -0
- Cython/Tests/TestCythonUtils.py +202 -0
- Cython/Tests/TestJediTyper.py +223 -0
- Cython/Tests/TestShadow.py +114 -0
- Cython/Tests/TestStringIOTree.py +67 -0
- Cython/Tests/TestTestUtils.py +90 -0
- Cython/Tests/__init__.py +1 -0
- Cython/Tests/xmlrunner.py +390 -0
- Cython/Utility/AsyncGen.c +1031 -0
- Cython/Utility/Buffer.c +865 -0
- Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
- Cython/Utility/Builtins.c +810 -0
- Cython/Utility/CConvert.pyx +134 -0
- Cython/Utility/CMath.c +104 -0
- Cython/Utility/CommonStructures.c +226 -0
- Cython/Utility/Complex.c +378 -0
- Cython/Utility/Coroutine.c +2300 -0
- Cython/Utility/CpdefEnums.pyx +103 -0
- Cython/Utility/CppConvert.pyx +282 -0
- Cython/Utility/CppSupport.cpp +151 -0
- Cython/Utility/CythonFunction.c +1832 -0
- Cython/Utility/Dataclasses.c +101 -0
- Cython/Utility/Embed.c +121 -0
- Cython/Utility/Exceptions.c +1016 -0
- Cython/Utility/ExtensionTypes.c +996 -0
- Cython/Utility/FunctionArguments.c +1043 -0
- Cython/Utility/FusedFunction.pyx +44 -0
- Cython/Utility/ImportExport.c +907 -0
- Cython/Utility/MemoryView.pxd +188 -0
- Cython/Utility/MemoryView.pyx +1482 -0
- Cython/Utility/MemoryView_C.c +927 -0
- Cython/Utility/ModuleSetupCode.c +3203 -0
- Cython/Utility/NumpyImportArray.c +46 -0
- Cython/Utility/ObjectHandling.c +3273 -0
- Cython/Utility/Optimize.c +1603 -0
- Cython/Utility/Overflow.c +384 -0
- Cython/Utility/Printing.c +86 -0
- Cython/Utility/Profile.c +732 -0
- Cython/Utility/StringTools.c +1379 -0
- Cython/Utility/Synchronization.c +399 -0
- Cython/Utility/TString.c +356 -0
- Cython/Utility/TestCyUtilityLoader.pyx +8 -0
- Cython/Utility/TestCythonScope.pyx +75 -0
- Cython/Utility/TestUtilityLoader.c +12 -0
- Cython/Utility/TypeConversion.c +1385 -0
- Cython/Utility/UFuncs.pyx +50 -0
- Cython/Utility/UFuncs_C.c +89 -0
- Cython/Utility/__init__.py +28 -0
- Cython/Utility/arrayarray.h +167 -0
- Cython/Utils.py +687 -0
- Cython/Utils.pyd +0 -0
- Cython/__init__.py +10 -0
- Cython/__init__.pyi +7 -0
- Cython/py.typed +0 -0
- cython-3.2.0.dist-info/METADATA +85 -0
- cython-3.2.0.dist-info/RECORD +333 -0
- cython-3.2.0.dist-info/WHEEL +5 -0
- cython-3.2.0.dist-info/entry_points.txt +4 -0
- cython-3.2.0.dist-info/top_level.txt +3 -0
- cython.py +29 -0
- pyximport/__init__.py +4 -0
- pyximport/pyxbuild.py +160 -0
- pyximport/pyximport.py +482 -0
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
/////////////// FixUpExtensionType.proto ///////////////
|
|
2
|
+
|
|
3
|
+
static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); /*proto*/
|
|
4
|
+
|
|
5
|
+
/////////////// FixUpExtensionType ///////////////
|
|
6
|
+
//@requires:ModuleSetupCode.c::IncludeStructmemberH
|
|
7
|
+
//@requires:StringTools.c::IncludeStringH
|
|
8
|
+
//@requires:SetItemOnTypeDict
|
|
9
|
+
|
|
10
|
+
static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) {
|
|
11
|
+
#if __PYX_LIMITED_VERSION_HEX > 0x030900B1
|
|
12
|
+
CYTHON_UNUSED_VAR(spec);
|
|
13
|
+
CYTHON_UNUSED_VAR(type);
|
|
14
|
+
CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
|
|
15
|
+
#else
|
|
16
|
+
// Set tp_weakreflist, tp_dictoffset, tp_vectorcalloffset
|
|
17
|
+
// Copied and adapted from https://bugs.python.org/issue38140
|
|
18
|
+
const PyType_Slot *slot = spec->slots;
|
|
19
|
+
int changed = 0;
|
|
20
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
21
|
+
while (slot && slot->slot && slot->slot != Py_tp_members)
|
|
22
|
+
slot++;
|
|
23
|
+
if (slot && slot->slot == Py_tp_members) {
|
|
24
|
+
#if !CYTHON_COMPILING_IN_CPYTHON
|
|
25
|
+
const
|
|
26
|
+
#endif // !CYTHON_COMPILING_IN_CPYTHON)
|
|
27
|
+
PyMemberDef *memb = (PyMemberDef*) slot->pfunc;
|
|
28
|
+
while (memb && memb->name) {
|
|
29
|
+
if (memb->name[0] == '_' && memb->name[1] == '_') {
|
|
30
|
+
if (strcmp(memb->name, "__weaklistoffset__") == 0) {
|
|
31
|
+
// The PyMemberDef must be a Py_ssize_t and readonly.
|
|
32
|
+
assert(memb->type == T_PYSSIZET);
|
|
33
|
+
assert(memb->flags == READONLY);
|
|
34
|
+
type->tp_weaklistoffset = memb->offset;
|
|
35
|
+
// FIXME: is it even worth calling PyType_Modified() here?
|
|
36
|
+
changed = 1;
|
|
37
|
+
}
|
|
38
|
+
else if (strcmp(memb->name, "__dictoffset__") == 0) {
|
|
39
|
+
// The PyMemberDef must be a Py_ssize_t and readonly.
|
|
40
|
+
assert(memb->type == T_PYSSIZET);
|
|
41
|
+
assert(memb->flags == READONLY);
|
|
42
|
+
type->tp_dictoffset = memb->offset;
|
|
43
|
+
// FIXME: is it even worth calling PyType_Modified() here?
|
|
44
|
+
changed = 1;
|
|
45
|
+
}
|
|
46
|
+
#if CYTHON_METH_FASTCALL
|
|
47
|
+
else if (strcmp(memb->name, "__vectorcalloffset__") == 0) {
|
|
48
|
+
// The PyMemberDef must be a Py_ssize_t and readonly.
|
|
49
|
+
assert(memb->type == T_PYSSIZET);
|
|
50
|
+
assert(memb->flags == READONLY);
|
|
51
|
+
type->tp_vectorcall_offset = memb->offset;
|
|
52
|
+
// FIXME: is it even worth calling PyType_Modified() here?
|
|
53
|
+
changed = 1;
|
|
54
|
+
}
|
|
55
|
+
#endif // CYTHON_METH_FASTCALL
|
|
56
|
+
#if !CYTHON_COMPILING_IN_PYPY
|
|
57
|
+
else if (strcmp(memb->name, "__module__") == 0) {
|
|
58
|
+
// PyType_FromSpec() in CPython <= 3.9b1 overwrites this field with a constant string.
|
|
59
|
+
// See https://bugs.python.org/issue40703
|
|
60
|
+
PyObject *descr;
|
|
61
|
+
// The PyMemberDef must be an object and normally readable, possibly writable.
|
|
62
|
+
assert(memb->type == T_OBJECT);
|
|
63
|
+
assert(memb->flags == 0 || memb->flags == READONLY);
|
|
64
|
+
descr = PyDescr_NewMember(type, memb);
|
|
65
|
+
if (unlikely(!descr))
|
|
66
|
+
return -1;
|
|
67
|
+
int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
|
|
68
|
+
Py_DECREF(descr);
|
|
69
|
+
if (unlikely(set_item_result < 0)) {
|
|
70
|
+
return -1;
|
|
71
|
+
}
|
|
72
|
+
changed = 1;
|
|
73
|
+
}
|
|
74
|
+
#endif // !CYTHON_COMPILING_IN_PYPY
|
|
75
|
+
}
|
|
76
|
+
memb++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
#endif // !CYTHON_COMPILING_IN_LIMITED_API
|
|
80
|
+
#if !CYTHON_COMPILING_IN_PYPY
|
|
81
|
+
slot = spec->slots;
|
|
82
|
+
while (slot && slot->slot && slot->slot != Py_tp_getset)
|
|
83
|
+
slot++;
|
|
84
|
+
if (slot && slot->slot == Py_tp_getset) {
|
|
85
|
+
PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc;
|
|
86
|
+
while (getset && getset->name) {
|
|
87
|
+
if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) {
|
|
88
|
+
PyObject *descr = PyDescr_NewGetSet(type, getset);
|
|
89
|
+
if (unlikely(!descr))
|
|
90
|
+
return -1;
|
|
91
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
92
|
+
PyObject *pyname = PyUnicode_FromString(getset->name);
|
|
93
|
+
if (unlikely(!pyname)) {
|
|
94
|
+
Py_DECREF(descr);
|
|
95
|
+
return -1;
|
|
96
|
+
}
|
|
97
|
+
int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr);
|
|
98
|
+
Py_DECREF(pyname);
|
|
99
|
+
#else
|
|
100
|
+
CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
|
|
101
|
+
int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
|
|
102
|
+
#endif
|
|
103
|
+
Py_DECREF(descr);
|
|
104
|
+
if (unlikely(set_item_result < 0)) {
|
|
105
|
+
return -1;
|
|
106
|
+
}
|
|
107
|
+
changed = 1;
|
|
108
|
+
}
|
|
109
|
+
++getset;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
#else
|
|
113
|
+
CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
|
|
114
|
+
#endif // !CYTHON_COMPILING_IN_PYPY
|
|
115
|
+
if (changed)
|
|
116
|
+
PyType_Modified(type);
|
|
117
|
+
#endif // PY_VERSION_HEX > 0x030900B1
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
/////////////// ValidateBasesTuple.proto ///////////////
|
|
123
|
+
|
|
124
|
+
#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
|
|
125
|
+
static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases); /*proto*/
|
|
126
|
+
#endif
|
|
127
|
+
|
|
128
|
+
/////////////// ValidateBasesTuple ///////////////
|
|
129
|
+
|
|
130
|
+
#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
|
|
131
|
+
static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) {
|
|
132
|
+
// Loop over all bases (except the first) and check that those
|
|
133
|
+
// really are heap types. Otherwise, it would not be safe to
|
|
134
|
+
// subclass them.
|
|
135
|
+
//
|
|
136
|
+
// We also check tp_dictoffset: it is unsafe to inherit
|
|
137
|
+
// tp_dictoffset from a base class because the object structures
|
|
138
|
+
// would not be compatible. So, if our extension type doesn't set
|
|
139
|
+
// tp_dictoffset (i.e. there is no __dict__ attribute in the object
|
|
140
|
+
// structure), we need to check that none of the base classes sets
|
|
141
|
+
// it either.
|
|
142
|
+
Py_ssize_t i, n;
|
|
143
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
144
|
+
n = PyTuple_GET_SIZE(bases);
|
|
145
|
+
#else
|
|
146
|
+
n = PyTuple_Size(bases);
|
|
147
|
+
if (unlikely(n < 0)) return -1;
|
|
148
|
+
#endif
|
|
149
|
+
for (i = 1; i < n; i++) /* Skip first base */
|
|
150
|
+
{
|
|
151
|
+
PyTypeObject *b;
|
|
152
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
153
|
+
PyObject *b0 = PySequence_GetItem(bases, i);
|
|
154
|
+
if (!b0) return -1;
|
|
155
|
+
#elif CYTHON_ASSUME_SAFE_MACROS
|
|
156
|
+
PyObject *b0 = PyTuple_GET_ITEM(bases, i);
|
|
157
|
+
#else
|
|
158
|
+
PyObject *b0 = PyTuple_GetItem(bases, i);
|
|
159
|
+
if (!b0) return -1;
|
|
160
|
+
#endif
|
|
161
|
+
b = (PyTypeObject*) b0;
|
|
162
|
+
if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
|
|
163
|
+
{
|
|
164
|
+
__Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
|
|
165
|
+
PyErr_Format(PyExc_TypeError,
|
|
166
|
+
"base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name);
|
|
167
|
+
__Pyx_DECREF_TypeName(b_name);
|
|
168
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
169
|
+
Py_DECREF(b0);
|
|
170
|
+
#endif
|
|
171
|
+
return -1;
|
|
172
|
+
}
|
|
173
|
+
if (dictoffset == 0)
|
|
174
|
+
{
|
|
175
|
+
Py_ssize_t b_dictoffset = 0;
|
|
176
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
177
|
+
b_dictoffset = b->tp_dictoffset;
|
|
178
|
+
#else
|
|
179
|
+
PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__");
|
|
180
|
+
if (!py_b_dictoffset) goto dictoffset_return;
|
|
181
|
+
b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset);
|
|
182
|
+
Py_DECREF(py_b_dictoffset);
|
|
183
|
+
if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return;
|
|
184
|
+
#endif
|
|
185
|
+
if (b_dictoffset) {
|
|
186
|
+
{
|
|
187
|
+
__Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
|
|
188
|
+
PyErr_Format(PyExc_TypeError,
|
|
189
|
+
"extension type '%.200s' has no __dict__ slot, "
|
|
190
|
+
"but base type '" __Pyx_FMT_TYPENAME "' has: "
|
|
191
|
+
"either add 'cdef dict __dict__' to the extension type "
|
|
192
|
+
"or add '__slots__ = [...]' to the base type",
|
|
193
|
+
type_name, b_name);
|
|
194
|
+
__Pyx_DECREF_TypeName(b_name);
|
|
195
|
+
}
|
|
196
|
+
#if !CYTHON_USE_TYPE_SLOTS
|
|
197
|
+
dictoffset_return:
|
|
198
|
+
#endif
|
|
199
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
200
|
+
Py_DECREF(b0);
|
|
201
|
+
#endif
|
|
202
|
+
return -1;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
206
|
+
Py_DECREF(b0);
|
|
207
|
+
#endif
|
|
208
|
+
}
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
#endif
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
/////////////// PyType_Ready.proto ///////////////
|
|
215
|
+
|
|
216
|
+
// unused when using type specs
|
|
217
|
+
CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t);/*proto*/
|
|
218
|
+
|
|
219
|
+
/////////////// PyType_Ready ///////////////
|
|
220
|
+
//@requires: ObjectHandling.c::PyObjectCallMethod0
|
|
221
|
+
//@requires: ValidateBasesTuple
|
|
222
|
+
|
|
223
|
+
CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) {
|
|
224
|
+
while (t) {
|
|
225
|
+
PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
|
|
226
|
+
if (bases) {
|
|
227
|
+
return 1;
|
|
228
|
+
}
|
|
229
|
+
t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*);
|
|
230
|
+
}
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Wrapper around PyType_Ready() with some runtime checks and fixes
|
|
235
|
+
// to deal with multiple inheritance.
|
|
236
|
+
static int __Pyx_PyType_Ready(PyTypeObject *t) {
|
|
237
|
+
|
|
238
|
+
#if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION)
|
|
239
|
+
// avoid C warning about unused helper function
|
|
240
|
+
(void)__Pyx_PyObject_CallMethod0;
|
|
241
|
+
#if CYTHON_USE_TYPE_SPECS
|
|
242
|
+
(void)__Pyx_validate_bases_tuple;
|
|
243
|
+
#endif
|
|
244
|
+
|
|
245
|
+
return PyType_Ready(t);
|
|
246
|
+
|
|
247
|
+
#else
|
|
248
|
+
int r;
|
|
249
|
+
|
|
250
|
+
if (!__Pyx_PyType_HasMultipleInheritance(t)) {
|
|
251
|
+
// shortcut - if none of the base classes do multiple inheritance then we don't need to
|
|
252
|
+
// (and shouldn't) mess around with faking heaptypes.
|
|
253
|
+
return PyType_Ready(t);
|
|
254
|
+
}
|
|
255
|
+
PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
|
|
256
|
+
if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1))
|
|
257
|
+
return -1;
|
|
258
|
+
|
|
259
|
+
#if !defined(PYSTON_MAJOR_VERSION)
|
|
260
|
+
{
|
|
261
|
+
// Make sure GC does not pick up our non-heap type as heap type with this hack!
|
|
262
|
+
// For details, see https://github.com/cython/cython/issues/3603
|
|
263
|
+
int gc_was_enabled;
|
|
264
|
+
#if PY_VERSION_HEX >= 0x030A00b1
|
|
265
|
+
// finally added in Py3.10 :)
|
|
266
|
+
gc_was_enabled = PyGC_Disable();
|
|
267
|
+
(void)__Pyx_PyObject_CallMethod0;
|
|
268
|
+
|
|
269
|
+
#else
|
|
270
|
+
// Call gc.disable() as a backwards compatible fallback, but only if needed.
|
|
271
|
+
PyObject *ret, *py_status;
|
|
272
|
+
PyObject *gc = NULL;
|
|
273
|
+
#if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) && \
|
|
274
|
+
!CYTHON_COMPILING_IN_GRAAL
|
|
275
|
+
// https://foss.heptapod.net/pypy/pypy/-/issues/3385
|
|
276
|
+
gc = PyImport_GetModule(PYUNICODE("gc"));
|
|
277
|
+
#endif
|
|
278
|
+
if (unlikely(!gc)) gc = PyImport_Import(PYUNICODE("gc"));
|
|
279
|
+
if (unlikely(!gc)) return -1;
|
|
280
|
+
py_status = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("isenabled"));
|
|
281
|
+
if (unlikely(!py_status)) {
|
|
282
|
+
Py_DECREF(gc);
|
|
283
|
+
return -1;
|
|
284
|
+
}
|
|
285
|
+
gc_was_enabled = __Pyx_PyObject_IsTrue(py_status);
|
|
286
|
+
Py_DECREF(py_status);
|
|
287
|
+
if (gc_was_enabled > 0) {
|
|
288
|
+
ret = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("disable"));
|
|
289
|
+
if (unlikely(!ret)) {
|
|
290
|
+
Py_DECREF(gc);
|
|
291
|
+
return -1;
|
|
292
|
+
}
|
|
293
|
+
Py_DECREF(ret);
|
|
294
|
+
} else if (unlikely(gc_was_enabled == -1)) {
|
|
295
|
+
Py_DECREF(gc);
|
|
296
|
+
return -1;
|
|
297
|
+
}
|
|
298
|
+
#endif
|
|
299
|
+
|
|
300
|
+
// As of https://github.com/python/cpython/issues/66277
|
|
301
|
+
// PyType_Ready enforces that all bases of a non-heap type are
|
|
302
|
+
// non-heap. We know that this is the case for the solid base but
|
|
303
|
+
// other bases are heap allocated and are kept alive through the
|
|
304
|
+
// tp_bases reference.
|
|
305
|
+
// Other than this check, the Py_TPFLAGS_HEAPTYPE flag is unused
|
|
306
|
+
// in PyType_Ready().
|
|
307
|
+
t->tp_flags |= Py_TPFLAGS_HEAPTYPE;
|
|
308
|
+
#if PY_VERSION_HEX >= 0x030A0000
|
|
309
|
+
// As of https://github.com/python/cpython/pull/25520
|
|
310
|
+
// PyType_Ready marks types as immutable if they are static types
|
|
311
|
+
// and requires the Py_TPFLAGS_IMMUTABLETYPE flag to mark types as
|
|
312
|
+
// immutable
|
|
313
|
+
// Manually set the Py_TPFLAGS_IMMUTABLETYPE flag, since the type
|
|
314
|
+
// is immutable
|
|
315
|
+
t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
|
|
316
|
+
#endif
|
|
317
|
+
#else
|
|
318
|
+
// avoid C warning about unused helper function
|
|
319
|
+
(void)__Pyx_PyObject_CallMethod0;
|
|
320
|
+
#endif
|
|
321
|
+
|
|
322
|
+
r = PyType_Ready(t);
|
|
323
|
+
|
|
324
|
+
#if !defined(PYSTON_MAJOR_VERSION)
|
|
325
|
+
t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
|
|
326
|
+
|
|
327
|
+
#if PY_VERSION_HEX >= 0x030A00b1
|
|
328
|
+
if (gc_was_enabled)
|
|
329
|
+
PyGC_Enable();
|
|
330
|
+
#else
|
|
331
|
+
if (gc_was_enabled) {
|
|
332
|
+
PyObject *tp, *v, *tb;
|
|
333
|
+
PyErr_Fetch(&tp, &v, &tb);
|
|
334
|
+
ret = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("enable"));
|
|
335
|
+
if (likely(ret || r == -1)) {
|
|
336
|
+
Py_XDECREF(ret);
|
|
337
|
+
// do not overwrite exceptions raised by PyType_Ready() above
|
|
338
|
+
PyErr_Restore(tp, v, tb);
|
|
339
|
+
} else {
|
|
340
|
+
// PyType_Ready() succeeded, but gc.enable() failed.
|
|
341
|
+
Py_XDECREF(tp);
|
|
342
|
+
Py_XDECREF(v);
|
|
343
|
+
Py_XDECREF(tb);
|
|
344
|
+
r = -1;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
Py_DECREF(gc);
|
|
348
|
+
#endif
|
|
349
|
+
}
|
|
350
|
+
#endif
|
|
351
|
+
|
|
352
|
+
return r;
|
|
353
|
+
#endif
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
/////////////// PyTrashcan.proto ///////////////
|
|
358
|
+
|
|
359
|
+
// These macros are taken from https://github.com/python/cpython/pull/11841
|
|
360
|
+
// Unlike the Py_TRASHCAN_SAFE_BEGIN/Py_TRASHCAN_SAFE_END macros, they
|
|
361
|
+
// allow dealing correctly with subclasses.
|
|
362
|
+
|
|
363
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
364
|
+
// https://github.com/python/cpython/pull/11841 merged so Cython reimplementation
|
|
365
|
+
// is no longer necessary
|
|
366
|
+
#define __Pyx_TRASHCAN_BEGIN Py_TRASHCAN_BEGIN
|
|
367
|
+
#define __Pyx_TRASHCAN_END Py_TRASHCAN_END
|
|
368
|
+
|
|
369
|
+
#elif CYTHON_COMPILING_IN_CPYTHON
|
|
370
|
+
|
|
371
|
+
#define __Pyx_TRASHCAN_BEGIN_CONDITION(op, cond) \
|
|
372
|
+
do { \
|
|
373
|
+
PyThreadState *_tstate = NULL; \
|
|
374
|
+
// If "cond" is false, then _tstate remains NULL and the deallocator
|
|
375
|
+
// is run normally without involving the trashcan
|
|
376
|
+
if (cond) { \
|
|
377
|
+
_tstate = PyThreadState_GET(); \
|
|
378
|
+
if (_tstate->trash_delete_nesting >= PyTrash_UNWIND_LEVEL) { \
|
|
379
|
+
// Store the object (to be deallocated later) and jump past
|
|
380
|
+
// Py_TRASHCAN_END, skipping the body of the deallocator
|
|
381
|
+
_PyTrash_thread_deposit_object((PyObject*)(op)); \
|
|
382
|
+
break; \
|
|
383
|
+
} \
|
|
384
|
+
++_tstate->trash_delete_nesting; \
|
|
385
|
+
}
|
|
386
|
+
// The body of the deallocator is here.
|
|
387
|
+
#define __Pyx_TRASHCAN_END \
|
|
388
|
+
if (_tstate) { \
|
|
389
|
+
--_tstate->trash_delete_nesting; \
|
|
390
|
+
if (_tstate->trash_delete_later && _tstate->trash_delete_nesting <= 0) \
|
|
391
|
+
_PyTrash_thread_destroy_chain(); \
|
|
392
|
+
} \
|
|
393
|
+
} while (0);
|
|
394
|
+
|
|
395
|
+
#define __Pyx_TRASHCAN_BEGIN(op, dealloc) __Pyx_TRASHCAN_BEGIN_CONDITION(op, \
|
|
396
|
+
__Pyx_PyObject_GetSlot(op, tp_dealloc, destructor) == (destructor)(dealloc))
|
|
397
|
+
|
|
398
|
+
#else
|
|
399
|
+
// The trashcan is a no-op on other Python implementations
|
|
400
|
+
// or old CPython versions
|
|
401
|
+
#define __Pyx_TRASHCAN_BEGIN(op, dealloc)
|
|
402
|
+
#define __Pyx_TRASHCAN_END
|
|
403
|
+
#endif
|
|
404
|
+
|
|
405
|
+
/////////////// CallNextTpDealloc.proto ///////////////
|
|
406
|
+
|
|
407
|
+
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
|
|
408
|
+
|
|
409
|
+
/////////////// CallNextTpDealloc ///////////////
|
|
410
|
+
|
|
411
|
+
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
|
|
412
|
+
PyTypeObject* type = Py_TYPE(obj);
|
|
413
|
+
destructor tp_dealloc = NULL;
|
|
414
|
+
/* try to find the first parent type that has a different tp_dealloc() function */
|
|
415
|
+
while (type && __Pyx_PyType_GetSlot(type, tp_dealloc, destructor) != current_tp_dealloc)
|
|
416
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
417
|
+
while (type && (tp_dealloc = __Pyx_PyType_GetSlot(type, tp_dealloc, destructor)) == current_tp_dealloc)
|
|
418
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
419
|
+
if (type)
|
|
420
|
+
tp_dealloc(obj);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/////////////// CallNextTpTraverse.proto ///////////////
|
|
424
|
+
|
|
425
|
+
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
|
|
426
|
+
|
|
427
|
+
/////////////// CallNextTpTraverse ///////////////
|
|
428
|
+
|
|
429
|
+
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
|
|
430
|
+
PyTypeObject* type = Py_TYPE(obj);
|
|
431
|
+
traverseproc tp_traverse = NULL;
|
|
432
|
+
/* try to find the first parent type that has a different tp_traverse() function */
|
|
433
|
+
while (type && __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc) != current_tp_traverse)
|
|
434
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
435
|
+
while (type && (tp_traverse = __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc)) == current_tp_traverse)
|
|
436
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
437
|
+
if (type && tp_traverse)
|
|
438
|
+
return tp_traverse(obj, v, a);
|
|
439
|
+
// FIXME: really ignore?
|
|
440
|
+
return 0;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/////////////// CallNextTpClear.proto ///////////////
|
|
444
|
+
|
|
445
|
+
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear);
|
|
446
|
+
|
|
447
|
+
/////////////// CallNextTpClear ///////////////
|
|
448
|
+
|
|
449
|
+
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
|
|
450
|
+
PyTypeObject* type = Py_TYPE(obj);
|
|
451
|
+
inquiry tp_clear = NULL;
|
|
452
|
+
/* try to find the first parent type that has a different tp_clear() function */
|
|
453
|
+
while (type && __Pyx_PyType_GetSlot(type, tp_clear, inquiry) != current_tp_clear)
|
|
454
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
455
|
+
while (type && (tp_clear = __Pyx_PyType_GetSlot(type, tp_clear, inquiry)) == current_tp_clear)
|
|
456
|
+
type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*);
|
|
457
|
+
if (type && tp_clear)
|
|
458
|
+
tp_clear(obj);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
/////////////// SetupReduce.proto ///////////////
|
|
463
|
+
|
|
464
|
+
static int __Pyx_setup_reduce(PyObject* type_obj);
|
|
465
|
+
|
|
466
|
+
/////////////// SetupReduce ///////////////
|
|
467
|
+
//@requires: ObjectHandling.c::PyObjectGetAttrStrNoError
|
|
468
|
+
//@requires: ObjectHandling.c::PyObjectGetAttrStr
|
|
469
|
+
//@requires: SetItemOnTypeDict
|
|
470
|
+
//@requires: DelItemOnTypeDict
|
|
471
|
+
|
|
472
|
+
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
|
|
473
|
+
int ret;
|
|
474
|
+
PyObject *name_attr;
|
|
475
|
+
|
|
476
|
+
name_attr = __Pyx_PyObject_GetAttrStrNoError(meth, PYIDENT("__name__"));
|
|
477
|
+
if (likely(name_attr)) {
|
|
478
|
+
ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
|
|
479
|
+
} else {
|
|
480
|
+
ret = -1;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if (unlikely(ret < 0)) {
|
|
484
|
+
PyErr_Clear();
|
|
485
|
+
ret = 0;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
Py_XDECREF(name_attr);
|
|
489
|
+
return ret;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
static int __Pyx_setup_reduce(PyObject* type_obj) {
|
|
493
|
+
int ret = 0;
|
|
494
|
+
PyObject *object_reduce = NULL;
|
|
495
|
+
PyObject *object_getstate = NULL;
|
|
496
|
+
PyObject *object_reduce_ex = NULL;
|
|
497
|
+
PyObject *reduce = NULL;
|
|
498
|
+
PyObject *reduce_ex = NULL;
|
|
499
|
+
PyObject *reduce_cython = NULL;
|
|
500
|
+
PyObject *setstate = NULL;
|
|
501
|
+
PyObject *setstate_cython = NULL;
|
|
502
|
+
PyObject *getstate = NULL;
|
|
503
|
+
|
|
504
|
+
#if CYTHON_USE_PYTYPE_LOOKUP
|
|
505
|
+
getstate = _PyType_Lookup((PyTypeObject*)type_obj, PYIDENT("__getstate__"));
|
|
506
|
+
#else
|
|
507
|
+
getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__getstate__"));
|
|
508
|
+
if (!getstate && PyErr_Occurred()) {
|
|
509
|
+
goto __PYX_BAD;
|
|
510
|
+
}
|
|
511
|
+
#endif
|
|
512
|
+
if (getstate) {
|
|
513
|
+
// Python 3.11 introduces object.__getstate__. Because it's version-specific failure to find it should not be an error
|
|
514
|
+
#if CYTHON_USE_PYTYPE_LOOKUP
|
|
515
|
+
object_getstate = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__getstate__"));
|
|
516
|
+
#else
|
|
517
|
+
object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, PYIDENT("__getstate__"));
|
|
518
|
+
if (!object_getstate && PyErr_Occurred()) {
|
|
519
|
+
goto __PYX_BAD;
|
|
520
|
+
}
|
|
521
|
+
#endif
|
|
522
|
+
if (object_getstate != getstate) {
|
|
523
|
+
goto __PYX_GOOD;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
#if CYTHON_USE_PYTYPE_LOOKUP
|
|
528
|
+
object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__reduce_ex__")); if (!object_reduce_ex) goto __PYX_BAD;
|
|
529
|
+
#else
|
|
530
|
+
object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, PYIDENT("__reduce_ex__")); if (!object_reduce_ex) goto __PYX_BAD;
|
|
531
|
+
#endif
|
|
532
|
+
|
|
533
|
+
reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce_ex__")); if (unlikely(!reduce_ex)) goto __PYX_BAD;
|
|
534
|
+
if (reduce_ex == object_reduce_ex) {
|
|
535
|
+
|
|
536
|
+
#if CYTHON_USE_PYTYPE_LOOKUP
|
|
537
|
+
object_reduce = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__reduce__")); if (!object_reduce) goto __PYX_BAD;
|
|
538
|
+
#else
|
|
539
|
+
object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, PYIDENT("__reduce__")); if (!object_reduce) goto __PYX_BAD;
|
|
540
|
+
#endif
|
|
541
|
+
reduce = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce__")); if (unlikely(!reduce)) goto __PYX_BAD;
|
|
542
|
+
|
|
543
|
+
if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, PYIDENT("__reduce_cython__"))) {
|
|
544
|
+
reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__reduce_cython__"));
|
|
545
|
+
if (likely(reduce_cython)) {
|
|
546
|
+
ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__reduce__"), reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
547
|
+
ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__reduce_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
548
|
+
} else if (reduce == object_reduce || PyErr_Occurred()) {
|
|
549
|
+
// Ignore if we're done, i.e. if 'reduce' already has the right name and the original is gone.
|
|
550
|
+
// Otherwise: error.
|
|
551
|
+
goto __PYX_BAD;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
setstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__setstate__"));
|
|
555
|
+
if (!setstate) PyErr_Clear();
|
|
556
|
+
if (!setstate || __Pyx_setup_reduce_is_named(setstate, PYIDENT("__setstate_cython__"))) {
|
|
557
|
+
setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__setstate_cython__"));
|
|
558
|
+
if (likely(setstate_cython)) {
|
|
559
|
+
ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__setstate__"), setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
560
|
+
ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, PYIDENT("__setstate_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD;
|
|
561
|
+
} else if (!setstate || PyErr_Occurred()) {
|
|
562
|
+
// Ignore if we're done, i.e. if 'setstate' already has the right name and the original is gone.
|
|
563
|
+
// Otherwise: error.
|
|
564
|
+
goto __PYX_BAD;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
PyType_Modified((PyTypeObject*)type_obj);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
goto __PYX_GOOD;
|
|
571
|
+
|
|
572
|
+
__PYX_BAD:
|
|
573
|
+
if (!PyErr_Occurred()) {
|
|
574
|
+
__Pyx_TypeName type_obj_name =
|
|
575
|
+
__Pyx_PyType_GetFullyQualifiedName((PyTypeObject*)type_obj);
|
|
576
|
+
PyErr_Format(PyExc_RuntimeError,
|
|
577
|
+
"Unable to initialize pickling for " __Pyx_FMT_TYPENAME, type_obj_name);
|
|
578
|
+
__Pyx_DECREF_TypeName(type_obj_name);
|
|
579
|
+
}
|
|
580
|
+
ret = -1;
|
|
581
|
+
__PYX_GOOD:
|
|
582
|
+
#if !CYTHON_USE_PYTYPE_LOOKUP
|
|
583
|
+
Py_XDECREF(object_reduce);
|
|
584
|
+
Py_XDECREF(object_reduce_ex);
|
|
585
|
+
Py_XDECREF(object_getstate);
|
|
586
|
+
Py_XDECREF(getstate);
|
|
587
|
+
#endif
|
|
588
|
+
Py_XDECREF(reduce);
|
|
589
|
+
Py_XDECREF(reduce_ex);
|
|
590
|
+
Py_XDECREF(reduce_cython);
|
|
591
|
+
Py_XDECREF(setstate);
|
|
592
|
+
Py_XDECREF(setstate_cython);
|
|
593
|
+
return ret;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
/////////////// CheckUnpickleChecksum.proto ///////////////
|
|
598
|
+
|
|
599
|
+
static CYTHON_INLINE int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members); /*proto*/
|
|
600
|
+
|
|
601
|
+
/////////////// CheckUnpickleChecksum ///////////////
|
|
602
|
+
|
|
603
|
+
static void __Pyx_RaiseUnpickleChecksumError(long checksum, long checksum1, long checksum2, long checksum3, const char *members) {
|
|
604
|
+
// This function always raises some kind of error, either the expected one or a different one.
|
|
605
|
+
PyObject *pickle_module = PyImport_ImportModule("pickle");
|
|
606
|
+
if (unlikely(!pickle_module)) return;
|
|
607
|
+
|
|
608
|
+
PyObject *pickle_error = PyObject_GetAttrString(pickle_module, "PickleError");
|
|
609
|
+
Py_DECREF(pickle_module);
|
|
610
|
+
if (unlikely(!pickle_error)) return;
|
|
611
|
+
|
|
612
|
+
if (checksum2 == checksum1) {
|
|
613
|
+
PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x) = (%s))",
|
|
614
|
+
checksum, checksum1, members);
|
|
615
|
+
} else if (checksum3 == checksum2) {
|
|
616
|
+
PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x) = (%s))",
|
|
617
|
+
checksum, checksum1, checksum2, members);
|
|
618
|
+
} else {
|
|
619
|
+
PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x, 0x%x) = (%s))",
|
|
620
|
+
checksum, checksum1, checksum2, checksum3, members);
|
|
621
|
+
}
|
|
622
|
+
Py_DECREF(pickle_error);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
static int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members) {
|
|
626
|
+
int found = 0;
|
|
627
|
+
found |= checksum1 == checksum;
|
|
628
|
+
found |= checksum2 == checksum;
|
|
629
|
+
found |= checksum3 == checksum;
|
|
630
|
+
if (likely(found))
|
|
631
|
+
return 0;
|
|
632
|
+
|
|
633
|
+
__Pyx_RaiseUnpickleChecksumError(checksum, checksum1, checksum2, checksum3, members);
|
|
634
|
+
return -1;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
/////////////// UpdateUnpickledDict.proto ///////////////
|
|
639
|
+
|
|
640
|
+
static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index); /*proto*/
|
|
641
|
+
|
|
642
|
+
/////////////// UpdateUnpickledDict ///////////////
|
|
643
|
+
//@requires: ObjectHandling.c::PyObjectCallMethod1
|
|
644
|
+
|
|
645
|
+
static int __Pyx__UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) {
|
|
646
|
+
PyObject *state_dict = __Pyx_PySequence_ITEM(state, index);
|
|
647
|
+
if (unlikely(!state_dict)) {
|
|
648
|
+
return -1;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
int non_empty = PyObject_IsTrue(state_dict);
|
|
652
|
+
if (non_empty == 0) {
|
|
653
|
+
// Nothing to do.
|
|
654
|
+
Py_DECREF(state_dict);
|
|
655
|
+
return 0;
|
|
656
|
+
} else if (unlikely(non_empty == -1)) {
|
|
657
|
+
return -1;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// Since we received a non-empty dict from pickling,
|
|
661
|
+
// we assume that we're unpickling an object that has one, too.
|
|
662
|
+
PyObject *dict;
|
|
663
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
664
|
+
dict = PyObject_GetAttrString(obj, "__dict__");
|
|
665
|
+
#else
|
|
666
|
+
dict = PyObject_GenericGetDict(obj, NULL);
|
|
667
|
+
#endif
|
|
668
|
+
if (unlikely(!dict)) {
|
|
669
|
+
// It is debatable if it is a fatal error if we cannot reassign the state of the dict because
|
|
670
|
+
// the unpickled object does not have a '__dict__'. But the user should probably know.
|
|
671
|
+
Py_DECREF(state_dict);
|
|
672
|
+
return -1;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
int result;
|
|
676
|
+
if (likely(PyDict_CheckExact(dict))) {
|
|
677
|
+
result = PyDict_Update(dict, state_dict);
|
|
678
|
+
} else {
|
|
679
|
+
PyObject *obj_result = __Pyx_PyObject_CallMethod1(dict, PYIDENT("update"), state_dict);
|
|
680
|
+
if (likely(obj_result)) {
|
|
681
|
+
Py_DECREF(obj_result);
|
|
682
|
+
result = 0;
|
|
683
|
+
} else {
|
|
684
|
+
result = -1;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
Py_DECREF(state_dict);
|
|
688
|
+
Py_DECREF(dict);
|
|
689
|
+
return result;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) {
|
|
693
|
+
Py_ssize_t state_size = __Pyx_PyTuple_GET_SIZE(state);
|
|
694
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
695
|
+
if (unlikely(state_size == -1)) return -1;
|
|
696
|
+
#endif
|
|
697
|
+
if (state_size <= index) {
|
|
698
|
+
// No dict from pickling.
|
|
699
|
+
return 0;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
return __Pyx__UpdateUnpickledDict(obj, state, index);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
/////////////// BinopSlot ///////////////
|
|
707
|
+
|
|
708
|
+
static CYTHON_INLINE PyObject *{{func_name}}_maybe_call_slot(PyTypeObject* type, PyObject *left, PyObject *right {{extra_arg_decl}}) {
|
|
709
|
+
{{slot_type}} slot;
|
|
710
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
711
|
+
slot = type->tp_as_number ? type->tp_as_number->{{slot_name}} : NULL;
|
|
712
|
+
#else
|
|
713
|
+
slot = ({{slot_type}}) PyType_GetSlot(type, Py_{{slot_name}});
|
|
714
|
+
#endif
|
|
715
|
+
return slot ? slot(left, right {{extra_arg}}) : __Pyx_NewRef(Py_NotImplemented);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
static PyObject *{{func_name}}(PyObject *left, PyObject *right {{extra_arg_decl}}) {
|
|
719
|
+
int maybe_self_is_left, maybe_self_is_right = 0;
|
|
720
|
+
maybe_self_is_left = Py_TYPE(left) == Py_TYPE(right)
|
|
721
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
722
|
+
|| (Py_TYPE(left)->tp_as_number && Py_TYPE(left)->tp_as_number->{{slot_name}} == &{{func_name}})
|
|
723
|
+
#endif
|
|
724
|
+
|| __Pyx_TypeCheck(left, {{type_cname}});
|
|
725
|
+
|
|
726
|
+
// Optimize for the common case where the left operation is defined (and successful).
|
|
727
|
+
{{if not overloads_left}}
|
|
728
|
+
maybe_self_is_right = Py_TYPE(left) == Py_TYPE(right)
|
|
729
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
730
|
+
|| (Py_TYPE(right)->tp_as_number && Py_TYPE(right)->tp_as_number->{{slot_name}} == &{{func_name}})
|
|
731
|
+
#endif
|
|
732
|
+
|| __Pyx_TypeCheck(right, {{type_cname}});
|
|
733
|
+
{{endif}}
|
|
734
|
+
|
|
735
|
+
if (maybe_self_is_left) {
|
|
736
|
+
PyObject *res;
|
|
737
|
+
|
|
738
|
+
{{if overloads_right and not overloads_left}}
|
|
739
|
+
if (maybe_self_is_right) {
|
|
740
|
+
res = {{call_right}};
|
|
741
|
+
if (res != Py_NotImplemented) return res;
|
|
742
|
+
Py_DECREF(res);
|
|
743
|
+
// Don't bother calling it again.
|
|
744
|
+
maybe_self_is_right = 0;
|
|
745
|
+
}
|
|
746
|
+
{{endif}}
|
|
747
|
+
|
|
748
|
+
res = {{call_left}};
|
|
749
|
+
if (res != Py_NotImplemented) return res;
|
|
750
|
+
Py_DECREF(res);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
{{if overloads_left}}
|
|
754
|
+
maybe_self_is_right = Py_TYPE(left) == Py_TYPE(right)
|
|
755
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
756
|
+
|| (Py_TYPE(right)->tp_as_number && Py_TYPE(right)->tp_as_number->{{slot_name}} == &{{func_name}})
|
|
757
|
+
#endif
|
|
758
|
+
|| PyType_IsSubtype(Py_TYPE(right), {{type_cname}});
|
|
759
|
+
{{endif}}
|
|
760
|
+
|
|
761
|
+
if (maybe_self_is_right) {
|
|
762
|
+
return {{call_right}};
|
|
763
|
+
}
|
|
764
|
+
return __Pyx_NewRef(Py_NotImplemented);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/////////////// ValidateExternBase.proto ///////////////
|
|
768
|
+
|
|
769
|
+
static int __Pyx_validate_extern_base(PyTypeObject *base); /* proto */
|
|
770
|
+
|
|
771
|
+
/////////////// ValidateExternBase ///////////////
|
|
772
|
+
//@requires: ObjectHandling.c::FormatTypeName
|
|
773
|
+
|
|
774
|
+
static int __Pyx_validate_extern_base(PyTypeObject *base) {
|
|
775
|
+
Py_ssize_t itemsize;
|
|
776
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
777
|
+
PyObject *py_itemsize;
|
|
778
|
+
#endif
|
|
779
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
780
|
+
itemsize = ((PyTypeObject *)base)->tp_itemsize;
|
|
781
|
+
#else
|
|
782
|
+
py_itemsize = PyObject_GetAttrString((PyObject*)base, "__itemsize__");
|
|
783
|
+
if (!py_itemsize)
|
|
784
|
+
return -1;
|
|
785
|
+
itemsize = PyLong_AsSsize_t(py_itemsize);
|
|
786
|
+
Py_DECREF(py_itemsize);
|
|
787
|
+
py_itemsize = 0;
|
|
788
|
+
if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred())
|
|
789
|
+
return -1;
|
|
790
|
+
#endif
|
|
791
|
+
if (itemsize) {
|
|
792
|
+
__Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(base);
|
|
793
|
+
PyErr_Format(PyExc_TypeError,
|
|
794
|
+
"inheritance from PyVarObject types like '" __Pyx_FMT_TYPENAME "' not currently supported", b_name);
|
|
795
|
+
__Pyx_DECREF_TypeName(b_name);
|
|
796
|
+
return -1;
|
|
797
|
+
}
|
|
798
|
+
return 0;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/////////////// CallTypeTraverse.proto /////////////////////
|
|
802
|
+
|
|
803
|
+
#if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
|
|
804
|
+
// Without type specs, we're never responsible for this.
|
|
805
|
+
// If we *know* the Python version is less that 3.9 we're also not responsible
|
|
806
|
+
#define __Pyx_call_type_traverse(o, always_call, visit, arg) 0
|
|
807
|
+
#else
|
|
808
|
+
static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg); /* proto */
|
|
809
|
+
#endif
|
|
810
|
+
|
|
811
|
+
/////////////// CallTypeTraverse ////////////////////////////
|
|
812
|
+
|
|
813
|
+
#if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
|
|
814
|
+
// nothing to do
|
|
815
|
+
#else
|
|
816
|
+
static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) {
|
|
817
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000
|
|
818
|
+
// We have to work out whether to call traverse based on the runtime version.
|
|
819
|
+
// __Pyx_get_runtime_version is always available so no need to require it.
|
|
820
|
+
if (__Pyx_get_runtime_version() < 0x03090000) return 0;
|
|
821
|
+
#endif
|
|
822
|
+
if (!always_call) {
|
|
823
|
+
// Written with reference to https://docs.python.org/3/howto/isolating-extensions.html
|
|
824
|
+
PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*);
|
|
825
|
+
unsigned long flags = PyType_GetFlags(base);
|
|
826
|
+
if (flags & Py_TPFLAGS_HEAPTYPE) {
|
|
827
|
+
// The base class should have handled it
|
|
828
|
+
return 0;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
Py_VISIT((PyObject*)Py_TYPE(o));
|
|
832
|
+
return 0;
|
|
833
|
+
}
|
|
834
|
+
#endif
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
////////////////// LimitedApiGetTypeDict.proto //////////////////////
|
|
838
|
+
|
|
839
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
840
|
+
// This is a little hacky - the Limited API works quite hard to stop us getting
|
|
841
|
+
// the dict of a type object. But apparently not hard enough...
|
|
842
|
+
//
|
|
843
|
+
// In future we should prefer to work with mutable types, and then make them immutable
|
|
844
|
+
// once we're done (pending C API support for this).
|
|
845
|
+
static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp); /* proto */
|
|
846
|
+
#endif
|
|
847
|
+
|
|
848
|
+
////////////////// LimitedApiGetTypeDict //////////////////////
|
|
849
|
+
|
|
850
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
851
|
+
static Py_ssize_t __Pyx_GetTypeDictOffset(void) {
|
|
852
|
+
PyObject *tp_dictoffset_o;
|
|
853
|
+
Py_ssize_t tp_dictoffset;
|
|
854
|
+
tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__");
|
|
855
|
+
if (unlikely(!tp_dictoffset_o)) return -1;
|
|
856
|
+
tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o);
|
|
857
|
+
Py_DECREF(tp_dictoffset_o);
|
|
858
|
+
|
|
859
|
+
if (unlikely(tp_dictoffset == 0)) {
|
|
860
|
+
PyErr_SetString(
|
|
861
|
+
PyExc_TypeError,
|
|
862
|
+
"'type' doesn't have a dictoffset");
|
|
863
|
+
return -1;
|
|
864
|
+
} else if (unlikely(tp_dictoffset < 0)) {
|
|
865
|
+
// This isn't completely future proof. dictoffset can be
|
|
866
|
+
// negative, but isn't in Python <=3.13 (current at time
|
|
867
|
+
// of writing). It's awkward to calculate in the limited
|
|
868
|
+
// API because we need to know the object size. For now
|
|
869
|
+
// just raise an error and fix it if it every changes.
|
|
870
|
+
PyErr_SetString(
|
|
871
|
+
PyExc_TypeError,
|
|
872
|
+
"'type' has an unexpected negative dictoffset. "
|
|
873
|
+
"Please report this as Cython bug");
|
|
874
|
+
return -1;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
return tp_dictoffset;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) {
|
|
881
|
+
// TODO - if we ever support custom metatypes for extension types then
|
|
882
|
+
// we have to modify this caching.
|
|
883
|
+
static Py_ssize_t tp_dictoffset = 0;
|
|
884
|
+
if (unlikely(tp_dictoffset == 0)) {
|
|
885
|
+
tp_dictoffset = __Pyx_GetTypeDictOffset();
|
|
886
|
+
// Note that negative dictoffsets are definitely allowed.
|
|
887
|
+
// A dictoffset of -1 seems unlikely but isn't obviously forbidden.
|
|
888
|
+
if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) {
|
|
889
|
+
tp_dictoffset = 0; // try again next time?
|
|
890
|
+
return NULL;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
return *(PyObject**)((char*)tp + tp_dictoffset);
|
|
894
|
+
}
|
|
895
|
+
#endif
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
////////////////// SetItemOnTypeDict.proto //////////////////////////
|
|
899
|
+
//@requires: LimitedApiGetTypeDict
|
|
900
|
+
|
|
901
|
+
static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v); /* proto */
|
|
902
|
+
|
|
903
|
+
#define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v)
|
|
904
|
+
|
|
905
|
+
////////////////// SetItemOnTypeDict //////////////////////////
|
|
906
|
+
|
|
907
|
+
static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) {
|
|
908
|
+
int result;
|
|
909
|
+
PyObject *tp_dict;
|
|
910
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
911
|
+
tp_dict = __Pyx_GetTypeDict(tp);
|
|
912
|
+
if (unlikely(!tp_dict)) return -1;
|
|
913
|
+
#else
|
|
914
|
+
tp_dict = tp->tp_dict;
|
|
915
|
+
#endif
|
|
916
|
+
result = PyDict_SetItem(tp_dict, k, v);
|
|
917
|
+
if (likely(!result)) {
|
|
918
|
+
PyType_Modified(tp);
|
|
919
|
+
if (unlikely(PyObject_HasAttr(v, PYIDENT("__set_name__")))) {
|
|
920
|
+
PyObject *setNameResult = PyObject_CallMethodObjArgs(v, PYIDENT("__set_name__"), (PyObject *) tp, k, NULL);
|
|
921
|
+
if (!setNameResult) return -1;
|
|
922
|
+
Py_DECREF(setNameResult);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
return result;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
////////////////// DelItemOnTypeDict.proto //////////////////////////
|
|
929
|
+
|
|
930
|
+
static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k); /* proto */
|
|
931
|
+
|
|
932
|
+
#define __Pyx_DelItemOnTypeDict(tp, k) __Pyx__DelItemOnTypeDict((PyTypeObject*)tp, k)
|
|
933
|
+
|
|
934
|
+
////////////////// DelItemOnTypeDict //////////////////////////
|
|
935
|
+
//@requires: LimitedApiGetTypeDict
|
|
936
|
+
|
|
937
|
+
static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k) {
|
|
938
|
+
int result;
|
|
939
|
+
PyObject *tp_dict;
|
|
940
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
941
|
+
tp_dict = __Pyx_GetTypeDict(tp);
|
|
942
|
+
if (unlikely(!tp_dict)) return -1;
|
|
943
|
+
#else
|
|
944
|
+
tp_dict = tp->tp_dict;
|
|
945
|
+
#endif
|
|
946
|
+
result = PyDict_DelItem(tp_dict, k);
|
|
947
|
+
if (likely(!result)) PyType_Modified(tp);
|
|
948
|
+
return result;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
////////////////// AllocateExtensionType.proto ///////////////////////
|
|
952
|
+
|
|
953
|
+
static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); /* proto */
|
|
954
|
+
|
|
955
|
+
////////////////// AllocateExtensionType ////////////////////////////
|
|
956
|
+
|
|
957
|
+
static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) {
|
|
958
|
+
if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) {
|
|
959
|
+
allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc);
|
|
960
|
+
return alloc_func(t, 0);
|
|
961
|
+
} else {
|
|
962
|
+
// Call PyBaseObject_Type.tp_new. This is is expected to fail, generating an appropriate
|
|
963
|
+
// error message about allocating an abstract type.
|
|
964
|
+
newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc);
|
|
965
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
966
|
+
if (!tp_new) {
|
|
967
|
+
PyObject *new_str = PyUnicode_FromString("__new__");
|
|
968
|
+
if (likely(new_str)) {
|
|
969
|
+
PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL);
|
|
970
|
+
Py_DECREF(new_str);
|
|
971
|
+
return o;
|
|
972
|
+
} else
|
|
973
|
+
return NULL;
|
|
974
|
+
} else
|
|
975
|
+
#endif
|
|
976
|
+
return tp_new(t, EMPTY(tuple), 0);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
///////////////////// CheckTypeForFreelists.proto ////////////////////////
|
|
981
|
+
|
|
982
|
+
#if CYTHON_USE_FREELISTS
|
|
983
|
+
#if CYTHON_USE_TYPE_SPECS
|
|
984
|
+
// with CYTHON_USE_TYPE_SPECS we can only reasonably use freelists for an exact type match,
|
|
985
|
+
// because it isn't easy to look up basicsize is the limited API, and because everything fails the heap-type check.
|
|
986
|
+
#define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t) == (expected_tp)))
|
|
987
|
+
#define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS Py_TPFLAGS_IS_ABSTRACT
|
|
988
|
+
#else
|
|
989
|
+
#define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t)->tp_basicsize == (expected_size)))
|
|
990
|
+
#define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)
|
|
991
|
+
#endif
|
|
992
|
+
|
|
993
|
+
#define __PYX_CHECK_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) \
|
|
994
|
+
(__PYX_CHECK_FINAL_TYPE_FOR_FREELISTS((t), (expected_tp), (expected_size)) & \
|
|
995
|
+
(int) (!__Pyx_PyType_HasFeature((t), __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS)))
|
|
996
|
+
#endif
|