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,1016 @@
|
|
|
1
|
+
// Exception raising code
|
|
2
|
+
//
|
|
3
|
+
// Exceptions are raised by __Pyx_Raise() and stored as plain
|
|
4
|
+
// type/value/tb in PyThreadState->curexc_*. When being caught by an
|
|
5
|
+
// 'except' statement, curexc_* is moved over to exc_* by
|
|
6
|
+
// __Pyx_GetException()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/////////////// AssertionsEnabled.init ///////////////
|
|
10
|
+
|
|
11
|
+
if (likely(__Pyx_init_assertions_enabled() == 0)); else
|
|
12
|
+
// error propagation code is appended automatically
|
|
13
|
+
|
|
14
|
+
/////////////// AssertionsEnabled.proto ///////////////
|
|
15
|
+
|
|
16
|
+
#if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000
|
|
17
|
+
// Py_OptimizeFlag is deprecated in Py3.12+ and not available in the Limited API.
|
|
18
|
+
static int __pyx_assertions_enabled_flag;
|
|
19
|
+
#define __pyx_assertions_enabled() (__pyx_assertions_enabled_flag)
|
|
20
|
+
|
|
21
|
+
static int __Pyx_init_assertions_enabled(void) {
|
|
22
|
+
PyObject *builtins, *debug, *debug_str;
|
|
23
|
+
int flag;
|
|
24
|
+
builtins = PyEval_GetBuiltins();
|
|
25
|
+
if (!builtins) goto bad;
|
|
26
|
+
// Not using PYIDENT() here because we probably don't need the string more than this once.
|
|
27
|
+
debug_str = PyUnicode_FromStringAndSize("__debug__", 9);
|
|
28
|
+
if (!debug_str) goto bad;
|
|
29
|
+
debug = PyObject_GetItem(builtins, debug_str);
|
|
30
|
+
Py_DECREF(debug_str);
|
|
31
|
+
if (!debug) goto bad;
|
|
32
|
+
flag = PyObject_IsTrue(debug);
|
|
33
|
+
Py_DECREF(debug);
|
|
34
|
+
if (flag == -1) goto bad;
|
|
35
|
+
__pyx_assertions_enabled_flag = flag;
|
|
36
|
+
return 0;
|
|
37
|
+
bad:
|
|
38
|
+
__pyx_assertions_enabled_flag = 1;
|
|
39
|
+
// We (rarely) may not have an exception set, but the calling code will call PyErr_Occurred() either way.
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
#else
|
|
43
|
+
#define __Pyx_init_assertions_enabled() (0)
|
|
44
|
+
#define __pyx_assertions_enabled() (!Py_OptimizeFlag)
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/////////////// ErrOccurredWithGIL.proto ///////////////
|
|
49
|
+
static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */
|
|
50
|
+
|
|
51
|
+
/////////////// ErrOccurredWithGIL ///////////////
|
|
52
|
+
static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) {
|
|
53
|
+
int err;
|
|
54
|
+
PyGILState_STATE _save = PyGILState_Ensure();
|
|
55
|
+
err = !!PyErr_Occurred();
|
|
56
|
+
PyGILState_Release(_save);
|
|
57
|
+
return err;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/////////////// PyThreadStateGet.proto ///////////////
|
|
62
|
+
//@substitute: naming
|
|
63
|
+
|
|
64
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
65
|
+
#define __Pyx_PyThreadState_declare PyThreadState *$local_tstate_cname;
|
|
66
|
+
#define __Pyx_PyThreadState_assign $local_tstate_cname = __Pyx_PyThreadState_Current;
|
|
67
|
+
#if PY_VERSION_HEX >= 0x030C00A6
|
|
68
|
+
#define __Pyx_PyErr_Occurred() ($local_tstate_cname->current_exception != NULL)
|
|
69
|
+
#define __Pyx_PyErr_CurrentExceptionType() ($local_tstate_cname->current_exception ? (PyObject*) Py_TYPE($local_tstate_cname->current_exception) : (PyObject*) NULL)
|
|
70
|
+
#else
|
|
71
|
+
#define __Pyx_PyErr_Occurred() ($local_tstate_cname->curexc_type != NULL)
|
|
72
|
+
#define __Pyx_PyErr_CurrentExceptionType() ($local_tstate_cname->curexc_type)
|
|
73
|
+
#endif
|
|
74
|
+
#else
|
|
75
|
+
// !CYTHON_FAST_THREAD_STATE
|
|
76
|
+
#define __Pyx_PyThreadState_declare
|
|
77
|
+
#define __Pyx_PyThreadState_assign
|
|
78
|
+
#define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
|
|
79
|
+
#define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
/////////////// PyErrExceptionMatches.proto ///////////////
|
|
84
|
+
//@substitute: naming
|
|
85
|
+
|
|
86
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
87
|
+
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState($local_tstate_cname, err)
|
|
88
|
+
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
|
|
89
|
+
#else
|
|
90
|
+
#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
|
|
91
|
+
#endif
|
|
92
|
+
|
|
93
|
+
/////////////// PyErrExceptionMatches ///////////////
|
|
94
|
+
|
|
95
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
96
|
+
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
|
|
97
|
+
Py_ssize_t i, n;
|
|
98
|
+
n = PyTuple_GET_SIZE(tuple);
|
|
99
|
+
// the tighter subtype checking in Py3 allows faster out-of-order comparison
|
|
100
|
+
for (i=0; i<n; i++) {
|
|
101
|
+
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
|
|
102
|
+
}
|
|
103
|
+
for (i=0; i<n; i++) {
|
|
104
|
+
if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
|
|
105
|
+
}
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
|
|
110
|
+
int result;
|
|
111
|
+
PyObject *exc_type;
|
|
112
|
+
#if PY_VERSION_HEX >= 0x030C00A6
|
|
113
|
+
PyObject *current_exception = tstate->current_exception;
|
|
114
|
+
if (unlikely(!current_exception)) return 0;
|
|
115
|
+
exc_type = (PyObject*) Py_TYPE(current_exception);
|
|
116
|
+
if (exc_type == err) return 1;
|
|
117
|
+
#else
|
|
118
|
+
exc_type = tstate->curexc_type;
|
|
119
|
+
if (exc_type == err) return 1;
|
|
120
|
+
if (unlikely(!exc_type)) return 0;
|
|
121
|
+
#endif
|
|
122
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
123
|
+
Py_INCREF(exc_type);
|
|
124
|
+
#endif
|
|
125
|
+
if (unlikely(PyTuple_Check(err))) {
|
|
126
|
+
result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
|
|
127
|
+
} else {
|
|
128
|
+
result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
|
|
129
|
+
}
|
|
130
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
131
|
+
Py_DECREF(exc_type);
|
|
132
|
+
#endif
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
#endif
|
|
136
|
+
|
|
137
|
+
/////////////// PyErrFetchRestore.proto ///////////////
|
|
138
|
+
//@substitute: naming
|
|
139
|
+
//@requires: PyThreadStateGet
|
|
140
|
+
|
|
141
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
142
|
+
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
|
|
143
|
+
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
|
|
144
|
+
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
|
|
145
|
+
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState($local_tstate_cname, type, value, tb)
|
|
146
|
+
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState($local_tstate_cname, type, value, tb)
|
|
147
|
+
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/
|
|
148
|
+
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
|
149
|
+
|
|
150
|
+
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
|
|
151
|
+
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
|
|
152
|
+
#else
|
|
153
|
+
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
|
|
154
|
+
#endif
|
|
155
|
+
|
|
156
|
+
#else
|
|
157
|
+
#define __Pyx_PyErr_Clear() PyErr_Clear()
|
|
158
|
+
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
|
|
159
|
+
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
|
|
160
|
+
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
|
|
161
|
+
#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
|
|
162
|
+
#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
|
|
163
|
+
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
|
|
164
|
+
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
/////////////// PyErrFetchRestore ///////////////
|
|
168
|
+
|
|
169
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
170
|
+
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
|
|
171
|
+
#if PY_VERSION_HEX >= 0x030C00A6
|
|
172
|
+
PyObject *tmp_value;
|
|
173
|
+
assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
|
|
174
|
+
if (value) {
|
|
175
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
176
|
+
if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
|
|
177
|
+
#endif
|
|
178
|
+
// If this fails, we may lose the traceback but still set the expected exception below.
|
|
179
|
+
PyException_SetTraceback(value, tb);
|
|
180
|
+
}
|
|
181
|
+
tmp_value = tstate->current_exception;
|
|
182
|
+
tstate->current_exception = value;
|
|
183
|
+
Py_XDECREF(tmp_value);
|
|
184
|
+
Py_XDECREF(type);
|
|
185
|
+
Py_XDECREF(tb);
|
|
186
|
+
#else
|
|
187
|
+
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
|
188
|
+
tmp_type = tstate->curexc_type;
|
|
189
|
+
tmp_value = tstate->curexc_value;
|
|
190
|
+
tmp_tb = tstate->curexc_traceback;
|
|
191
|
+
tstate->curexc_type = type;
|
|
192
|
+
tstate->curexc_value = value;
|
|
193
|
+
tstate->curexc_traceback = tb;
|
|
194
|
+
Py_XDECREF(tmp_type);
|
|
195
|
+
Py_XDECREF(tmp_value);
|
|
196
|
+
Py_XDECREF(tmp_tb);
|
|
197
|
+
#endif
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
|
|
201
|
+
#if PY_VERSION_HEX >= 0x030C00A6
|
|
202
|
+
PyObject* exc_value;
|
|
203
|
+
exc_value = tstate->current_exception;
|
|
204
|
+
tstate->current_exception = 0;
|
|
205
|
+
*value = exc_value;
|
|
206
|
+
*type = NULL;
|
|
207
|
+
*tb = NULL;
|
|
208
|
+
if (exc_value) {
|
|
209
|
+
*type = (PyObject*) Py_TYPE(exc_value);
|
|
210
|
+
Py_INCREF(*type);
|
|
211
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
212
|
+
*tb = ((PyBaseExceptionObject*) exc_value)->traceback;
|
|
213
|
+
Py_XINCREF(*tb);
|
|
214
|
+
#else
|
|
215
|
+
*tb = PyException_GetTraceback(exc_value);
|
|
216
|
+
#endif
|
|
217
|
+
}
|
|
218
|
+
#else
|
|
219
|
+
*type = tstate->curexc_type;
|
|
220
|
+
*value = tstate->curexc_value;
|
|
221
|
+
*tb = tstate->curexc_traceback;
|
|
222
|
+
tstate->curexc_type = 0;
|
|
223
|
+
tstate->curexc_value = 0;
|
|
224
|
+
tstate->curexc_traceback = 0;
|
|
225
|
+
#endif
|
|
226
|
+
}
|
|
227
|
+
#endif
|
|
228
|
+
|
|
229
|
+
/////////////// RaiseException.export ///////////////
|
|
230
|
+
|
|
231
|
+
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
|
|
232
|
+
|
|
233
|
+
/////////////// RaiseException ///////////////
|
|
234
|
+
//@requires: PyErrFetchRestore
|
|
235
|
+
//@requires: PyThreadStateGet
|
|
236
|
+
|
|
237
|
+
// The following function is based on do_raise() from ceval.c.
|
|
238
|
+
|
|
239
|
+
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
|
|
240
|
+
PyObject* owned_instance = NULL;
|
|
241
|
+
if (tb == Py_None) {
|
|
242
|
+
tb = 0;
|
|
243
|
+
} else if (tb && !PyTraceBack_Check(tb)) {
|
|
244
|
+
PyErr_SetString(PyExc_TypeError,
|
|
245
|
+
"raise: arg 3 must be a traceback or None");
|
|
246
|
+
goto bad;
|
|
247
|
+
}
|
|
248
|
+
if (value == Py_None)
|
|
249
|
+
value = 0;
|
|
250
|
+
|
|
251
|
+
if (PyExceptionInstance_Check(type)) {
|
|
252
|
+
if (value) {
|
|
253
|
+
PyErr_SetString(PyExc_TypeError,
|
|
254
|
+
"instance exception may not have a separate value");
|
|
255
|
+
goto bad;
|
|
256
|
+
}
|
|
257
|
+
value = type;
|
|
258
|
+
type = (PyObject*) Py_TYPE(value);
|
|
259
|
+
} else if (PyExceptionClass_Check(type)) {
|
|
260
|
+
// make sure value is an exception instance of type
|
|
261
|
+
PyObject *instance_class = NULL;
|
|
262
|
+
if (value && PyExceptionInstance_Check(value)) {
|
|
263
|
+
instance_class = (PyObject*) Py_TYPE(value);
|
|
264
|
+
if (instance_class != type) {
|
|
265
|
+
int is_subclass = PyObject_IsSubclass(instance_class, type);
|
|
266
|
+
if (!is_subclass) {
|
|
267
|
+
instance_class = NULL;
|
|
268
|
+
} else if (unlikely(is_subclass == -1)) {
|
|
269
|
+
// error on subclass test
|
|
270
|
+
goto bad;
|
|
271
|
+
} else {
|
|
272
|
+
// believe the instance
|
|
273
|
+
type = instance_class;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (!instance_class) {
|
|
278
|
+
// instantiate the type now (we don't know when and how it will be caught)
|
|
279
|
+
// assuming that 'value' is an argument to the type's constructor
|
|
280
|
+
// not using PyErr_NormalizeException() to avoid ref-counting problems
|
|
281
|
+
PyObject *args;
|
|
282
|
+
if (!value)
|
|
283
|
+
args = PyTuple_New(0);
|
|
284
|
+
else if (PyTuple_Check(value)) {
|
|
285
|
+
Py_INCREF(value);
|
|
286
|
+
args = value;
|
|
287
|
+
} else
|
|
288
|
+
args = PyTuple_Pack(1, value);
|
|
289
|
+
if (!args)
|
|
290
|
+
goto bad;
|
|
291
|
+
owned_instance = PyObject_Call(type, args, NULL);
|
|
292
|
+
Py_DECREF(args);
|
|
293
|
+
if (!owned_instance)
|
|
294
|
+
goto bad;
|
|
295
|
+
value = owned_instance;
|
|
296
|
+
if (!PyExceptionInstance_Check(value)) {
|
|
297
|
+
PyErr_Format(PyExc_TypeError,
|
|
298
|
+
"calling %R should have returned an instance of "
|
|
299
|
+
"BaseException, not %R",
|
|
300
|
+
type, Py_TYPE(value));
|
|
301
|
+
goto bad;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
PyErr_SetString(PyExc_TypeError,
|
|
306
|
+
"raise: exception class must be a subclass of BaseException");
|
|
307
|
+
goto bad;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (cause) {
|
|
311
|
+
PyObject *fixed_cause;
|
|
312
|
+
if (cause == Py_None) {
|
|
313
|
+
// raise ... from None
|
|
314
|
+
fixed_cause = NULL;
|
|
315
|
+
} else if (PyExceptionClass_Check(cause)) {
|
|
316
|
+
fixed_cause = PyObject_CallObject(cause, NULL);
|
|
317
|
+
if (fixed_cause == NULL)
|
|
318
|
+
goto bad;
|
|
319
|
+
} else if (PyExceptionInstance_Check(cause)) {
|
|
320
|
+
fixed_cause = cause;
|
|
321
|
+
Py_INCREF(fixed_cause);
|
|
322
|
+
} else {
|
|
323
|
+
PyErr_SetString(PyExc_TypeError,
|
|
324
|
+
"exception causes must derive from "
|
|
325
|
+
"BaseException");
|
|
326
|
+
goto bad;
|
|
327
|
+
}
|
|
328
|
+
PyException_SetCause(value, fixed_cause);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
PyErr_SetObject(type, value);
|
|
332
|
+
|
|
333
|
+
if (tb) {
|
|
334
|
+
#if PY_VERSION_HEX >= 0x030C00A6
|
|
335
|
+
// If this fails, we just get a different exception, so ignore the return value.
|
|
336
|
+
PyException_SetTraceback(value, tb);
|
|
337
|
+
#elif CYTHON_FAST_THREAD_STATE
|
|
338
|
+
PyThreadState *tstate = __Pyx_PyThreadState_Current;
|
|
339
|
+
PyObject* tmp_tb = tstate->curexc_traceback;
|
|
340
|
+
if (tb != tmp_tb) {
|
|
341
|
+
Py_INCREF(tb);
|
|
342
|
+
tstate->curexc_traceback = tb;
|
|
343
|
+
Py_XDECREF(tmp_tb);
|
|
344
|
+
}
|
|
345
|
+
#else
|
|
346
|
+
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
|
347
|
+
PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
|
|
348
|
+
Py_INCREF(tb);
|
|
349
|
+
PyErr_Restore(tmp_type, tmp_value, tb);
|
|
350
|
+
Py_XDECREF(tmp_tb);
|
|
351
|
+
#endif
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
bad:
|
|
355
|
+
Py_XDECREF(owned_instance);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
/////////////// GetTopmostException.proto ///////////////
|
|
361
|
+
|
|
362
|
+
#if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
|
|
363
|
+
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
|
|
364
|
+
#endif
|
|
365
|
+
|
|
366
|
+
/////////////// GetTopmostException ///////////////
|
|
367
|
+
|
|
368
|
+
#if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
|
|
369
|
+
// Copied from errors.c in CPython.
|
|
370
|
+
static _PyErr_StackItem *
|
|
371
|
+
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
|
|
372
|
+
{
|
|
373
|
+
_PyErr_StackItem *exc_info = tstate->exc_info;
|
|
374
|
+
while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
|
|
375
|
+
exc_info->previous_item != NULL)
|
|
376
|
+
{
|
|
377
|
+
exc_info = exc_info->previous_item;
|
|
378
|
+
}
|
|
379
|
+
return exc_info;
|
|
380
|
+
}
|
|
381
|
+
#endif
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
/////////////// GetException.proto ///////////////
|
|
385
|
+
//@substitute: naming
|
|
386
|
+
//@requires: PyThreadStateGet
|
|
387
|
+
|
|
388
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
389
|
+
#define __Pyx_GetException(type, value, tb) __Pyx__GetException($local_tstate_cname, type, value, tb)
|
|
390
|
+
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
|
391
|
+
#else
|
|
392
|
+
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
|
393
|
+
#endif
|
|
394
|
+
|
|
395
|
+
/////////////// GetException ///////////////
|
|
396
|
+
|
|
397
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
398
|
+
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
|
|
399
|
+
#else
|
|
400
|
+
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
|
|
401
|
+
#endif
|
|
402
|
+
{
|
|
403
|
+
PyObject *local_type = NULL, *local_value, *local_tb = NULL;
|
|
404
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
405
|
+
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
|
406
|
+
#if PY_VERSION_HEX >= 0x030C0000
|
|
407
|
+
local_value = tstate->current_exception;
|
|
408
|
+
tstate->current_exception = 0;
|
|
409
|
+
#else
|
|
410
|
+
local_type = tstate->curexc_type;
|
|
411
|
+
local_value = tstate->curexc_value;
|
|
412
|
+
local_tb = tstate->curexc_traceback;
|
|
413
|
+
tstate->curexc_type = 0;
|
|
414
|
+
tstate->curexc_value = 0;
|
|
415
|
+
tstate->curexc_traceback = 0;
|
|
416
|
+
#endif
|
|
417
|
+
#elif __PYX_LIMITED_VERSION_HEX > 0x030C0000
|
|
418
|
+
local_value = PyErr_GetRaisedException();
|
|
419
|
+
#else
|
|
420
|
+
PyErr_Fetch(&local_type, &local_value, &local_tb);
|
|
421
|
+
#endif
|
|
422
|
+
|
|
423
|
+
#if __PYX_LIMITED_VERSION_HEX > 0x030C0000
|
|
424
|
+
if (likely(local_value)) {
|
|
425
|
+
local_type = (PyObject*) Py_TYPE(local_value);
|
|
426
|
+
Py_INCREF(local_type);
|
|
427
|
+
local_tb = PyException_GetTraceback(local_value);
|
|
428
|
+
}
|
|
429
|
+
#else
|
|
430
|
+
// Note that In Python 3.12+ exceptions are already normalized
|
|
431
|
+
PyErr_NormalizeException(&local_type, &local_value, &local_tb);
|
|
432
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
433
|
+
if (unlikely(tstate->curexc_type))
|
|
434
|
+
#else
|
|
435
|
+
if (unlikely(PyErr_Occurred()))
|
|
436
|
+
#endif
|
|
437
|
+
goto bad;
|
|
438
|
+
|
|
439
|
+
// Note that in Python 3.12 the traceback came directly from local_value anyway.
|
|
440
|
+
if (local_tb) {
|
|
441
|
+
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
|
|
442
|
+
goto bad;
|
|
443
|
+
}
|
|
444
|
+
#endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000
|
|
445
|
+
|
|
446
|
+
// traceback may be NULL for freshly raised exceptions
|
|
447
|
+
Py_XINCREF(local_tb);
|
|
448
|
+
// exception state may be empty in parallel loops (code-gen error where we don't generate a
|
|
449
|
+
// top-level PyGILState_Ensure surrounding the whole loop, and so releasing the GIL temporarily
|
|
450
|
+
// wipes the whole thread state).
|
|
451
|
+
Py_XINCREF(local_type);
|
|
452
|
+
Py_XINCREF(local_value);
|
|
453
|
+
*type = local_type;
|
|
454
|
+
*value = local_value;
|
|
455
|
+
*tb = local_tb;
|
|
456
|
+
|
|
457
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
458
|
+
#if CYTHON_USE_EXC_INFO_STACK
|
|
459
|
+
{
|
|
460
|
+
_PyErr_StackItem *exc_info = tstate->exc_info;
|
|
461
|
+
#if PY_VERSION_HEX >= 0x030B00a4
|
|
462
|
+
tmp_value = exc_info->exc_value;
|
|
463
|
+
exc_info->exc_value = local_value;
|
|
464
|
+
tmp_type = NULL;
|
|
465
|
+
tmp_tb = NULL;
|
|
466
|
+
Py_XDECREF(local_type);
|
|
467
|
+
Py_XDECREF(local_tb);
|
|
468
|
+
#else
|
|
469
|
+
tmp_type = exc_info->exc_type;
|
|
470
|
+
tmp_value = exc_info->exc_value;
|
|
471
|
+
tmp_tb = exc_info->exc_traceback;
|
|
472
|
+
exc_info->exc_type = local_type;
|
|
473
|
+
exc_info->exc_value = local_value;
|
|
474
|
+
exc_info->exc_traceback = local_tb;
|
|
475
|
+
#endif
|
|
476
|
+
}
|
|
477
|
+
#else
|
|
478
|
+
tmp_type = tstate->exc_type;
|
|
479
|
+
tmp_value = tstate->exc_value;
|
|
480
|
+
tmp_tb = tstate->exc_traceback;
|
|
481
|
+
tstate->exc_type = local_type;
|
|
482
|
+
tstate->exc_value = local_value;
|
|
483
|
+
tstate->exc_traceback = local_tb;
|
|
484
|
+
#endif
|
|
485
|
+
// Make sure tstate is in a consistent state when we XDECREF
|
|
486
|
+
// these objects (DECREF may run arbitrary code).
|
|
487
|
+
Py_XDECREF(tmp_type);
|
|
488
|
+
Py_XDECREF(tmp_value);
|
|
489
|
+
Py_XDECREF(tmp_tb);
|
|
490
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
|
|
491
|
+
PyErr_SetHandledException(local_value);
|
|
492
|
+
Py_XDECREF(local_value);
|
|
493
|
+
Py_XDECREF(local_type);
|
|
494
|
+
Py_XDECREF(local_tb);
|
|
495
|
+
#else
|
|
496
|
+
PyErr_SetExcInfo(local_type, local_value, local_tb);
|
|
497
|
+
#endif
|
|
498
|
+
|
|
499
|
+
return 0;
|
|
500
|
+
|
|
501
|
+
#if __PYX_LIMITED_VERSION_HEX <= 0x030C0000
|
|
502
|
+
bad:
|
|
503
|
+
*type = 0;
|
|
504
|
+
*value = 0;
|
|
505
|
+
*tb = 0;
|
|
506
|
+
Py_XDECREF(local_type);
|
|
507
|
+
Py_XDECREF(local_value);
|
|
508
|
+
Py_XDECREF(local_tb);
|
|
509
|
+
return -1;
|
|
510
|
+
#endif
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/////////////// ReRaiseException.proto ///////////////
|
|
514
|
+
|
|
515
|
+
static CYTHON_INLINE void __Pyx_ReraiseException(void); /*proto*/
|
|
516
|
+
|
|
517
|
+
/////////////// ReRaiseException ///////////////
|
|
518
|
+
//@requires: GetTopmostException
|
|
519
|
+
|
|
520
|
+
static CYTHON_INLINE void __Pyx_ReraiseException(void) {
|
|
521
|
+
PyObject *type = NULL, *value = NULL, *tb = NULL;
|
|
522
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
523
|
+
PyThreadState *tstate = PyThreadState_GET();
|
|
524
|
+
#if CYTHON_USE_EXC_INFO_STACK
|
|
525
|
+
_PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
|
|
526
|
+
value = exc_info->exc_value;
|
|
527
|
+
#if PY_VERSION_HEX >= 0x030B00a4
|
|
528
|
+
if (unlikely(value == Py_None)) {
|
|
529
|
+
value = NULL;
|
|
530
|
+
} else if (value) {
|
|
531
|
+
Py_INCREF(value);
|
|
532
|
+
type = (PyObject*) Py_TYPE(value);
|
|
533
|
+
Py_INCREF(type);
|
|
534
|
+
tb = PyException_GetTraceback(value);
|
|
535
|
+
}
|
|
536
|
+
#else
|
|
537
|
+
type = exc_info->exc_type;
|
|
538
|
+
tb = exc_info->exc_traceback;
|
|
539
|
+
Py_XINCREF(type);
|
|
540
|
+
Py_XINCREF(value);
|
|
541
|
+
Py_XINCREF(tb);
|
|
542
|
+
#endif
|
|
543
|
+
#else
|
|
544
|
+
type = tstate->exc_type;
|
|
545
|
+
value = tstate->exc_value;
|
|
546
|
+
tb = tstate->exc_traceback;
|
|
547
|
+
Py_XINCREF(type);
|
|
548
|
+
Py_XINCREF(value);
|
|
549
|
+
Py_XINCREF(tb);
|
|
550
|
+
#endif
|
|
551
|
+
#else
|
|
552
|
+
PyErr_GetExcInfo(&type, &value, &tb);
|
|
553
|
+
#endif
|
|
554
|
+
if (unlikely(!type || type == Py_None)) {
|
|
555
|
+
Py_XDECREF(type);
|
|
556
|
+
Py_XDECREF(value);
|
|
557
|
+
Py_XDECREF(tb);
|
|
558
|
+
// message copied from Py3
|
|
559
|
+
PyErr_SetString(PyExc_RuntimeError,
|
|
560
|
+
"No active exception to reraise");
|
|
561
|
+
} else {
|
|
562
|
+
PyErr_Restore(type, value, tb);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/////////////// SaveResetException.proto ///////////////
|
|
567
|
+
//@substitute: naming
|
|
568
|
+
//@requires: PyThreadStateGet
|
|
569
|
+
|
|
570
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
571
|
+
#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave($local_tstate_cname, type, value, tb)
|
|
572
|
+
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
|
573
|
+
#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset($local_tstate_cname, type, value, tb)
|
|
574
|
+
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/
|
|
575
|
+
|
|
576
|
+
#else
|
|
577
|
+
|
|
578
|
+
#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
|
|
579
|
+
#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
|
|
580
|
+
#endif
|
|
581
|
+
|
|
582
|
+
/////////////// SaveResetException ///////////////
|
|
583
|
+
//@requires: GetTopmostException
|
|
584
|
+
|
|
585
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
586
|
+
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
|
|
587
|
+
#if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
|
|
588
|
+
_PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
|
|
589
|
+
PyObject *exc_value = exc_info->exc_value;
|
|
590
|
+
if (exc_value == NULL || exc_value == Py_None) {
|
|
591
|
+
*value = NULL;
|
|
592
|
+
*type = NULL;
|
|
593
|
+
*tb = NULL;
|
|
594
|
+
} else {
|
|
595
|
+
*value = exc_value;
|
|
596
|
+
Py_INCREF(*value);
|
|
597
|
+
*type = (PyObject*) Py_TYPE(exc_value);
|
|
598
|
+
Py_INCREF(*type);
|
|
599
|
+
*tb = PyException_GetTraceback(exc_value);
|
|
600
|
+
}
|
|
601
|
+
#elif CYTHON_USE_EXC_INFO_STACK
|
|
602
|
+
_PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
|
|
603
|
+
*type = exc_info->exc_type;
|
|
604
|
+
*value = exc_info->exc_value;
|
|
605
|
+
*tb = exc_info->exc_traceback;
|
|
606
|
+
Py_XINCREF(*type);
|
|
607
|
+
Py_XINCREF(*value);
|
|
608
|
+
Py_XINCREF(*tb);
|
|
609
|
+
#else
|
|
610
|
+
*type = tstate->exc_type;
|
|
611
|
+
*value = tstate->exc_value;
|
|
612
|
+
*tb = tstate->exc_traceback;
|
|
613
|
+
Py_XINCREF(*type);
|
|
614
|
+
Py_XINCREF(*value);
|
|
615
|
+
Py_XINCREF(*tb);
|
|
616
|
+
#endif
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
|
|
620
|
+
#if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
|
|
621
|
+
_PyErr_StackItem *exc_info = tstate->exc_info;
|
|
622
|
+
PyObject *tmp_value = exc_info->exc_value;
|
|
623
|
+
exc_info->exc_value = value;
|
|
624
|
+
Py_XDECREF(tmp_value);
|
|
625
|
+
// TODO: avoid passing these at all
|
|
626
|
+
Py_XDECREF(type);
|
|
627
|
+
Py_XDECREF(tb);
|
|
628
|
+
#else
|
|
629
|
+
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
|
630
|
+
#if CYTHON_USE_EXC_INFO_STACK
|
|
631
|
+
_PyErr_StackItem *exc_info = tstate->exc_info;
|
|
632
|
+
tmp_type = exc_info->exc_type;
|
|
633
|
+
tmp_value = exc_info->exc_value;
|
|
634
|
+
tmp_tb = exc_info->exc_traceback;
|
|
635
|
+
exc_info->exc_type = type;
|
|
636
|
+
exc_info->exc_value = value;
|
|
637
|
+
exc_info->exc_traceback = tb;
|
|
638
|
+
#else
|
|
639
|
+
tmp_type = tstate->exc_type;
|
|
640
|
+
tmp_value = tstate->exc_value;
|
|
641
|
+
tmp_tb = tstate->exc_traceback;
|
|
642
|
+
tstate->exc_type = type;
|
|
643
|
+
tstate->exc_value = value;
|
|
644
|
+
tstate->exc_traceback = tb;
|
|
645
|
+
#endif
|
|
646
|
+
Py_XDECREF(tmp_type);
|
|
647
|
+
Py_XDECREF(tmp_value);
|
|
648
|
+
Py_XDECREF(tmp_tb);
|
|
649
|
+
#endif
|
|
650
|
+
}
|
|
651
|
+
#endif
|
|
652
|
+
|
|
653
|
+
/////////////// SwapException.proto ///////////////
|
|
654
|
+
//@substitute: naming
|
|
655
|
+
//@requires: PyThreadStateGet
|
|
656
|
+
|
|
657
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
658
|
+
#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap($local_tstate_cname, type, value, tb)
|
|
659
|
+
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
|
660
|
+
#else
|
|
661
|
+
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
|
662
|
+
#endif
|
|
663
|
+
|
|
664
|
+
/////////////// SwapException ///////////////
|
|
665
|
+
|
|
666
|
+
#if CYTHON_FAST_THREAD_STATE
|
|
667
|
+
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
|
|
668
|
+
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
|
669
|
+
#if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
|
|
670
|
+
_PyErr_StackItem *exc_info = tstate->exc_info;
|
|
671
|
+
tmp_value = exc_info->exc_value;
|
|
672
|
+
exc_info->exc_value = *value;
|
|
673
|
+
if (tmp_value == NULL || tmp_value == Py_None) {
|
|
674
|
+
Py_XDECREF(tmp_value);
|
|
675
|
+
tmp_value = NULL;
|
|
676
|
+
tmp_type = NULL;
|
|
677
|
+
tmp_tb = NULL;
|
|
678
|
+
} else {
|
|
679
|
+
// TODO: avoid swapping these at all
|
|
680
|
+
tmp_type = (PyObject*) Py_TYPE(tmp_value);
|
|
681
|
+
Py_INCREF(tmp_type);
|
|
682
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
683
|
+
tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
|
|
684
|
+
Py_XINCREF(tmp_tb);
|
|
685
|
+
#else
|
|
686
|
+
tmp_tb = PyException_GetTraceback(tmp_value);
|
|
687
|
+
#endif
|
|
688
|
+
}
|
|
689
|
+
#elif CYTHON_USE_EXC_INFO_STACK
|
|
690
|
+
_PyErr_StackItem *exc_info = tstate->exc_info;
|
|
691
|
+
tmp_type = exc_info->exc_type;
|
|
692
|
+
tmp_value = exc_info->exc_value;
|
|
693
|
+
tmp_tb = exc_info->exc_traceback;
|
|
694
|
+
|
|
695
|
+
exc_info->exc_type = *type;
|
|
696
|
+
exc_info->exc_value = *value;
|
|
697
|
+
exc_info->exc_traceback = *tb;
|
|
698
|
+
#else
|
|
699
|
+
tmp_type = tstate->exc_type;
|
|
700
|
+
tmp_value = tstate->exc_value;
|
|
701
|
+
tmp_tb = tstate->exc_traceback;
|
|
702
|
+
|
|
703
|
+
tstate->exc_type = *type;
|
|
704
|
+
tstate->exc_value = *value;
|
|
705
|
+
tstate->exc_traceback = *tb;
|
|
706
|
+
#endif
|
|
707
|
+
|
|
708
|
+
*type = tmp_type;
|
|
709
|
+
*value = tmp_value;
|
|
710
|
+
*tb = tmp_tb;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
#else
|
|
714
|
+
|
|
715
|
+
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
|
|
716
|
+
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
|
717
|
+
PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
|
|
718
|
+
PyErr_SetExcInfo(*type, *value, *tb);
|
|
719
|
+
*type = tmp_type;
|
|
720
|
+
*value = tmp_value;
|
|
721
|
+
*tb = tmp_tb;
|
|
722
|
+
}
|
|
723
|
+
#endif
|
|
724
|
+
|
|
725
|
+
/////////////// WriteUnraisableException.proto ///////////////
|
|
726
|
+
|
|
727
|
+
static void __Pyx_WriteUnraisable(const char *name, int clineno,
|
|
728
|
+
int lineno, const char *filename,
|
|
729
|
+
int full_traceback, int nogil); /*proto*/
|
|
730
|
+
|
|
731
|
+
/////////////// WriteUnraisableException ///////////////
|
|
732
|
+
//@requires: PyErrFetchRestore
|
|
733
|
+
//@requires: PyThreadStateGet
|
|
734
|
+
|
|
735
|
+
static void __Pyx_WriteUnraisable(const char *name, int clineno,
|
|
736
|
+
int lineno, const char *filename,
|
|
737
|
+
int full_traceback, int nogil) {
|
|
738
|
+
PyObject *old_exc, *old_val, *old_tb;
|
|
739
|
+
PyObject *ctx;
|
|
740
|
+
__Pyx_PyThreadState_declare
|
|
741
|
+
PyGILState_STATE state;
|
|
742
|
+
if (nogil)
|
|
743
|
+
state = PyGILState_Ensure();
|
|
744
|
+
/* arbitrary, to suppress warning */
|
|
745
|
+
else state = (PyGILState_STATE)0;
|
|
746
|
+
CYTHON_UNUSED_VAR(clineno);
|
|
747
|
+
CYTHON_UNUSED_VAR(lineno);
|
|
748
|
+
CYTHON_UNUSED_VAR(filename);
|
|
749
|
+
CYTHON_MAYBE_UNUSED_VAR(nogil);
|
|
750
|
+
|
|
751
|
+
__Pyx_PyThreadState_assign
|
|
752
|
+
__Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
|
|
753
|
+
if (full_traceback) {
|
|
754
|
+
Py_XINCREF(old_exc);
|
|
755
|
+
Py_XINCREF(old_val);
|
|
756
|
+
Py_XINCREF(old_tb);
|
|
757
|
+
__Pyx_ErrRestore(old_exc, old_val, old_tb);
|
|
758
|
+
PyErr_PrintEx(0);
|
|
759
|
+
}
|
|
760
|
+
ctx = PyUnicode_FromString(name);
|
|
761
|
+
__Pyx_ErrRestore(old_exc, old_val, old_tb);
|
|
762
|
+
if (!ctx) {
|
|
763
|
+
PyErr_WriteUnraisable(Py_None);
|
|
764
|
+
} else {
|
|
765
|
+
PyErr_WriteUnraisable(ctx);
|
|
766
|
+
Py_DECREF(ctx);
|
|
767
|
+
}
|
|
768
|
+
if (nogil)
|
|
769
|
+
PyGILState_Release(state);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/////////////// CLineInTraceback.proto ///////////////
|
|
773
|
+
|
|
774
|
+
#if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
|
|
775
|
+
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);/*proto*/
|
|
776
|
+
#else
|
|
777
|
+
#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
|
|
778
|
+
#endif
|
|
779
|
+
|
|
780
|
+
/////////////// CLineInTraceback ///////////////
|
|
781
|
+
//@requires: ObjectHandling.c::PyObjectGetAttrStrNoError
|
|
782
|
+
//@requires: ObjectHandling.c::PyDictVersioning
|
|
783
|
+
//@requires: PyErrFetchRestore
|
|
784
|
+
//@requires: Builtins.c::dict_setdefault
|
|
785
|
+
|
|
786
|
+
#if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
|
|
787
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
788
|
+
// On earlier version of the Limited API we're less flexible and assume it's
|
|
789
|
+
// definitely a module. Which will break some odd user monkey-patching...
|
|
790
|
+
#define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
|
|
791
|
+
#elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
792
|
+
// On freethreading, use PyObject_GenericGetDict to avoid having to think too hard
|
|
793
|
+
// about atomics and _PyObject_GetDictPtr.
|
|
794
|
+
#define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
|
|
795
|
+
#else
|
|
796
|
+
PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
|
|
797
|
+
PyObject **dict_ptr = _PyObject_GetDictPtr(o);
|
|
798
|
+
return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
|
|
799
|
+
}
|
|
800
|
+
#endif
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
|
|
804
|
+
PyObject *use_cline = NULL;
|
|
805
|
+
PyObject *ptype, *pvalue, *ptraceback;
|
|
806
|
+
PyObject *cython_runtime_dict;
|
|
807
|
+
|
|
808
|
+
CYTHON_MAYBE_UNUSED_VAR(tstate);
|
|
809
|
+
|
|
810
|
+
if (unlikely(!NAMED_CGLOBAL(cython_runtime_cname))) {
|
|
811
|
+
// Very early error where the runtime module is not set up yet.
|
|
812
|
+
return c_line;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
|
|
816
|
+
|
|
817
|
+
cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(NAMED_CGLOBAL(cython_runtime_cname));
|
|
818
|
+
if (likely(cython_runtime_dict)) {
|
|
819
|
+
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
|
|
820
|
+
use_cline, cython_runtime_dict,
|
|
821
|
+
__Pyx_PyDict_SetDefault(cython_runtime_dict, PYIDENT("cline_in_traceback"), Py_False))
|
|
822
|
+
}
|
|
823
|
+
if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
|
|
824
|
+
c_line = 0;
|
|
825
|
+
}
|
|
826
|
+
Py_XDECREF(use_cline);
|
|
827
|
+
Py_XDECREF(cython_runtime_dict);
|
|
828
|
+
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
|
|
829
|
+
return c_line;
|
|
830
|
+
}
|
|
831
|
+
#endif
|
|
832
|
+
|
|
833
|
+
/////////////// AddTraceback.proto ///////////////
|
|
834
|
+
|
|
835
|
+
static void __Pyx_AddTraceback(const char *funcname, int c_line,
|
|
836
|
+
int py_line, const char *filename); /*proto*/
|
|
837
|
+
|
|
838
|
+
/////////////// AddTraceback ///////////////
|
|
839
|
+
//@requires: ModuleSetupCode.c::CodeObjectCache
|
|
840
|
+
//@requires: CLineInTraceback
|
|
841
|
+
//@substitute: naming
|
|
842
|
+
|
|
843
|
+
#include "compile.h"
|
|
844
|
+
#include "frameobject.h"
|
|
845
|
+
#include "traceback.h"
|
|
846
|
+
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
|
|
847
|
+
#ifndef Py_BUILD_CORE
|
|
848
|
+
#define Py_BUILD_CORE 1
|
|
849
|
+
#endif
|
|
850
|
+
#include "internal/pycore_frame.h"
|
|
851
|
+
#endif
|
|
852
|
+
|
|
853
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
854
|
+
static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
|
|
855
|
+
PyObject *firstlineno, PyObject *name) {
|
|
856
|
+
PyObject *replace = NULL;
|
|
857
|
+
if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
|
|
858
|
+
if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
|
|
859
|
+
|
|
860
|
+
replace = PyObject_GetAttrString(code, "replace");
|
|
861
|
+
if (likely(replace)) {
|
|
862
|
+
PyObject *result = PyObject_Call(replace, EMPTY(tuple), scratch_dict);
|
|
863
|
+
Py_DECREF(replace);
|
|
864
|
+
return result;
|
|
865
|
+
}
|
|
866
|
+
PyErr_Clear();
|
|
867
|
+
|
|
868
|
+
return NULL;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
static void __Pyx_AddTraceback(const char *funcname, int c_line,
|
|
872
|
+
int py_line, const char *filename) {
|
|
873
|
+
PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
|
|
874
|
+
PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
|
|
875
|
+
PyObject *exc_type, *exc_value, *exc_traceback;
|
|
876
|
+
int success = 0;
|
|
877
|
+
if (c_line) {
|
|
878
|
+
c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// DW - this is a horrendous hack, but I'm quite proud of it. Essentially
|
|
882
|
+
// we need to generate a frame with the right line number/filename/funcname.
|
|
883
|
+
// We do this by compiling a small bit of code that uses sys._getframe to get a
|
|
884
|
+
// frame, and then customizing the details of the code to match.
|
|
885
|
+
// We then run the code object and use the generated frame to set the traceback.
|
|
886
|
+
|
|
887
|
+
PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
|
|
888
|
+
|
|
889
|
+
code_object = $global_code_object_cache_find(c_line ? -c_line : py_line);
|
|
890
|
+
if (!code_object) {
|
|
891
|
+
code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
|
|
892
|
+
if (unlikely(!code_object)) goto bad;
|
|
893
|
+
py_py_line = PyLong_FromLong(py_line);
|
|
894
|
+
if (unlikely(!py_py_line)) goto bad;
|
|
895
|
+
if (c_line) {
|
|
896
|
+
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line);
|
|
897
|
+
} else {
|
|
898
|
+
py_funcname = PyUnicode_FromString(funcname);
|
|
899
|
+
}
|
|
900
|
+
if (unlikely(!py_funcname)) goto bad;
|
|
901
|
+
dict = PyDict_New();
|
|
902
|
+
if (unlikely(!dict)) goto bad;
|
|
903
|
+
{
|
|
904
|
+
PyObject *old_code_object = code_object;
|
|
905
|
+
code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
|
|
906
|
+
Py_DECREF(old_code_object);
|
|
907
|
+
}
|
|
908
|
+
if (unlikely(!code_object)) goto bad;
|
|
909
|
+
|
|
910
|
+
$global_code_object_cache_insert(c_line ? -c_line : py_line, code_object);
|
|
911
|
+
} else {
|
|
912
|
+
// The frame part still expects a dict
|
|
913
|
+
dict = PyDict_New();
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// Note that getframe is borrowed
|
|
917
|
+
getframe = PySys_GetObject("_getframe");
|
|
918
|
+
if (unlikely(!getframe)) goto bad;
|
|
919
|
+
// reuse dict as globals (nothing conflicts, and it saves an allocation)
|
|
920
|
+
if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
|
|
921
|
+
|
|
922
|
+
frame = PyEval_EvalCode(code_object, dict, dict);
|
|
923
|
+
if (unlikely(!frame) || frame == Py_None) goto bad;
|
|
924
|
+
success = 1;
|
|
925
|
+
|
|
926
|
+
bad:
|
|
927
|
+
PyErr_Restore(exc_type, exc_value, exc_traceback);
|
|
928
|
+
Py_XDECREF(code_object);
|
|
929
|
+
Py_XDECREF(py_py_line);
|
|
930
|
+
Py_XDECREF(py_funcname);
|
|
931
|
+
Py_XDECREF(dict);
|
|
932
|
+
Py_XDECREF(replace);
|
|
933
|
+
|
|
934
|
+
if (success) {
|
|
935
|
+
// Unfortunately an easy way to check the type of frame isn't in the
|
|
936
|
+
// limited API. The check against None should cover the most
|
|
937
|
+
// likely wrong answer though.
|
|
938
|
+
PyTraceBack_Here(
|
|
939
|
+
// Python < 0x03090000 didn't expose PyFrameObject
|
|
940
|
+
// but they all expose struct _frame as an opaque type
|
|
941
|
+
(struct _frame*)frame);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
Py_XDECREF(frame);
|
|
945
|
+
}
|
|
946
|
+
#else
|
|
947
|
+
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
|
|
948
|
+
const char *funcname, int c_line,
|
|
949
|
+
int py_line, const char *filename) {
|
|
950
|
+
PyCodeObject *py_code = NULL;
|
|
951
|
+
PyObject *py_funcname = NULL;
|
|
952
|
+
|
|
953
|
+
if (c_line) {
|
|
954
|
+
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line);
|
|
955
|
+
if (!py_funcname) goto bad;
|
|
956
|
+
funcname = PyUnicode_AsUTF8(py_funcname);
|
|
957
|
+
if (!funcname) goto bad;
|
|
958
|
+
}
|
|
959
|
+
py_code = PyCode_NewEmpty(filename, funcname, py_line);
|
|
960
|
+
Py_XDECREF(py_funcname); /* XDECREF since it's only set on Py3 if cline */
|
|
961
|
+
return py_code;
|
|
962
|
+
bad:
|
|
963
|
+
Py_XDECREF(py_funcname);
|
|
964
|
+
return NULL;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
static void __Pyx_AddTraceback(const char *funcname, int c_line,
|
|
968
|
+
int py_line, const char *filename) {
|
|
969
|
+
PyCodeObject *py_code = 0;
|
|
970
|
+
PyFrameObject *py_frame = 0;
|
|
971
|
+
PyThreadState *tstate = __Pyx_PyThreadState_Current;
|
|
972
|
+
PyObject *ptype, *pvalue, *ptraceback;
|
|
973
|
+
|
|
974
|
+
if (c_line) {
|
|
975
|
+
c_line = __Pyx_CLineForTraceback(tstate, c_line);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// Negate to avoid collisions between py and c lines.
|
|
979
|
+
py_code = $global_code_object_cache_find(c_line ? -c_line : py_line);
|
|
980
|
+
if (!py_code) {
|
|
981
|
+
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
|
|
982
|
+
py_code = __Pyx_CreateCodeObjectForTraceback(
|
|
983
|
+
funcname, c_line, py_line, filename);
|
|
984
|
+
if (!py_code) {
|
|
985
|
+
/* If the code object creation fails, then we should clear the
|
|
986
|
+
fetched exception references and propagate the new exception */
|
|
987
|
+
Py_XDECREF(ptype);
|
|
988
|
+
Py_XDECREF(pvalue);
|
|
989
|
+
Py_XDECREF(ptraceback);
|
|
990
|
+
goto bad;
|
|
991
|
+
}
|
|
992
|
+
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
|
|
993
|
+
$global_code_object_cache_insert(c_line ? -c_line : py_line, py_code);
|
|
994
|
+
}
|
|
995
|
+
py_frame = PyFrame_New(
|
|
996
|
+
tstate, /*PyThreadState *tstate,*/
|
|
997
|
+
py_code, /*PyCodeObject *code,*/
|
|
998
|
+
NAMED_CGLOBAL(moddict_cname), /*PyObject *globals,*/
|
|
999
|
+
0 /*PyObject *locals*/
|
|
1000
|
+
);
|
|
1001
|
+
if (!py_frame) goto bad;
|
|
1002
|
+
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
|
|
1003
|
+
PyTraceBack_Here(py_frame);
|
|
1004
|
+
bad:
|
|
1005
|
+
Py_XDECREF(py_code);
|
|
1006
|
+
Py_XDECREF(py_frame);
|
|
1007
|
+
}
|
|
1008
|
+
#endif
|
|
1009
|
+
|
|
1010
|
+
///////////////////////////// FloatExceptionCheck.proto ///////////////////////////
|
|
1011
|
+
|
|
1012
|
+
// Detect if error_value is NaN, and use a different check in that case
|
|
1013
|
+
#define __PYX_CHECK_FLOAT_EXCEPTION(value, error_value) \
|
|
1014
|
+
((error_value) == (error_value) ? \
|
|
1015
|
+
(value) == (error_value) : \
|
|
1016
|
+
(value) != (value))
|