Nuitka-winsvc 2.4.8__cp311-cp311-win_amd64.whl → 2.5.1__cp311-cp311-win_amd64.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.
Potentially problematic release.
This version of Nuitka-winsvc might be problematic. Click here for more details.
- {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/METADATA +2 -1
- {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/RECORD +294 -271
- {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/WHEEL +1 -1
- nuitka/Builtins.py +31 -0
- nuitka/HardImportRegistry.py +8 -0
- nuitka/MainControl.py +9 -4
- nuitka/OptionParsing.py +105 -52
- nuitka/Options.py +73 -16
- nuitka/OutputDirectories.py +7 -2
- nuitka/PostProcessing.py +69 -38
- nuitka/Progress.py +16 -1
- nuitka/PythonVersions.py +2 -1
- nuitka/Serialization.py +4 -2
- nuitka/Tracing.py +69 -1
- nuitka/Version.py +2 -2
- nuitka/build/Backend.scons +45 -5
- nuitka/build/CCompilerVersion.scons +6 -0
- nuitka/build/Onefile.scons +6 -0
- nuitka/build/SconsCaching.py +12 -2
- nuitka/build/SconsCompilerSettings.py +17 -6
- nuitka/build/SconsInterface.py +1 -0
- nuitka/build/SconsUtils.py +5 -0
- nuitka/build/include/nuitka/allocator.h +124 -1
- nuitka/build/include/nuitka/calling.h +6 -6
- nuitka/build/include/nuitka/compiled_asyncgen.h +10 -7
- nuitka/build/include/nuitka/compiled_frame.h +2 -1
- nuitka/build/include/nuitka/constants.h +6 -0
- nuitka/build/include/nuitka/debug_settings.h +60 -0
- nuitka/build/include/nuitka/exceptions.h +264 -121
- nuitka/build/include/nuitka/helper/attributes.h +0 -4
- nuitka/build/include/nuitka/helper/calling_generated.h +52 -52
- nuitka/build/include/nuitka/helper/comparisons_dual_eq.h +47 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_ge.h +39 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_gt.h +39 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_le.h +47 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_lt.h +47 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_ne.h +39 -0
- nuitka/build/include/nuitka/helper/dictionaries.h +65 -29
- nuitka/build/include/nuitka/helper/ints.h +86 -37
- nuitka/build/include/nuitka/helper/iterators.h +82 -34
- nuitka/build/include/nuitka/helper/operations.h +3 -0
- nuitka/build/include/nuitka/helper/operations_binary_add.h +6 -0
- nuitka/build/include/nuitka/helper/operations_binary_dual_add.h +34 -0
- nuitka/build/include/nuitka/helper/operations_binary_sub.h +6 -0
- nuitka/build/include/nuitka/helper/operations_inplace_add.h +3 -0
- nuitka/build/include/nuitka/helper/operations_inplace_sub.h +3 -0
- nuitka/build/include/nuitka/helper/raising.h +47 -28
- nuitka/build/include/nuitka/helper/richcomparisons.h +7 -0
- nuitka/build/include/nuitka/helpers.h +12 -2
- nuitka/build/include/nuitka/prelude.h +35 -25
- nuitka/build/include/nuitka/printing.h +9 -7
- nuitka/build/include/nuitka/threading.h +15 -1
- nuitka/build/include/nuitka/type_aliases.h +3 -0
- nuitka/build/inline_copy/stubgen/astunparse.py +938 -0
- nuitka/build/inline_copy/stubgen/six.py +998 -0
- nuitka/build/inline_copy/stubgen/stubgen.py +307 -0
- nuitka/build/static_src/CompiledAsyncgenType.c +45 -39
- nuitka/build/static_src/CompiledCellType.c +6 -4
- nuitka/build/static_src/CompiledCodeHelpers.c +104 -40
- nuitka/build/static_src/CompiledCoroutineType.c +40 -30
- nuitka/build/static_src/CompiledFrameType.c +110 -79
- nuitka/build/static_src/CompiledFunctionType.c +173 -151
- nuitka/build/static_src/CompiledGeneratorType.c +51 -49
- nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +424 -46
- nuitka/build/static_src/CompiledMethodType.c +10 -13
- nuitka/build/static_src/HelpersAllocator.c +270 -32
- nuitka/build/static_src/HelpersAttributes.c +0 -21
- nuitka/build/static_src/HelpersBuiltin.c +22 -13
- nuitka/build/static_src/HelpersCalling.c +7 -7
- nuitka/build/static_src/HelpersCallingGenerated.c +70 -70
- nuitka/build/static_src/HelpersComparisonDualEq.c +183 -0
- nuitka/build/static_src/HelpersComparisonDualGe.c +121 -0
- nuitka/build/static_src/HelpersComparisonDualGt.c +121 -0
- nuitka/build/static_src/HelpersComparisonDualLe.c +183 -0
- nuitka/build/static_src/HelpersComparisonDualLt.c +183 -0
- nuitka/build/static_src/HelpersComparisonDualNe.c +121 -0
- nuitka/build/static_src/HelpersComparisonEq.c +18 -4
- nuitka/build/static_src/HelpersComparisonEqUtils.c +1 -0
- nuitka/build/static_src/HelpersComparisonGe.c +18 -4
- nuitka/build/static_src/HelpersComparisonGt.c +18 -4
- nuitka/build/static_src/HelpersComparisonLe.c +18 -4
- nuitka/build/static_src/HelpersComparisonLt.c +18 -4
- nuitka/build/static_src/HelpersComparisonNe.c +18 -4
- nuitka/build/static_src/HelpersConsole.c +34 -8
- nuitka/build/static_src/HelpersConstantsBlob.c +10 -4
- nuitka/build/static_src/HelpersDictionaries.c +181 -34
- nuitka/build/static_src/HelpersDictionariesGenerated.c +0 -106
- nuitka/build/static_src/HelpersExceptions.c +24 -50
- nuitka/build/static_src/HelpersFiles.c +79 -5
- nuitka/build/static_src/HelpersImport.c +13 -9
- nuitka/build/static_src/HelpersImportHard.c +23 -46
- nuitka/build/static_src/HelpersLists.c +98 -9
- nuitka/build/static_src/HelpersMatching.c +1 -1
- nuitka/build/static_src/HelpersOperationBinaryAdd.c +224 -6
- nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +3 -0
- nuitka/build/static_src/HelpersOperationBinaryBitand.c +5 -5
- nuitka/build/static_src/HelpersOperationBinaryBitor.c +5 -5
- nuitka/build/static_src/HelpersOperationBinaryBitxor.c +5 -5
- nuitka/build/static_src/HelpersOperationBinaryDivmod.c +8 -2
- nuitka/build/static_src/HelpersOperationBinaryDualAdd.c +172 -0
- nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +14 -8
- nuitka/build/static_src/HelpersOperationBinaryLshift.c +36 -36
- nuitka/build/static_src/HelpersOperationBinaryMatmult.c +1 -0
- nuitka/build/static_src/HelpersOperationBinaryMod.c +22 -10
- nuitka/build/static_src/HelpersOperationBinaryMult.c +17 -7
- nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +14 -8
- nuitka/build/static_src/HelpersOperationBinaryPow.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryRshift.c +4 -4
- nuitka/build/static_src/HelpersOperationBinarySub.c +229 -8
- nuitka/build/static_src/HelpersOperationBinaryTruediv.c +8 -2
- nuitka/build/static_src/HelpersOperationInplaceAdd.c +162 -10
- nuitka/build/static_src/HelpersOperationInplaceBitand.c +5 -5
- nuitka/build/static_src/HelpersOperationInplaceBitor.c +5 -5
- nuitka/build/static_src/HelpersOperationInplaceBitxor.c +5 -5
- nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +11 -6
- nuitka/build/static_src/HelpersOperationInplaceLshift.c +20 -20
- nuitka/build/static_src/HelpersOperationInplaceMatmult.c +1 -0
- nuitka/build/static_src/HelpersOperationInplaceMod.c +11 -6
- nuitka/build/static_src/HelpersOperationInplaceMult.c +11 -6
- nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +11 -6
- nuitka/build/static_src/HelpersOperationInplacePow.c +20 -20
- nuitka/build/static_src/HelpersOperationInplaceRshift.c +4 -4
- nuitka/build/static_src/HelpersOperationInplaceSub.c +163 -10
- nuitka/build/static_src/HelpersOperationInplaceTruediv.c +6 -1
- nuitka/build/static_src/HelpersProfiling.c +1 -1
- nuitka/build/static_src/HelpersRaising.c +255 -310
- nuitka/build/static_src/HelpersStrings.c +1 -1
- nuitka/build/static_src/HelpersTuples.c +1 -1
- nuitka/build/static_src/HelpersTypes.c +98 -2
- nuitka/build/static_src/MainProgram.c +117 -29
- nuitka/build/static_src/MetaPathBasedLoader.c +18 -19
- nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +134 -11
- nuitka/build/static_src/OnefileBootstrap.c +6 -1
- nuitka/code_generation/AsyncgenCodes.py +2 -6
- nuitka/code_generation/BinaryOperationHelperDefinitions.py +269 -167
- nuitka/code_generation/BuiltinCodes.py +9 -1
- nuitka/code_generation/CallCodes.py +16 -16
- nuitka/code_generation/CodeGeneration.py +14 -2
- nuitka/code_generation/CodeHelperSelection.py +1 -1
- nuitka/code_generation/CodeHelpers.py +4 -1
- nuitka/code_generation/CodeObjectCodes.py +2 -2
- nuitka/code_generation/ComparisonCodes.py +13 -2
- nuitka/code_generation/ComparisonHelperDefinitions.py +23 -8
- nuitka/code_generation/Contexts.py +28 -16
- nuitka/code_generation/CoroutineCodes.py +2 -6
- nuitka/code_generation/DictCodes.py +3 -3
- nuitka/code_generation/ErrorCodes.py +34 -50
- nuitka/code_generation/ExceptionCodes.py +165 -96
- nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +25 -10
- nuitka/code_generation/FrameCodes.py +4 -11
- nuitka/code_generation/FunctionCodes.py +2 -6
- nuitka/code_generation/GeneratorCodes.py +2 -6
- nuitka/code_generation/GlobalConstants.py +8 -2
- nuitka/code_generation/GlobalsLocalsCodes.py +2 -2
- nuitka/code_generation/IteratorCodes.py +67 -54
- nuitka/code_generation/LineNumberCodes.py +1 -3
- nuitka/code_generation/ModuleCodes.py +28 -4
- nuitka/code_generation/OperationCodes.py +51 -20
- nuitka/code_generation/PackageResourceCodes.py +37 -0
- nuitka/code_generation/RaisingCodes.py +164 -90
- nuitka/code_generation/Reports.py +13 -5
- nuitka/code_generation/ReturnCodes.py +2 -16
- nuitka/code_generation/TryCodes.py +12 -24
- nuitka/code_generation/TypeAliasCodes.py +48 -0
- nuitka/code_generation/VariableCodes.py +99 -40
- nuitka/code_generation/VariableDeclarations.py +8 -8
- nuitka/code_generation/YieldCodes.py +1 -1
- nuitka/code_generation/c_types/CTypeBases.py +10 -2
- nuitka/code_generation/c_types/CTypeModuleDictVariables.py +3 -0
- nuitka/code_generation/c_types/CTypeNuitkaBooleans.py +3 -4
- nuitka/code_generation/c_types/CTypeNuitkaInts.py +70 -25
- nuitka/code_generation/c_types/CTypeNuitkaVoids.py +1 -1
- nuitka/code_generation/c_types/CTypePyObjectPointers.py +16 -6
- nuitka/code_generation/templates/CodeTemplatesAsyncgens.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesConstants.py +11 -3
- nuitka/code_generation/templates/CodeTemplatesCoroutines.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesExceptions.py +15 -16
- nuitka/code_generation/templates/CodeTemplatesFrames.py +18 -10
- nuitka/code_generation/templates/CodeTemplatesFunction.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesGeneratorFunction.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesIterators.py +1 -35
- nuitka/code_generation/templates/CodeTemplatesModules.py +34 -4
- nuitka/code_generation/templates/CodeTemplatesVariables.py +73 -0
- nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +3 -3
- nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +0 -105
- nuitka/code_generation/templates_c/HelperImportHard.c.j2 +1 -2
- nuitka/code_generation/templates_c/HelperLongTools.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationBinaryDual.c.j2 +115 -0
- nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +9 -9
- nuitka/code_generation/templates_c/HelperOperationComparisonDual.c.j2 +86 -0
- nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +9 -9
- nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +9 -9
- nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -4
- nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperSlotsInt.c.j2 +31 -31
- nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +1 -1
- nuitka/containers/Namedtuples.py +6 -0
- nuitka/containers/OrderedSets.py +105 -5
- nuitka/distutils/Build.py +14 -0
- nuitka/distutils/DistutilCommands.py +50 -10
- nuitka/finalizations/Finalization.py +3 -3
- nuitka/finalizations/FinalizeMarkups.py +10 -14
- nuitka/freezer/DependsExe.py +13 -3
- nuitka/freezer/DllDependenciesMacOS.py +18 -1
- nuitka/freezer/DllDependenciesWin32.py +26 -12
- nuitka/freezer/ImportDetection.py +3 -0
- nuitka/freezer/IncludedDataFiles.py +31 -8
- nuitka/freezer/IncludedEntryPoints.py +3 -2
- nuitka/freezer/Standalone.py +76 -18
- nuitka/importing/Importing.py +33 -6
- nuitka/importing/Recursion.py +12 -1
- nuitka/importing/StandardLibrary.py +57 -59
- nuitka/nodes/AsyncgenNodes.py +3 -6
- nuitka/nodes/BuiltinIteratorNodes.py +1 -1
- nuitka/nodes/BuiltinRefNodes.py +14 -30
- nuitka/nodes/ChildrenHavingMixins.py +439 -46
- nuitka/nodes/ConditionalNodes.py +3 -2
- nuitka/nodes/CoroutineNodes.py +3 -6
- nuitka/nodes/ExceptionNodes.py +102 -26
- nuitka/nodes/ExpressionBasesGenerated.py +288 -4
- nuitka/nodes/FrameNodes.py +22 -11
- nuitka/nodes/FunctionNodes.py +3 -3
- nuitka/nodes/GeneratorNodes.py +3 -6
- nuitka/nodes/HardImportNodesGenerated.py +182 -0
- nuitka/nodes/ImportNodes.py +2 -2
- nuitka/nodes/NodeBases.py +28 -1
- nuitka/nodes/NodeMakingHelpers.py +71 -50
- nuitka/nodes/OperatorNodesUnary.py +128 -3
- nuitka/nodes/OsSysNodes.py +37 -6
- nuitka/nodes/OutlineNodes.py +2 -2
- nuitka/nodes/StatementBasesGenerated.py +0 -2
- nuitka/nodes/StatementNodes.py +8 -7
- nuitka/nodes/SubscriptNodes.py +1 -1
- nuitka/nodes/TypeNodes.py +28 -1
- nuitka/nodes/shapes/BuiltinTypeShapes.py +24 -7
- nuitka/nodes/shapes/ShapeMixins.py +17 -0
- nuitka/nodes/shapes/StandardShapes.py +53 -1
- nuitka/optimizations/BytecodeDemotion.py +2 -1
- nuitka/plugins/PluginBase.py +64 -22
- nuitka/plugins/Plugins.py +6 -3
- nuitka/plugins/standard/AntiBloatPlugin.py +23 -12
- nuitka/plugins/standard/ImplicitImports.py +1 -13
- nuitka/plugins/standard/KivyPlugin.py +3 -12
- nuitka/plugins/standard/MatplotlibPlugin.py +12 -1
- nuitka/plugins/standard/MultiprocessingPlugin.py +11 -20
- nuitka/plugins/standard/PlaywrightPlugin.py +184 -0
- nuitka/plugins/standard/PySidePyQtPlugin.py +8 -0
- nuitka/plugins/standard/TkinterPlugin.py +0 -56
- nuitka/plugins/standard/TransformersPlugin.py +70 -275
- nuitka/plugins/standard/standard.nuitka-package.config.yml +510 -28
- nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +35 -2
- nuitka/reports/CompilationReportReader.py +12 -0
- nuitka/reports/Reports.py +11 -0
- nuitka/specs/BuiltinParameterSpecs.py +5 -1
- nuitka/specs/HardImportSpecs.py +7 -0
- nuitka/specs/ParameterSpecs.py +4 -4
- nuitka/tools/general/dll_report/__main__.py +10 -1
- nuitka/tools/onefile_compressor/OnefileCompressor.py +1 -1
- nuitka/tools/specialize/CTypeDescriptions.py +158 -9
- nuitka/tools/specialize/SpecializeC.py +218 -56
- nuitka/tools/testing/Common.py +70 -63
- nuitka/tools/testing/compare_with_cpython/__main__.py +3 -1
- nuitka/tools/testing/measure_construct_performance/__main__.py +1 -8
- nuitka/tools/testing/run_nuitka_tests/__main__.py +77 -11
- nuitka/tools/watch/AutoStage.py +1 -0
- nuitka/tree/Building.py +10 -37
- nuitka/tree/ComplexCallHelperFunctions.py +4 -0
- nuitka/tree/ReformulationAssertStatements.py +31 -14
- nuitka/tree/ReformulationAssignmentStatements.py +5 -1
- nuitka/tree/ReformulationClasses3.py +94 -19
- nuitka/tree/ReformulationDictionaryCreation.py +1 -0
- nuitka/tree/ReformulationFunctionStatements.py +1 -1
- nuitka/tree/ReformulationMatchStatements.py +3 -1
- nuitka/tree/ReformulationYieldExpressions.py +23 -5
- nuitka/utils/CommandLineOptions.py +27 -3
- nuitka/utils/Download.py +2 -2
- nuitka/utils/Execution.py +36 -31
- nuitka/utils/FileOperations.py +39 -54
- nuitka/utils/Importing.py +2 -14
- nuitka/utils/InlineCopies.py +52 -0
- nuitka/utils/InstalledPythons.py +9 -4
- nuitka/utils/Json.py +2 -2
- nuitka/utils/PackageResources.py +44 -0
- nuitka/utils/Utils.py +17 -0
- {Nuitka_winsvc-2.4.8.data → Nuitka_winsvc-2.5.1.data}/scripts/nuitka-run.cmd +0 -0
- {Nuitka_winsvc-2.4.8.data → Nuitka_winsvc-2.5.1.data}/scripts/nuitka.cmd +0 -0
- {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/top_level.txt +0 -0
|
@@ -40,35 +40,6 @@ NUITKA_MAY_BE_UNUSED static inline void ASSERT_NORMALIZED_EXCEPTION_VALUE(PyObje
|
|
|
40
40
|
assert(PyExceptionInstance_Check(exception_value));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
extern void Nuitka_Err_NormalizeException(PyThreadState *tstate, PyObject **exc, PyObject **val,
|
|
44
|
-
PyTracebackObject **tb);
|
|
45
|
-
|
|
46
|
-
// Normalize an exception, may release old values and replace them, expects
|
|
47
|
-
// references passed and returns them.
|
|
48
|
-
NUITKA_MAY_BE_UNUSED static inline void NORMALIZE_EXCEPTION(PyThreadState *tstate, PyObject **exception_type,
|
|
49
|
-
PyObject **exception_value,
|
|
50
|
-
PyTracebackObject **exception_tb) {
|
|
51
|
-
#if _DEBUG_EXCEPTIONS
|
|
52
|
-
PRINT_STRING("NORMALIZE_EXCEPTION: Enter\n");
|
|
53
|
-
PRINT_EXCEPTION(*exception_type, *exception_value, *exception_tb);
|
|
54
|
-
#endif
|
|
55
|
-
CHECK_OBJECT_X(*exception_type);
|
|
56
|
-
CHECK_OBJECT_X(*exception_value);
|
|
57
|
-
if (exception_tb) {
|
|
58
|
-
CHECK_OBJECT_X(*exception_tb);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// TODO: Often we already know this to be true.
|
|
62
|
-
if (*exception_type != Py_None && *exception_type != NULL) {
|
|
63
|
-
Nuitka_Err_NormalizeException(tstate, exception_type, exception_value, exception_tb);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
#if _DEBUG_EXCEPTIONS
|
|
67
|
-
PRINT_STRING("NORMALIZE_EXCEPTION: Leave\n");
|
|
68
|
-
PRINT_EXCEPTION(*exception_type, *exception_value, exception_tb ? *exception_tb : NULL);
|
|
69
|
-
#endif
|
|
70
|
-
}
|
|
71
|
-
|
|
72
43
|
// Clear error, which likely set, similar to "_PyErr_Clear(tstate)" and "PyErr_Clear"
|
|
73
44
|
NUITKA_MAY_BE_UNUSED static inline void CLEAR_ERROR_OCCURRED(PyThreadState *tstate) {
|
|
74
45
|
#if PYTHON_VERSION < 0x3c0
|
|
@@ -209,6 +180,7 @@ NUITKA_MAY_BE_UNUSED static PyTracebackObject *ADD_TRACEBACK(PyTracebackObject *
|
|
|
209
180
|
|
|
210
181
|
PyTracebackObject *traceback_new = MAKE_TRACEBACK(frame, lineno);
|
|
211
182
|
traceback_new->tb_next = exception_tb;
|
|
183
|
+
Py_INCREF(exception_tb);
|
|
212
184
|
return traceback_new;
|
|
213
185
|
}
|
|
214
186
|
|
|
@@ -366,6 +338,14 @@ NUITKA_MAY_BE_UNUSED inline static void SET_CURRENT_EXCEPTION(PyThreadState *tst
|
|
|
366
338
|
#endif
|
|
367
339
|
}
|
|
368
340
|
|
|
341
|
+
// Normalize an exception, may release old values and replace them, expects
|
|
342
|
+
// references passed and returns them.
|
|
343
|
+
NUITKA_MAY_BE_UNUSED static inline void NORMALIZE_EXCEPTION(PyThreadState *tstate, PyObject **exception_type,
|
|
344
|
+
PyObject **exception_value,
|
|
345
|
+
PyTracebackObject **exception_tb);
|
|
346
|
+
|
|
347
|
+
extern PyObject *NORMALIZE_EXCEPTION_VALUE_FOR_RAISE(PyThreadState *tstate, PyObject *exception_type);
|
|
348
|
+
|
|
369
349
|
// Helper that sets the current thread exception, and has no reference passed.
|
|
370
350
|
// Similar to "PyErr_SetNone".
|
|
371
351
|
NUITKA_MAY_BE_UNUSED inline static void SET_CURRENT_EXCEPTION_TYPE0(PyThreadState *tstate, PyObject *exception_type) {
|
|
@@ -392,11 +372,11 @@ NUITKA_MAY_BE_UNUSED inline static void SET_CURRENT_EXCEPTION_TYPE0(PyThreadStat
|
|
|
392
372
|
#else
|
|
393
373
|
PyObject *old_exception = tstate->current_exception;
|
|
394
374
|
ASSERT_NORMALIZED_EXCEPTION_VALUE_X(old_exception);
|
|
395
|
-
|
|
396
|
-
|
|
375
|
+
|
|
376
|
+
// TODO: Make the call, exception creation on the outside somehow.
|
|
377
|
+
PyObject *exception_value = NORMALIZE_EXCEPTION_VALUE_FOR_RAISE(tstate, exception_type);
|
|
397
378
|
ASSERT_NORMALIZED_EXCEPTION_VALUE(exception_value);
|
|
398
379
|
tstate->current_exception = exception_value;
|
|
399
|
-
Py_DECREF(exception_type);
|
|
400
380
|
|
|
401
381
|
#if _DEBUG_EXCEPTIONS
|
|
402
382
|
PRINT_STRING("SET_CURRENT_EXCEPTION_TYPE0:\n");
|
|
@@ -436,13 +416,14 @@ SET_CURRENT_EXCEPTION_TYPE0_VALUE0(PyThreadState *tstate, PyObject *exception_ty
|
|
|
436
416
|
PyObject *old_exception_value = tstate->current_exception;
|
|
437
417
|
ASSERT_NORMALIZED_EXCEPTION_VALUE_X(old_exception_value);
|
|
438
418
|
|
|
419
|
+
// TODO: Make the call on the outside.
|
|
439
420
|
NORMALIZE_EXCEPTION(tstate, &exception_type, &exception_value, NULL);
|
|
440
421
|
ASSERT_NORMALIZED_EXCEPTION_VALUE(exception_value);
|
|
441
422
|
tstate->current_exception = exception_value;
|
|
442
423
|
Py_INCREF(exception_value);
|
|
443
424
|
|
|
444
425
|
#if _DEBUG_EXCEPTIONS
|
|
445
|
-
PRINT_STRING("
|
|
426
|
+
PRINT_STRING("SET_CURRENT_EXCEPTION_TYPE_0_VALUE0:\n");
|
|
446
427
|
PRINT_CURRENT_EXCEPTION();
|
|
447
428
|
#endif
|
|
448
429
|
|
|
@@ -450,8 +431,13 @@ SET_CURRENT_EXCEPTION_TYPE0_VALUE0(PyThreadState *tstate, PyObject *exception_ty
|
|
|
450
431
|
#endif
|
|
451
432
|
}
|
|
452
433
|
|
|
434
|
+
// TODO: For Python3.12 it would be nice to know it's normalized already, so we
|
|
435
|
+
// can avoid the call to "NORMALIZE_EXCEPTION".
|
|
453
436
|
NUITKA_MAY_BE_UNUSED inline static void
|
|
454
437
|
SET_CURRENT_EXCEPTION_TYPE0_VALUE1(PyThreadState *tstate, PyObject *exception_type, PyObject *exception_value) {
|
|
438
|
+
CHECK_OBJECT(exception_type);
|
|
439
|
+
CHECK_OBJECT(exception_value);
|
|
440
|
+
|
|
455
441
|
#if PYTHON_VERSION < 0x3c0
|
|
456
442
|
PyObject *old_exception_type = tstate->curexc_type;
|
|
457
443
|
PyObject *old_exception_value = tstate->curexc_value;
|
|
@@ -474,6 +460,7 @@ SET_CURRENT_EXCEPTION_TYPE0_VALUE1(PyThreadState *tstate, PyObject *exception_ty
|
|
|
474
460
|
PyObject *old_exception_value = tstate->current_exception;
|
|
475
461
|
ASSERT_NORMALIZED_EXCEPTION_VALUE_X(old_exception_value);
|
|
476
462
|
|
|
463
|
+
// TODO: Make the call, exception creation on the outside somehow.
|
|
477
464
|
NORMALIZE_EXCEPTION(tstate, &exception_type, &exception_value, NULL);
|
|
478
465
|
ASSERT_NORMALIZED_EXCEPTION_VALUE_X(exception_value);
|
|
479
466
|
tstate->current_exception = exception_value;
|
|
@@ -494,10 +481,6 @@ NUITKA_MAY_BE_UNUSED inline static void SET_CURRENT_EXCEPTION_TYPE0_STR(PyThread
|
|
|
494
481
|
char const *value) {
|
|
495
482
|
PyObject *exception_value = Nuitka_String_FromString(value);
|
|
496
483
|
|
|
497
|
-
#if PYTHON_VERSION >= 0x3c0
|
|
498
|
-
NORMALIZE_EXCEPTION(tstate, &exception_type, &exception_value, NULL);
|
|
499
|
-
#endif
|
|
500
|
-
|
|
501
484
|
SET_CURRENT_EXCEPTION_TYPE0_VALUE1(tstate, exception_type, exception_value);
|
|
502
485
|
}
|
|
503
486
|
|
|
@@ -618,55 +601,7 @@ NUITKA_MAY_BE_UNUSED static inline PyTracebackObject *GET_EXCEPTION_TRACEBACK(Py
|
|
|
618
601
|
PyBaseExceptionObject *exc_object = (PyBaseExceptionObject *)(exception_value);
|
|
619
602
|
return (PyTracebackObject *)exc_object->traceback;
|
|
620
603
|
}
|
|
621
|
-
#endif
|
|
622
|
-
|
|
623
|
-
// Publish an exception, erasing the values of the variables.
|
|
624
|
-
NUITKA_MAY_BE_UNUSED static inline void PUBLISH_CURRENT_EXCEPTION(PyThreadState *tstate, PyObject **exception_type,
|
|
625
|
-
PyObject **exception_value,
|
|
626
|
-
PyTracebackObject **exception_tb) {
|
|
627
|
-
#if _DEBUG_EXCEPTIONS
|
|
628
|
-
PRINT_STRING("PUBLISH_CURRENT_EXCEPTION:\n");
|
|
629
|
-
#endif
|
|
630
|
-
NORMALIZE_EXCEPTION(tstate, exception_type, exception_value, exception_tb);
|
|
631
|
-
ATTACH_TRACEBACK_TO_EXCEPTION_VALUE(*exception_value, *exception_tb);
|
|
632
|
-
|
|
633
|
-
struct Nuitka_ExceptionStackItem exc_state;
|
|
634
|
-
|
|
635
|
-
#if PYTHON_VERSION < 0x3b0
|
|
636
|
-
exc_state.exception_type = *exception_type;
|
|
637
|
-
#endif
|
|
638
|
-
exc_state.exception_value = *exception_value;
|
|
639
|
-
#if PYTHON_VERSION < 0x3b0
|
|
640
|
-
exc_state.exception_tb = *exception_tb;
|
|
641
|
-
#endif
|
|
642
|
-
|
|
643
|
-
SET_CURRENT_EXCEPTION(tstate, &exc_state);
|
|
644
|
-
|
|
645
|
-
#if PYTHON_VERSION >= 0x3b0
|
|
646
|
-
// TODO: We shouldn't get these in the first place, we don't transfer the
|
|
647
|
-
// type anymore and the exception tb could come in already attached.
|
|
648
|
-
Py_DECREF(*exception_type);
|
|
649
|
-
Py_XDECREF(*exception_tb);
|
|
650
|
-
#endif
|
|
651
|
-
|
|
652
|
-
*exception_type = NULL;
|
|
653
|
-
*exception_value = NULL;
|
|
654
|
-
*exception_tb = NULL;
|
|
655
|
-
}
|
|
656
604
|
|
|
657
|
-
#if PYTHON_VERSION >= 0x300
|
|
658
|
-
// Attach the exception context if necessary.
|
|
659
|
-
NUITKA_MAY_BE_UNUSED static inline void ADD_EXCEPTION_CONTEXT(PyThreadState *tstate, PyObject **exception_type,
|
|
660
|
-
PyObject **exception_value) {
|
|
661
|
-
PyObject *context = EXC_VALUE(tstate);
|
|
662
|
-
|
|
663
|
-
if (context != NULL) {
|
|
664
|
-
NORMALIZE_EXCEPTION(tstate, exception_type, exception_value, NULL);
|
|
665
|
-
|
|
666
|
-
Py_INCREF(context);
|
|
667
|
-
PyException_SetContext(*exception_value, context);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
605
|
#endif
|
|
671
606
|
|
|
672
607
|
NUITKA_MAY_BE_UNUSED static bool EXCEPTION_MATCH_BOOL_SINGLE(PyThreadState *tstate, PyObject *exception_value,
|
|
@@ -736,20 +671,6 @@ NUITKA_MAY_BE_UNUSED static bool CHECK_AND_CLEAR_ATTRIBUTE_ERROR_OCCURRED(PyThre
|
|
|
736
671
|
return _CHECK_AND_CLEAR_EXCEPTION_OCCURRED(tstate, PyExc_AttributeError);
|
|
737
672
|
}
|
|
738
673
|
|
|
739
|
-
// Format a NameError exception for a variable name, chains with existing exception.
|
|
740
|
-
extern void SET_CURRENT_EXCEPTION_NAME_ERROR(PyThreadState *tstate, PyObject *variable_name);
|
|
741
|
-
|
|
742
|
-
#if PYTHON_VERSION < 0x340
|
|
743
|
-
// Same as SET_CURRENT_EXCEPTION_NAME_ERROR with different wording, sometimes for Python2.
|
|
744
|
-
extern void SET_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR(PyThreadState *tstate, PyObject *variable_name);
|
|
745
|
-
#endif
|
|
746
|
-
|
|
747
|
-
// Format a UnboundLocalError exception for a variable name.
|
|
748
|
-
extern void FORMAT_UNBOUND_LOCAL_ERROR(PyObject **exception_type, PyObject **exception_value, PyObject *variable_name);
|
|
749
|
-
|
|
750
|
-
extern void FORMAT_UNBOUND_CLOSURE_ERROR(PyObject **exception_type, PyObject **exception_value,
|
|
751
|
-
PyObject *variable_name);
|
|
752
|
-
|
|
753
674
|
#if PYTHON_VERSION >= 0x3c0
|
|
754
675
|
NUITKA_MAY_BE_UNUSED static PyObject *MAKE_TUPLE1(PyThreadState *tstate, PyObject *element1);
|
|
755
676
|
|
|
@@ -794,6 +715,8 @@ struct Nuitka_ExceptionPreservationItem {
|
|
|
794
715
|
PyTracebackObject *exception_tb;
|
|
795
716
|
};
|
|
796
717
|
|
|
718
|
+
static const struct Nuitka_ExceptionPreservationItem Empty_Nuitka_ExceptionPreservationItem = {0};
|
|
719
|
+
|
|
797
720
|
// Fetch the current exception into state, transfers reference coming from tstate ownership. Old values are overwritten.
|
|
798
721
|
NUITKA_MAY_BE_UNUSED static void FETCH_ERROR_OCCURRED_STATE(PyThreadState *tstate,
|
|
799
722
|
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
@@ -888,7 +811,7 @@ ASSIGN_ARGS_FROM_EXCEPTION_PRESERVATION_STATE(struct Nuitka_ExceptionPreservatio
|
|
|
888
811
|
}
|
|
889
812
|
|
|
890
813
|
NUITKA_MAY_BE_UNUSED static PyTracebackObject *
|
|
891
|
-
GET_EXCEPTION_STATE_TRACEBACK(struct Nuitka_ExceptionPreservationItem
|
|
814
|
+
GET_EXCEPTION_STATE_TRACEBACK(struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
892
815
|
return exception_state->exception_tb;
|
|
893
816
|
}
|
|
894
817
|
|
|
@@ -897,6 +820,7 @@ NUITKA_MAY_BE_UNUSED static void SET_EXCEPTION_STATE_TRACEBACK(struct Nuitka_Exc
|
|
|
897
820
|
PyTracebackObject *exception_tb) {
|
|
898
821
|
CHECK_OBJECT_X(exception_state->exception_tb);
|
|
899
822
|
CHECK_OBJECT_X(exception_tb);
|
|
823
|
+
|
|
900
824
|
Py_XDECREF(exception_state->exception_tb);
|
|
901
825
|
exception_state->exception_tb = exception_tb;
|
|
902
826
|
}
|
|
@@ -930,6 +854,8 @@ struct Nuitka_ExceptionPreservationItem {
|
|
|
930
854
|
PyObject *exception_value;
|
|
931
855
|
};
|
|
932
856
|
|
|
857
|
+
static const struct Nuitka_ExceptionPreservationItem Empty_Nuitka_ExceptionPreservationItem = {0};
|
|
858
|
+
|
|
933
859
|
// Fetch the current exception into state, transfers reference coming from tstate ownership. Old value is overwritten.
|
|
934
860
|
NUITKA_MAY_BE_UNUSED static void FETCH_ERROR_OCCURRED_STATE(PyThreadState *tstate,
|
|
935
861
|
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
@@ -961,7 +887,7 @@ RESTORE_ERROR_OCCURRED_STATE(PyThreadState *tstate, struct Nuitka_ExceptionPrese
|
|
|
961
887
|
tstate->current_exception = exception_state->exception_value;
|
|
962
888
|
|
|
963
889
|
#if _DEBUG_EXCEPTIONS
|
|
964
|
-
PRINT_STRING("
|
|
890
|
+
PRINT_STRING("RESTORE_ERROR_OCCURRED_STATE:\n");
|
|
965
891
|
PRINT_CURRENT_EXCEPTION();
|
|
966
892
|
#endif
|
|
967
893
|
|
|
@@ -1082,19 +1008,79 @@ CHECK_EXCEPTION_STATE_X(struct Nuitka_ExceptionPreservationItem const *exception
|
|
|
1082
1008
|
|
|
1083
1009
|
#endif
|
|
1084
1010
|
|
|
1011
|
+
NUITKA_MAY_BE_UNUSED inline static void SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0(
|
|
1012
|
+
PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state, PyObject *exception_type) {
|
|
1013
|
+
|
|
1014
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_ARGS(tstate, exception_state, exception_type, NULL, NULL);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
extern PyObject *CALL_FUNCTION_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg);
|
|
1018
|
+
|
|
1019
|
+
NUITKA_MAY_BE_UNUSED inline static void
|
|
1020
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1(PyThreadState *tstate,
|
|
1021
|
+
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
1022
|
+
PyObject *exception_type, PyObject *exception_value) {
|
|
1023
|
+
#if PYTHON_VERSION < 0x3c0
|
|
1024
|
+
Py_INCREF(exception_type);
|
|
1025
|
+
|
|
1026
|
+
exception_state->exception_type = exception_type;
|
|
1027
|
+
exception_state->exception_value = exception_value;
|
|
1028
|
+
exception_state->exception_tb = NULL;
|
|
1029
|
+
#else
|
|
1030
|
+
PyObject *exc = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, exception_type, exception_value);
|
|
1031
|
+
exception_state->exception_value = exc;
|
|
1032
|
+
Py_DECREF(exception_value);
|
|
1033
|
+
#endif
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
NUITKA_MAY_BE_UNUSED inline static void
|
|
1037
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1_NORMALIZED(PyThreadState *tstate,
|
|
1038
|
+
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
1039
|
+
PyObject *exception_type, PyObject *exception_value) {
|
|
1040
|
+
#if PYTHON_VERSION < 0x3c0
|
|
1041
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1(tstate, exception_state, exception_type, exception_value);
|
|
1042
|
+
#else
|
|
1043
|
+
exception_state->exception_value = exception_value;
|
|
1044
|
+
#endif
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
NUITKA_MAY_BE_UNUSED inline static void
|
|
1048
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE0(PyThreadState *tstate,
|
|
1049
|
+
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
1050
|
+
PyObject *exception_type, PyObject *exception_value) {
|
|
1051
|
+
// TODO: Add variants for normalized values only.
|
|
1052
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_ARGS(tstate, exception_state, exception_type, exception_value, NULL);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1085
1055
|
NUITKA_MAY_BE_UNUSED inline static void
|
|
1086
1056
|
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_STR(PyThreadState *tstate,
|
|
1087
1057
|
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
1088
1058
|
PyObject *exception_type, char const *value) {
|
|
1089
1059
|
PyObject *exception_value = Nuitka_String_FromString(value);
|
|
1090
1060
|
|
|
1091
|
-
|
|
1092
|
-
Py_DECREF(exception_value);
|
|
1061
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1(tstate, exception_state, exception_type, exception_value);
|
|
1093
1062
|
}
|
|
1094
1063
|
|
|
1064
|
+
#define SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_FORMAT1(tstate, exception_state, exception_type, message, arg1) \
|
|
1065
|
+
{ \
|
|
1066
|
+
PyObject *exception_value = Nuitka_String_FromFormat(message, arg1); \
|
|
1067
|
+
CHECK_OBJECT(exception_value); \
|
|
1068
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1(tstate, exception_state, exception_type, exception_value); \
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
#define SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_FORMAT2(tstate, exception_state, exception_type, message, arg1, \
|
|
1072
|
+
arg2) \
|
|
1073
|
+
{ \
|
|
1074
|
+
PyObject *exception_value = Nuitka_String_FromFormat(message, arg1, arg2); \
|
|
1075
|
+
CHECK_OBJECT(exception_value); \
|
|
1076
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1(tstate, exception_state, exception_type, exception_value); \
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1095
1079
|
NUITKA_MAY_BE_UNUSED static bool EXCEPTION_MATCH_GENERATOR(PyThreadState *tstate, PyObject *exception_value) {
|
|
1096
1080
|
CHECK_OBJECT(exception_value);
|
|
1097
1081
|
|
|
1082
|
+
// TODO: For Python3.12 this must be done differently to be a lot better.
|
|
1083
|
+
|
|
1098
1084
|
// We need to check the class.
|
|
1099
1085
|
if (PyExceptionInstance_Check(exception_value)) {
|
|
1100
1086
|
exception_value = PyExceptionInstance_Class(exception_value);
|
|
@@ -1136,6 +1122,15 @@ NUITKA_MAY_BE_UNUSED static bool EXCEPTION_MATCH_GENERATOR(PyThreadState *tstate
|
|
|
1136
1122
|
return false;
|
|
1137
1123
|
}
|
|
1138
1124
|
|
|
1125
|
+
NUITKA_MAY_BE_UNUSED static bool
|
|
1126
|
+
EXCEPTION_STATE_MATCH_GENERATOR(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
1127
|
+
#if PYTHON_VERSION < 0x3c0
|
|
1128
|
+
return EXCEPTION_MATCH_GENERATOR(tstate, exception_state->exception_type);
|
|
1129
|
+
#else
|
|
1130
|
+
return EXCEPTION_MATCH_GENERATOR(tstate, exception_state->exception_value);
|
|
1131
|
+
#endif
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1139
1134
|
NUITKA_MAY_BE_UNUSED static bool EXCEPTION_MATCH_BOOL_SINGLE(PyThreadState *tstate, PyObject *exception_value,
|
|
1140
1135
|
PyObject *exception_checked) {
|
|
1141
1136
|
CHECK_OBJECT(exception_value);
|
|
@@ -1152,10 +1147,13 @@ NUITKA_MAY_BE_UNUSED static bool EXCEPTION_MATCH_BOOL_SINGLE(PyThreadState *tsta
|
|
|
1152
1147
|
}
|
|
1153
1148
|
|
|
1154
1149
|
if (PyExceptionClass_Check(exception_value)) {
|
|
1150
|
+
#if PYTHON_VERSION < 0x300
|
|
1155
1151
|
// Save the current exception, if any, we must preserve it.
|
|
1156
1152
|
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
1157
1153
|
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1158
1154
|
|
|
1155
|
+
// Python3.10 at least uses PyType_IsSubtype and needs no
|
|
1156
|
+
// fetch restore.
|
|
1159
1157
|
int res = PyObject_IsSubclass(exception_value, exception_checked);
|
|
1160
1158
|
|
|
1161
1159
|
// This function must not fail, so print the error here */
|
|
@@ -1166,6 +1164,10 @@ NUITKA_MAY_BE_UNUSED static bool EXCEPTION_MATCH_BOOL_SINGLE(PyThreadState *tsta
|
|
|
1166
1164
|
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1167
1165
|
|
|
1168
1166
|
return res == 1;
|
|
1167
|
+
#else
|
|
1168
|
+
int res = Nuitka_Type_IsSubtype((PyTypeObject *)exception_value, (PyTypeObject *)exception_checked);
|
|
1169
|
+
return res == 1;
|
|
1170
|
+
#endif
|
|
1169
1171
|
}
|
|
1170
1172
|
|
|
1171
1173
|
return false;
|
|
@@ -1270,29 +1272,170 @@ NUITKA_MAY_BE_UNUSED static inline int EXCEPTION_MATCH_BOOL(PyThreadState *tstat
|
|
|
1270
1272
|
}
|
|
1271
1273
|
}
|
|
1272
1274
|
|
|
1273
|
-
|
|
1275
|
+
// Normalize an exception type to a value.
|
|
1274
1276
|
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1277
|
+
extern void Nuitka_Err_NormalizeException(PyThreadState *tstate, PyObject **exc, PyObject **val,
|
|
1278
|
+
PyTracebackObject **tb);
|
|
1279
|
+
|
|
1280
|
+
// Normalize an exception, may release old values and replace them, expects
|
|
1281
|
+
// references passed and returns them.
|
|
1282
|
+
NUITKA_MAY_BE_UNUSED static inline void NORMALIZE_EXCEPTION(PyThreadState *tstate, PyObject **exception_type,
|
|
1283
|
+
PyObject **exception_value,
|
|
1284
|
+
PyTracebackObject **exception_tb) {
|
|
1285
|
+
#if _DEBUG_EXCEPTIONS
|
|
1286
|
+
PRINT_STRING("NORMALIZE_EXCEPTION: Enter\n");
|
|
1287
|
+
PRINT_EXCEPTION(*exception_type, *exception_value, *exception_tb);
|
|
1288
|
+
#endif
|
|
1289
|
+
CHECK_OBJECT_X(*exception_type);
|
|
1290
|
+
CHECK_OBJECT_X(*exception_value);
|
|
1291
|
+
if (exception_tb) {
|
|
1292
|
+
CHECK_OBJECT_X(*exception_tb);
|
|
1293
|
+
}
|
|
1279
1294
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1295
|
+
// TODO: Often we already know this to be true.
|
|
1296
|
+
if (*exception_type != Py_None && *exception_type != NULL) {
|
|
1297
|
+
Nuitka_Err_NormalizeException(tstate, exception_type, exception_value, exception_tb);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
#if _DEBUG_EXCEPTIONS
|
|
1301
|
+
PRINT_STRING("NORMALIZE_EXCEPTION: Leave\n");
|
|
1302
|
+
PRINT_EXCEPTION(*exception_type, *exception_value, exception_tb ? *exception_tb : NULL);
|
|
1303
|
+
#endif
|
|
1285
1304
|
}
|
|
1286
1305
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1306
|
+
#if PYTHON_VERSION < 0x3c0
|
|
1307
|
+
// Normalize an exception, may release old values and replace them, expects
|
|
1308
|
+
// references passed and returns them.
|
|
1309
|
+
static inline void NORMALIZE_EXCEPTION_STATE(PyThreadState *tstate,
|
|
1310
|
+
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
1311
|
+
CHECK_EXCEPTION_STATE_X(exception_state);
|
|
1312
|
+
|
|
1313
|
+
NORMALIZE_EXCEPTION(tstate, &exception_state->exception_type, &exception_state->exception_value,
|
|
1314
|
+
&exception_state->exception_tb);
|
|
1315
|
+
}
|
|
1316
|
+
#endif
|
|
1317
|
+
|
|
1318
|
+
extern PyObject *CALL_FUNCTION_NO_ARGS(PyThreadState *tstate, PyObject *called);
|
|
1319
|
+
|
|
1320
|
+
// Publish an exception, erasing the values of the variables.
|
|
1321
|
+
NUITKA_MAY_BE_UNUSED static inline void
|
|
1322
|
+
PUBLISH_CURRENT_EXCEPTION(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
1323
|
+
#if _DEBUG_EXCEPTIONS
|
|
1324
|
+
PRINT_STRING("PUBLISH_CURRENT_EXCEPTION:\n");
|
|
1325
|
+
PRINT_EXCEPTION_STATE(exception_state);
|
|
1326
|
+
#endif
|
|
1327
|
+
|
|
1328
|
+
#if PYTHON_VERSION < 0x3c0
|
|
1329
|
+
NORMALIZE_EXCEPTION_STATE(tstate, exception_state);
|
|
1330
|
+
ATTACH_TRACEBACK_TO_EXCEPTION_VALUE(exception_state->exception_value, exception_state->exception_tb);
|
|
1331
|
+
#endif
|
|
1332
|
+
|
|
1333
|
+
struct Nuitka_ExceptionStackItem exc_state;
|
|
1334
|
+
|
|
1335
|
+
#if PYTHON_VERSION < 0x3b0
|
|
1336
|
+
exc_state.exception_type = exception_state->exception_type;
|
|
1337
|
+
#endif
|
|
1338
|
+
exc_state.exception_value = exception_state->exception_value;
|
|
1339
|
+
#if PYTHON_VERSION < 0x3b0
|
|
1340
|
+
exc_state.exception_tb = exception_state->exception_tb;
|
|
1341
|
+
#endif
|
|
1342
|
+
|
|
1343
|
+
SET_CURRENT_EXCEPTION(tstate, &exc_state);
|
|
1344
|
+
|
|
1345
|
+
#if PYTHON_VERSION >= 0x3b0 && PYTHON_VERSION < 0x3c0
|
|
1346
|
+
// TODO: We shouldn't get these in the first place, we don't transfer the
|
|
1347
|
+
// type anymore and the exception tb could come in already attached.
|
|
1348
|
+
Py_DECREF(exception_state->exception_type);
|
|
1349
|
+
Py_XDECREF(exception_state->exception_tb);
|
|
1350
|
+
#endif
|
|
1351
|
+
|
|
1352
|
+
INIT_ERROR_OCCURRED_STATE(exception_state);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
NUITKA_MAY_BE_UNUSED static bool
|
|
1356
|
+
_CHECK_AND_CLEAR_EXCEPTION_STATE(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
1357
|
+
PyObject *exception_type) {
|
|
1358
|
+
#if PYTHON_VERSION < 0x3c0
|
|
1359
|
+
PyObject *exception_current = exception_state->exception_type;
|
|
1360
|
+
#else
|
|
1361
|
+
PyObject *exception_current = exception_state->exception_value;
|
|
1362
|
+
ASSERT_NORMALIZED_EXCEPTION_VALUE_X(exception_current);
|
|
1363
|
+
#endif
|
|
1364
|
+
if (exception_current == NULL) {
|
|
1365
|
+
return true;
|
|
1366
|
+
} else if (EXCEPTION_MATCH_BOOL_SINGLE(tstate, exception_current, exception_type)) {
|
|
1367
|
+
CHECK_OBJECT(exception_current);
|
|
1368
|
+
|
|
1369
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
1370
|
+
INIT_ERROR_OCCURRED_STATE(exception_state);
|
|
1371
|
+
|
|
1372
|
+
return true;
|
|
1373
|
+
} else {
|
|
1374
|
+
return false;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
// TODO: Get rid of "CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED" and rename this to
|
|
1379
|
+
// its name.
|
|
1380
|
+
NUITKA_MAY_BE_UNUSED static bool
|
|
1381
|
+
CHECK_AND_CLEAR_STOP_ITERATION_STATE(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
1382
|
+
return _CHECK_AND_CLEAR_EXCEPTION_STATE(tstate, exception_state, PyExc_StopIteration);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
// Format a UnboundLocalError exception for a variable name. TODO: This is more
|
|
1386
|
+
// for "raising.h" it seems.
|
|
1387
|
+
extern void FORMAT_UNBOUND_LOCAL_ERROR(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
1388
|
+
PyObject *variable_name);
|
|
1389
|
+
|
|
1390
|
+
extern void FORMAT_UNBOUND_CLOSURE_ERROR(PyThreadState *tstate,
|
|
1391
|
+
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
1392
|
+
PyObject *variable_name);
|
|
1393
|
+
|
|
1394
|
+
#if PYTHON_VERSION >= 0x300
|
|
1395
|
+
static inline PyBaseExceptionObject *_PyBaseExceptionObject_cast(PyObject *exc) {
|
|
1396
|
+
assert(PyExceptionInstance_Check(exc));
|
|
1397
|
+
return (PyBaseExceptionObject *)exc;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// Exception context, replacement for "PyException_GetContext", it however gives no
|
|
1401
|
+
// reference.
|
|
1402
|
+
NUITKA_MAY_BE_UNUSED static inline PyObject *Nuitka_Exception_GetContext(PyObject *self) {
|
|
1403
|
+
return _PyBaseExceptionObject_cast(self)->context;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// Exception context, replacement for "PyException_SetContext" it however doesn't
|
|
1407
|
+
// consume a reference.
|
|
1408
|
+
NUITKA_MAY_BE_UNUSED static inline void Nuitka_Exception_SetContext(PyObject *self, PyObject *context) {
|
|
1409
|
+
CHECK_OBJECT(context);
|
|
1410
|
+
|
|
1411
|
+
Py_INCREF(context);
|
|
1412
|
+
Py_XSETREF(_PyBaseExceptionObject_cast(self)->context, context);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
NUITKA_MAY_BE_UNUSED static inline void Nuitka_Exception_DeleteContext(PyObject *self) {
|
|
1416
|
+
Py_XSETREF(_PyBaseExceptionObject_cast(self)->context, NULL);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
#if PYTHON_VERSION >= 0x300
|
|
1420
|
+
// Attach the exception context if necessary.
|
|
1421
|
+
NUITKA_MAY_BE_UNUSED static inline void
|
|
1422
|
+
ADD_EXCEPTION_CONTEXT(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
1423
|
+
PyObject *context = EXC_VALUE(tstate);
|
|
1424
|
+
|
|
1425
|
+
if (context != NULL) {
|
|
1426
|
+
#if PYTHON_VERSION < 0x3c0
|
|
1427
|
+
NORMALIZE_EXCEPTION_STATE(tstate, exception_state);
|
|
1428
|
+
#endif
|
|
1429
|
+
Nuitka_Exception_SetContext(exception_state->exception_value, context);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
#endif
|
|
1294
1433
|
|
|
1295
|
-
|
|
1434
|
+
// Our replacement for "PyException_SetCause", consumes a reference.
|
|
1435
|
+
NUITKA_MAY_BE_UNUSED static inline void Nuitka_Exception_SetCause(PyObject *self, PyObject *cause) {
|
|
1436
|
+
PyBaseExceptionObject *base_self = _PyBaseExceptionObject_cast(self);
|
|
1437
|
+
base_self->suppress_context = 1;
|
|
1438
|
+
Py_XSETREF(base_self->cause, cause);
|
|
1296
1439
|
}
|
|
1297
1440
|
|
|
1298
1441
|
#endif
|
|
@@ -39,10 +39,6 @@ extern PyObject *FIND_ATTRIBUTE_IN_CLASS(PyClassObject *class_object, PyObject *
|
|
|
39
39
|
#endif
|
|
40
40
|
|
|
41
41
|
extern PyObject *LOOKUP_MODULE_VALUE(PyDictObject *module_dict, PyObject *var_name);
|
|
42
|
-
extern PyObject *GET_MODULE_VARIABLE_VALUE_FALLBACK(PyThreadState *tstate, PyObject *variable_name);
|
|
43
|
-
#if PYTHON_VERSION < 0x340
|
|
44
|
-
extern PyObject *GET_MODULE_VARIABLE_VALUE_FALLBACK_IN_FUNCTION(PyThreadState *tstate, PyObject *variable_name);
|
|
45
|
-
#endif
|
|
46
42
|
|
|
47
43
|
// In case of DLL usage, this avoids looking up the symbol from it.
|
|
48
44
|
extern getattrofunc PyObject_GenericGetAttr_resolved;
|