Nuitka-winsvc 2.4.11__cp311-cp311-win_amd64.whl → 2.5.6__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.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/METADATA +56 -109
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/RECORD +304 -280
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/WHEEL +1 -1
- nuitka/Builtins.py +31 -0
- nuitka/HardImportRegistry.py +8 -0
- nuitka/MainControl.py +9 -4
- nuitka/OptionParsing.py +108 -54
- nuitka/Options.py +69 -13
- 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 +4 -0
- nuitka/build/SconsCompilerSettings.py +14 -3
- nuitka/build/SconsInterface.py +3 -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 +8 -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 +75 -31
- 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/helper/tuples.h +12 -0
- nuitka/build/include/nuitka/helpers.h +12 -2
- nuitka/build/include/nuitka/prelude.h +36 -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 +106 -40
- nuitka/build/static_src/CompiledCoroutineType.c +41 -31
- 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 +433 -46
- nuitka/build/static_src/CompiledMethodType.c +6 -12
- nuitka/build/static_src/HelpersAllocator.c +266 -28
- nuitka/build/static_src/HelpersAttributes.c +0 -21
- nuitka/build/static_src/HelpersBuiltin.c +23 -14
- 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/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 +4 -2
- nuitka/build/static_src/HelpersDeepcopy.c +1 -0
- nuitka/build/static_src/HelpersDictionaries.c +195 -36
- nuitka/build/static_src/HelpersDictionariesGenerated.c +12 -107
- 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/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 +2 -2
- nuitka/build/static_src/HelpersTypes.c +98 -2
- nuitka/build/static_src/MainProgram.c +132 -28
- 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 +76 -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 +4 -106
- 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 +5 -2
- nuitka/freezer/DllDependenciesMacOS.py +18 -1
- nuitka/freezer/DllDependenciesWin32.py +26 -12
- nuitka/freezer/ImportDetection.py +6 -0
- nuitka/freezer/IncludedDataFiles.py +37 -6
- nuitka/freezer/Onefile.py +1 -0
- nuitka/freezer/Standalone.py +72 -18
- nuitka/importing/Importing.py +33 -6
- nuitka/importing/Recursion.py +5 -2
- nuitka/importing/StandardLibrary.py +57 -59
- nuitka/nodes/AsyncgenNodes.py +3 -6
- nuitka/nodes/BuiltinIteratorNodes.py +2 -2
- 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/DictionaryNodes.py +1 -1
- 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/VariableAssignNodes.py +2 -1
- nuitka/nodes/shapes/BuiltinTypeShapes.py +24 -7
- nuitka/nodes/shapes/IteratorShapes.py +71 -0
- nuitka/nodes/shapes/ShapeMixins.py +18 -0
- nuitka/nodes/shapes/StandardShapes.py +47 -44
- nuitka/optimizations/BytecodeDemotion.py +2 -1
- nuitka/plugins/PluginBase.py +64 -22
- nuitka/plugins/Plugins.py +16 -3
- nuitka/plugins/standard/AntiBloatPlugin.py +23 -12
- nuitka/plugins/standard/DllFilesPlugin.py +78 -2
- nuitka/plugins/standard/ImplicitImports.py +5 -15
- nuitka/plugins/standard/KivyPlugin.py +3 -12
- nuitka/plugins/standard/MatplotlibPlugin.py +12 -1
- nuitka/plugins/standard/MultiprocessingPlugin.py +11 -20
- nuitka/plugins/standard/OptionsNannyPlugin.py +5 -4
- nuitka/plugins/standard/PlaywrightPlugin.py +184 -0
- nuitka/plugins/standard/PySidePyQtPlugin.py +8 -0
- nuitka/plugins/standard/TkinterPlugin.py +23 -3
- nuitka/plugins/standard/TransformersPlugin.py +70 -275
- nuitka/plugins/standard/standard.nuitka-package.config.yml +413 -30
- 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/environments/Virtualenv.py +13 -5
- nuitka/tools/general/dll_report/__main__.py +10 -1
- nuitka/tools/onefile_compressor/OnefileCompressor.py +1 -1
- nuitka/tools/podman/__main__.py +4 -2
- nuitka/tools/specialize/CTypeDescriptions.py +158 -9
- nuitka/tools/specialize/SpecializeC.py +218 -56
- nuitka/tools/testing/Common.py +69 -62
- 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 +18 -39
- nuitka/utils/Hashing.py +5 -1
- 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/SharedLibraries.py +24 -0
- nuitka/utils/Signing.py +9 -1
- nuitka/utils/Utils.py +1 -0
- {Nuitka_winsvc-2.4.11.data → Nuitka_winsvc-2.5.6.data}/scripts/nuitka-run.cmd +0 -0
- {Nuitka_winsvc-2.4.11.data → Nuitka_winsvc-2.5.6.data}/scripts/nuitka.cmd +0 -0
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/top_level.txt +0 -0
|
@@ -10,23 +10,21 @@
|
|
|
10
10
|
#include "nuitka/prelude.h"
|
|
11
11
|
#endif
|
|
12
12
|
|
|
13
|
-
static void FORMAT_TYPE_ERROR1(
|
|
14
|
-
char const *arg) {
|
|
15
|
-
*
|
|
16
|
-
|
|
13
|
+
static void FORMAT_TYPE_ERROR1(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
14
|
+
char const *format, char const *arg) {
|
|
15
|
+
PyObject *exception_value = Nuitka_String_FromFormat(format, arg);
|
|
16
|
+
CHECK_OBJECT(exception_value);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
CHECK_OBJECT(*exception_value);
|
|
18
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1(tstate, exception_state, PyExc_TypeError, exception_value);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
#if PYTHON_VERSION >= 0x270
|
|
23
|
-
static void FORMAT_TYPE_ERROR2(
|
|
24
|
-
char const *arg1, char const *arg2) {
|
|
25
|
-
*
|
|
26
|
-
|
|
22
|
+
static void FORMAT_TYPE_ERROR2(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
23
|
+
char const *format, char const *arg1, char const *arg2) {
|
|
24
|
+
PyObject *exception_value = Nuitka_String_FromFormat(format, arg1, arg2);
|
|
25
|
+
CHECK_OBJECT(exception_value);
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
CHECK_OBJECT(*exception_value);
|
|
27
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1(tstate, exception_state, PyExc_TypeError, exception_value);
|
|
30
28
|
}
|
|
31
29
|
#endif
|
|
32
30
|
|
|
@@ -38,66 +36,57 @@ static void FORMAT_TYPE_ERROR2(PyObject **exception_type, PyObject **exception_v
|
|
|
38
36
|
#define WRONG_EXCEPTION_TYPE_ERROR_MESSAGE "exceptions must derive from BaseException"
|
|
39
37
|
#endif
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
PyObject *tmp = *exception_type;
|
|
50
|
-
*exception_type = PyTuple_GET_ITEM(*exception_type, 0);
|
|
51
|
-
Py_INCREF(*exception_type);
|
|
39
|
+
// Next, replace a tuple in exception type creation with its first item
|
|
40
|
+
#if PYTHON_VERSION < 0x3c0
|
|
41
|
+
static void UNPACK_TUPLE_EXCEPTION_TYPE(struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
42
|
+
while (unlikely(PyTuple_Check(exception_state->exception_type)) &&
|
|
43
|
+
PyTuple_GET_SIZE(exception_state->exception_type) > 0) {
|
|
44
|
+
PyObject *tmp = exception_state->exception_type;
|
|
45
|
+
exception_state->exception_type = PyTuple_GET_ITEM(exception_state->exception_type, 0);
|
|
46
|
+
Py_INCREF(exception_state->exception_type);
|
|
52
47
|
Py_DECREF(tmp);
|
|
53
48
|
}
|
|
49
|
+
}
|
|
54
50
|
#endif
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (unlikely(!PyExceptionInstance_Check(*exception_value))) {
|
|
61
|
-
assert(false);
|
|
62
|
-
|
|
63
|
-
PyObject *old_exception_type = *exception_type;
|
|
64
|
-
PyObject *old_exception_value = *exception_value;
|
|
65
|
-
|
|
66
|
-
FORMAT_TYPE_ERROR2(exception_type, exception_value,
|
|
67
|
-
"calling %s() should have returned an instance of BaseException, not '%s'",
|
|
68
|
-
Py_TYPE(*exception_type)->tp_name, Py_TYPE(*exception_value)->tp_name);
|
|
69
|
-
|
|
70
|
-
Py_DECREF(old_exception_type);
|
|
71
|
-
Py_DECREF(old_exception_value);
|
|
52
|
+
#if PYTHON_VERSION < 0x3c0
|
|
53
|
+
void RAISE_EXCEPTION_WITH_TYPE(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
54
|
+
exception_state->exception_value = NULL;
|
|
55
|
+
exception_state->exception_tb = NULL;
|
|
72
56
|
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
#if PYTHON_VERSION < 0x300
|
|
58
|
+
// Next, repeatedly, replace a tuple exception with its first item
|
|
59
|
+
UNPACK_TUPLE_EXCEPTION_TYPE(exception_state);
|
|
75
60
|
#endif
|
|
76
61
|
|
|
62
|
+
if (PyExceptionClass_Check(exception_state->exception_type)) {
|
|
63
|
+
NORMALIZE_EXCEPTION(tstate, &exception_state->exception_type, &exception_state->exception_value,
|
|
64
|
+
&exception_state->exception_tb);
|
|
65
|
+
|
|
77
66
|
#if PYTHON_VERSION >= 0x300
|
|
78
|
-
CHAIN_EXCEPTION(tstate,
|
|
67
|
+
CHAIN_EXCEPTION(tstate, exception_state->exception_value);
|
|
79
68
|
#endif
|
|
80
69
|
return;
|
|
81
|
-
} else if (PyExceptionInstance_Check(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Py_INCREF(
|
|
70
|
+
} else if (PyExceptionInstance_Check(exception_state->exception_type)) {
|
|
71
|
+
exception_state->exception_value = exception_state->exception_type;
|
|
72
|
+
exception_state->exception_type = PyExceptionInstance_Class(exception_state->exception_type);
|
|
73
|
+
Py_INCREF(exception_state->exception_type);
|
|
85
74
|
|
|
86
75
|
#if PYTHON_VERSION >= 0x300
|
|
87
|
-
CHAIN_EXCEPTION(tstate,
|
|
76
|
+
CHAIN_EXCEPTION(tstate, exception_state->exception_value);
|
|
88
77
|
|
|
89
78
|
// Note: Cannot be assigned here.
|
|
90
|
-
assert(
|
|
91
|
-
|
|
92
|
-
Py_XINCREF(
|
|
79
|
+
assert(exception_state->exception_tb == NULL);
|
|
80
|
+
exception_state->exception_tb = GET_EXCEPTION_TRACEBACK(exception_state->exception_value);
|
|
81
|
+
Py_XINCREF(exception_state->exception_tb);
|
|
93
82
|
#endif
|
|
94
83
|
|
|
95
84
|
return;
|
|
96
85
|
} else {
|
|
97
|
-
PyObject *old_exception_type =
|
|
86
|
+
PyObject *old_exception_type = exception_state->exception_type;
|
|
98
87
|
|
|
99
|
-
FORMAT_TYPE_ERROR1(
|
|
100
|
-
Py_TYPE(
|
|
88
|
+
FORMAT_TYPE_ERROR1(tstate, exception_state, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE,
|
|
89
|
+
Py_TYPE(exception_state->exception_type)->tp_name);
|
|
101
90
|
|
|
102
91
|
Py_DECREF(old_exception_type);
|
|
103
92
|
|
|
@@ -105,332 +94,262 @@ void RAISE_EXCEPTION_WITH_TYPE(PyThreadState *tstate, PyObject **exception_type,
|
|
|
105
94
|
}
|
|
106
95
|
}
|
|
107
96
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
CHECK_OBJECT(*exception_type);
|
|
112
|
-
CHECK_OBJECT(exception_cause);
|
|
113
|
-
*exception_tb = NULL;
|
|
97
|
+
void RAISE_EXCEPTION_WITH_TYPE_AND_VALUE(PyThreadState *tstate,
|
|
98
|
+
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
99
|
+
CHECK_EXCEPTION_STATE(exception_state);
|
|
114
100
|
|
|
115
|
-
|
|
116
|
-
if (exception_cause == Py_None) {
|
|
117
|
-
Py_DECREF_IMMORTAL(exception_cause);
|
|
118
|
-
exception_cause = NULL;
|
|
119
|
-
} else if (PyExceptionClass_Check(exception_cause)) {
|
|
120
|
-
PyObject *old_exception_cause = exception_cause;
|
|
121
|
-
exception_cause = PyObject_CallObject(exception_cause, NULL);
|
|
122
|
-
Py_DECREF(old_exception_cause);
|
|
101
|
+
exception_state->exception_tb = NULL;
|
|
123
102
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Py_XDECREF(*exception_tb);
|
|
103
|
+
// Non-empty tuple exceptions are the first element.
|
|
104
|
+
UNPACK_TUPLE_EXCEPTION_TYPE(exception_state);
|
|
127
105
|
|
|
128
|
-
|
|
129
|
-
|
|
106
|
+
if (PyExceptionClass_Check(exception_state->exception_type)) {
|
|
107
|
+
NORMALIZE_EXCEPTION_STATE(tstate, exception_state);
|
|
108
|
+
#if PYTHON_VERSION >= 0x270
|
|
109
|
+
if (unlikely(!PyExceptionInstance_Check(exception_state->exception_value))) {
|
|
110
|
+
char const *exception_type_type = Py_TYPE(exception_state->exception_type)->tp_name;
|
|
111
|
+
char const *exception_value_type = Py_TYPE(exception_state->exception_value)->tp_name;
|
|
130
112
|
|
|
131
|
-
|
|
132
|
-
exception_tb);
|
|
133
|
-
RELEASE_ERROR_OCCURRED_STATE(&exception_state);
|
|
113
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
134
114
|
|
|
135
|
-
|
|
115
|
+
FORMAT_TYPE_ERROR2(tstate, exception_state,
|
|
116
|
+
"calling %s() should have returned an instance of BaseException, not '%s'",
|
|
117
|
+
exception_type_type, exception_value_type);
|
|
136
118
|
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (unlikely(exception_cause != NULL && !PyExceptionInstance_Check(exception_cause))) {
|
|
140
|
-
Py_DECREF(*exception_type);
|
|
141
|
-
Py_XDECREF(*exception_tb);
|
|
142
|
-
|
|
143
|
-
PyObject *old_exception_cause = exception_cause;
|
|
144
|
-
|
|
145
|
-
#ifdef _NUITKA_FULL_COMPAT
|
|
146
|
-
SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "exception causes must derive from BaseException");
|
|
147
|
-
FETCH_ERROR_OCCURRED(tstate, exception_type, exception_value, exception_tb);
|
|
148
|
-
#else
|
|
149
|
-
FORMAT_TYPE_ERROR1(exception_type, exception_value,
|
|
150
|
-
"exception causes must derive from BaseException (%s does not)",
|
|
151
|
-
Py_TYPE(exception_cause)->tp_name);
|
|
152
119
|
#endif
|
|
153
120
|
|
|
154
|
-
Py_XDECREF(old_exception_cause);
|
|
155
121
|
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (unlikely(!PyExceptionInstance_Check(*exception_value))) {
|
|
162
|
-
Py_DECREF(*exception_tb);
|
|
163
|
-
Py_XDECREF(exception_cause);
|
|
164
|
-
|
|
165
|
-
PyObject *old_exception_type = *exception_type;
|
|
166
|
-
PyObject *old_exception_value = *exception_value;
|
|
167
|
-
|
|
168
|
-
FORMAT_TYPE_ERROR2(exception_type, exception_value,
|
|
169
|
-
"calling %s() should have returned an instance of BaseException, not '%s'",
|
|
170
|
-
Py_TYPE(*exception_type)->tp_name, Py_TYPE(*exception_value)->tp_name);
|
|
171
|
-
|
|
172
|
-
Py_DECREF(old_exception_type);
|
|
173
|
-
Py_XDECREF(old_exception_value);
|
|
122
|
+
} else if (PyExceptionInstance_Check(exception_state->exception_type)) {
|
|
123
|
+
if (unlikely(exception_state->exception_value != NULL && exception_state->exception_value != Py_None)) {
|
|
124
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
125
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_STR(tstate, exception_state, PyExc_TypeError,
|
|
126
|
+
"instance exception may not have a separate value");
|
|
174
127
|
|
|
175
128
|
return;
|
|
176
129
|
}
|
|
177
130
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
} else if (PyExceptionInstance_Check(*exception_type)) {
|
|
183
|
-
*exception_value = *exception_type;
|
|
184
|
-
*exception_type = PyExceptionInstance_Class(*exception_type);
|
|
185
|
-
Py_INCREF(*exception_type);
|
|
186
|
-
|
|
187
|
-
PyException_SetCause(*exception_value, exception_cause);
|
|
131
|
+
// The type is rather a value, so we are overriding it here.
|
|
132
|
+
exception_state->exception_value = exception_state->exception_type;
|
|
133
|
+
exception_state->exception_type = PyExceptionInstance_Class(exception_state->exception_type);
|
|
134
|
+
Py_INCREF(exception_state->exception_type);
|
|
188
135
|
|
|
189
|
-
CHAIN_EXCEPTION(tstate, *exception_value);
|
|
190
136
|
return;
|
|
191
137
|
} else {
|
|
192
|
-
|
|
138
|
+
char const *exception_type_type = Py_TYPE(exception_state->exception_type)->tp_name;
|
|
193
139
|
|
|
194
|
-
|
|
140
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
195
141
|
|
|
196
|
-
FORMAT_TYPE_ERROR1(
|
|
197
|
-
Py_TYPE(*exception_type)->tp_name);
|
|
198
|
-
|
|
199
|
-
Py_DECREF(old_exception_type);
|
|
142
|
+
FORMAT_TYPE_ERROR1(tstate, exception_state, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE, exception_type_type);
|
|
200
143
|
|
|
201
144
|
return;
|
|
202
145
|
}
|
|
203
146
|
}
|
|
204
|
-
#endif
|
|
205
147
|
|
|
206
|
-
|
|
207
|
-
PyTracebackObject **exception_tb) {
|
|
208
|
-
CHECK_OBJECT(*exception_type);
|
|
209
|
-
CHECK_OBJECT(*exception_value);
|
|
210
|
-
*exception_tb = NULL;
|
|
148
|
+
#else
|
|
211
149
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
*exception_type = PyTuple_GET_ITEM(*exception_type, 0);
|
|
215
|
-
}
|
|
150
|
+
void RAISE_EXCEPTION_WITH_VALUE(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
151
|
+
ASSERT_NORMALIZED_EXCEPTION_VALUE(exception_state->exception_value);
|
|
216
152
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
#
|
|
220
|
-
if (unlikely(!PyExceptionInstance_Check(*exception_value))) {
|
|
221
|
-
PyObject *old_exception_type = *exception_type;
|
|
222
|
-
PyObject *old_exception_value = *exception_type;
|
|
153
|
+
CHAIN_EXCEPTION(tstate, exception_state->exception_value);
|
|
154
|
+
}
|
|
155
|
+
#endif
|
|
223
156
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
157
|
+
#if PYTHON_VERSION >= 0x300
|
|
158
|
+
void RAISE_EXCEPTION_WITH_CAUSE(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
159
|
+
PyObject *exception_cause) {
|
|
160
|
+
CHECK_EXCEPTION_STATE(exception_state);
|
|
161
|
+
CHECK_OBJECT(exception_cause);
|
|
227
162
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
163
|
+
#if PYTHON_VERSION < 0x3c0
|
|
164
|
+
exception_state->exception_tb = NULL;
|
|
231
165
|
#endif
|
|
232
166
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
167
|
+
// None is not a cause.
|
|
168
|
+
if (exception_cause == Py_None) {
|
|
169
|
+
Py_DECREF_IMMORTAL(exception_cause);
|
|
170
|
+
exception_cause = NULL;
|
|
171
|
+
} else if (PyExceptionClass_Check(exception_cause)) {
|
|
172
|
+
PyObject *old_exception_cause = exception_cause;
|
|
173
|
+
exception_cause = CALL_FUNCTION_NO_ARGS(tstate, exception_cause);
|
|
174
|
+
Py_DECREF(old_exception_cause);
|
|
238
175
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
176
|
+
if (unlikely(exception_cause == NULL)) {
|
|
177
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
178
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
242
179
|
|
|
243
180
|
return;
|
|
244
181
|
}
|
|
182
|
+
}
|
|
245
183
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
184
|
+
if (unlikely(exception_cause != NULL && !PyExceptionInstance_Check(exception_cause))) {
|
|
185
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
186
|
+
|
|
187
|
+
#ifdef _NUITKA_FULL_COMPAT
|
|
188
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_STR(tstate, exception_state, PyExc_TypeError,
|
|
189
|
+
"exception causes must derive from BaseException");
|
|
190
|
+
#else
|
|
191
|
+
FORMAT_TYPE_ERROR1(tstate, exception_state, "exception causes must derive from BaseException (%s does not)",
|
|
192
|
+
Py_TYPE(exception_cause)->tp_name);
|
|
193
|
+
#endif
|
|
250
194
|
|
|
251
195
|
return;
|
|
252
|
-
}
|
|
253
|
-
PyObject *old_exception_type = *exception_type;
|
|
196
|
+
}
|
|
254
197
|
|
|
255
|
-
|
|
256
|
-
|
|
198
|
+
#if PYTHON_VERSION < 0x3c0
|
|
199
|
+
if (PyExceptionClass_Check(exception_state->exception_type)) {
|
|
200
|
+
char const *exception_type_type = Py_TYPE(exception_state->exception_type)->tp_name;
|
|
257
201
|
|
|
258
|
-
|
|
202
|
+
NORMALIZE_EXCEPTION_STATE(tstate, exception_state);
|
|
259
203
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
204
|
+
if (unlikely(!PyExceptionInstance_Check(exception_state->exception_value))) {
|
|
205
|
+
Py_XDECREF(exception_cause);
|
|
263
206
|
|
|
264
|
-
|
|
265
|
-
PyTracebackObject **exception_tb) {
|
|
266
|
-
CHECK_OBJECT(*exception_type);
|
|
267
|
-
CHECK_OBJECT(*exception_value);
|
|
268
|
-
*exception_tb = NULL;
|
|
207
|
+
char const *exception_value_type = Py_TYPE(exception_state->exception_value)->tp_name;
|
|
269
208
|
|
|
270
|
-
|
|
271
|
-
while (unlikely(PyTuple_Check(*exception_type) && PyTuple_GET_SIZE(*exception_type) > 0)) {
|
|
272
|
-
*exception_type = PyTuple_GET_ITEM(*exception_type, 0);
|
|
273
|
-
}
|
|
209
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
274
210
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
CHAIN_EXCEPTION(tstate, *exception_value);
|
|
279
|
-
#endif
|
|
211
|
+
FORMAT_TYPE_ERROR2(tstate, exception_state,
|
|
212
|
+
"calling %s() should have returned an instance of BaseException, not '%s'",
|
|
213
|
+
exception_type_type, exception_value_type);
|
|
280
214
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
#if PYTHON_VERSION >= 0x340
|
|
284
|
-
CHAIN_EXCEPTION(tstate, *exception_value);
|
|
285
|
-
#endif
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
286
217
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
218
|
+
Nuitka_Exception_SetCause(exception_state->exception_value, exception_cause);
|
|
219
|
+
CHAIN_EXCEPTION(tstate, exception_state->exception_value);
|
|
220
|
+
} else if (PyExceptionInstance_Check(exception_state->exception_type)) {
|
|
221
|
+
exception_state->exception_value = exception_state->exception_type;
|
|
222
|
+
exception_state->exception_type = PyExceptionInstance_Class(exception_state->exception_type);
|
|
223
|
+
Py_INCREF(exception_state->exception_type);
|
|
291
224
|
|
|
292
|
-
|
|
225
|
+
Nuitka_Exception_SetCause(exception_state->exception_value, exception_cause);
|
|
226
|
+
CHAIN_EXCEPTION(tstate, exception_state->exception_value);
|
|
293
227
|
} else {
|
|
294
|
-
|
|
295
|
-
Py_DECREF(*exception_value);
|
|
228
|
+
Py_XDECREF(exception_cause);
|
|
296
229
|
|
|
297
|
-
|
|
298
|
-
Py_TYPE(*exception_type)->tp_name);
|
|
230
|
+
char const *exception_type_type = Py_TYPE(exception_state->exception_type)->tp_name;
|
|
299
231
|
|
|
300
|
-
|
|
232
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
301
233
|
|
|
302
|
-
|
|
303
|
-
CHAIN_EXCEPTION(tstate, *exception_value);
|
|
304
|
-
#endif
|
|
305
|
-
|
|
306
|
-
return;
|
|
234
|
+
FORMAT_TYPE_ERROR1(tstate, exception_state, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE, exception_type_type);
|
|
307
235
|
}
|
|
308
|
-
|
|
236
|
+
#else
|
|
237
|
+
ASSERT_NORMALIZED_EXCEPTION_VALUE(exception_state->exception_value);
|
|
309
238
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
239
|
+
Nuitka_Exception_SetCause(exception_state->exception_value, exception_cause);
|
|
240
|
+
CHAIN_EXCEPTION(tstate, exception_state->exception_value);
|
|
241
|
+
#endif
|
|
242
|
+
}
|
|
243
|
+
#endif
|
|
314
244
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
245
|
+
#if PYTHON_VERSION < 0x300
|
|
246
|
+
void RAISE_EXCEPTION_WITH_TRACEBACK(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
247
|
+
if (exception_state->exception_tb == (PyTracebackObject *)Py_None) {
|
|
248
|
+
Py_DECREF_IMMORTAL(exception_state->exception_tb);
|
|
249
|
+
exception_state->exception_tb = NULL;
|
|
318
250
|
}
|
|
319
251
|
|
|
320
252
|
// Non-empty tuple exceptions are the first element.
|
|
321
|
-
|
|
322
|
-
*exception_type = PyTuple_GET_ITEM(*exception_type, 0);
|
|
323
|
-
}
|
|
253
|
+
UNPACK_TUPLE_EXCEPTION_TYPE(exception_state);
|
|
324
254
|
|
|
325
|
-
if (PyExceptionClass_Check(
|
|
326
|
-
|
|
255
|
+
if (PyExceptionClass_Check(exception_state->exception_type)) {
|
|
256
|
+
NORMALIZE_EXCEPTION_STATE(tstate, exception_state);
|
|
327
257
|
#if PYTHON_VERSION >= 0x270
|
|
328
|
-
if (unlikely(!PyExceptionInstance_Check(
|
|
329
|
-
|
|
330
|
-
|
|
258
|
+
if (unlikely(!PyExceptionInstance_Check(exception_state->exception_value))) {
|
|
259
|
+
char const *exception_type_type = Py_TYPE(exception_state->exception_type)->tp_name;
|
|
260
|
+
char const *exception_value_type = Py_TYPE(exception_state->exception_value)->tp_name;
|
|
331
261
|
|
|
332
|
-
|
|
333
|
-
"calling %s() should have returned an instance of BaseException, not '%s'",
|
|
334
|
-
Py_TYPE(*exception_type)->tp_name, Py_TYPE(*exception_value)->tp_name);
|
|
262
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
335
263
|
|
|
336
|
-
|
|
337
|
-
|
|
264
|
+
// TODO: It would be even more safe to create the format value
|
|
265
|
+
// before releasing the value.
|
|
266
|
+
FORMAT_TYPE_ERROR2(tstate, exception_state,
|
|
267
|
+
"calling %s() should have returned an instance of BaseException, not '%s'",
|
|
268
|
+
exception_type_type, exception_value_type);
|
|
338
269
|
}
|
|
339
270
|
#endif
|
|
340
271
|
|
|
341
272
|
return;
|
|
342
|
-
} else if (PyExceptionInstance_Check(
|
|
343
|
-
if (unlikely(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
*exception_type = PyExc_TypeError;
|
|
349
|
-
Py_INCREF(PyExc_TypeError);
|
|
350
|
-
*exception_value = Nuitka_String_FromString("instance exception may not have a separate value");
|
|
273
|
+
} else if (PyExceptionInstance_Check(exception_state->exception_type)) {
|
|
274
|
+
if (unlikely(exception_state->exception_value != NULL && exception_state->exception_value != Py_None)) {
|
|
275
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
276
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_STR(tstate, exception_state, PyExc_TypeError,
|
|
277
|
+
"instance exception may not have a separate value");
|
|
351
278
|
|
|
352
279
|
return;
|
|
353
280
|
}
|
|
354
281
|
|
|
355
282
|
// The type is rather a value, so we are overriding it here.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
Py_INCREF(
|
|
283
|
+
exception_state->exception_value = exception_state->exception_type;
|
|
284
|
+
exception_state->exception_type = PyExceptionInstance_Class(exception_state->exception_type);
|
|
285
|
+
Py_INCREF(exception_state->exception_type);
|
|
359
286
|
|
|
360
287
|
return;
|
|
361
288
|
} else {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
FORMAT_TYPE_ERROR1(exception_type, exception_value, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE,
|
|
365
|
-
Py_TYPE(*exception_type)->tp_name);
|
|
366
|
-
|
|
367
|
-
Py_DECREF(old_exception_type);
|
|
289
|
+
FORMAT_TYPE_ERROR1(tstate, exception_state, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE,
|
|
290
|
+
Py_TYPE(exception_state->exception_type)->tp_name);
|
|
368
291
|
|
|
369
292
|
return;
|
|
370
293
|
}
|
|
371
294
|
}
|
|
295
|
+
#endif
|
|
372
296
|
|
|
373
|
-
bool RERAISE_EXCEPTION(
|
|
374
|
-
PyThreadState *tstate = PyThreadState_GET();
|
|
375
|
-
assert(tstate);
|
|
376
|
-
|
|
297
|
+
bool RERAISE_EXCEPTION(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
377
298
|
#if PYTHON_VERSION < 0x3b0
|
|
378
|
-
|
|
379
|
-
Py_INCREF(
|
|
380
|
-
|
|
381
|
-
Py_XINCREF(
|
|
382
|
-
|
|
383
|
-
Py_XINCREF(
|
|
384
|
-
|
|
385
|
-
if (unlikely(
|
|
299
|
+
exception_state->exception_type = EXC_TYPE(tstate) != NULL ? EXC_TYPE(tstate) : Py_None;
|
|
300
|
+
Py_INCREF(exception_state->exception_type);
|
|
301
|
+
exception_state->exception_value = EXC_VALUE(tstate);
|
|
302
|
+
Py_XINCREF(exception_state->exception_value);
|
|
303
|
+
exception_state->exception_tb = (PyTracebackObject *)EXC_TRACEBACK(tstate);
|
|
304
|
+
Py_XINCREF(exception_state->exception_tb);
|
|
305
|
+
|
|
306
|
+
if (unlikely(exception_state->exception_type == Py_None)) {
|
|
386
307
|
#if PYTHON_VERSION >= 0x300
|
|
387
|
-
|
|
308
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
388
309
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
*exception_value = PyUnicode_FromString("No active exception to reraise");
|
|
392
|
-
*exception_tb = NULL;
|
|
310
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_STR(tstate, exception_state, PyExc_RuntimeError,
|
|
311
|
+
"No active exception to reraise");
|
|
393
312
|
#else
|
|
394
|
-
|
|
313
|
+
char const *exception_type_type = Py_TYPE(exception_state->exception_type)->tp_name;
|
|
395
314
|
|
|
396
|
-
|
|
397
|
-
|
|
315
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
316
|
+
|
|
317
|
+
FORMAT_TYPE_ERROR1(tstate, exception_state, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE, exception_type_type);
|
|
398
318
|
|
|
399
|
-
Py_DECREF(old_exception_type);
|
|
400
319
|
#endif
|
|
401
320
|
|
|
402
321
|
return false;
|
|
403
322
|
}
|
|
404
323
|
#else
|
|
405
|
-
|
|
324
|
+
exception_state->exception_value = EXC_VALUE(tstate);
|
|
406
325
|
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
*exception_value = PyUnicode_FromString("No active exception to reraise");
|
|
411
|
-
*exception_tb = NULL;
|
|
326
|
+
if (exception_state->exception_value == Py_None || exception_state->exception_value == NULL) {
|
|
327
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_STR(tstate, exception_state, PyExc_RuntimeError,
|
|
328
|
+
"No active exception to reraise");
|
|
412
329
|
|
|
413
330
|
return false;
|
|
414
331
|
} else {
|
|
415
|
-
Py_INCREF(
|
|
332
|
+
Py_INCREF(exception_state->exception_value);
|
|
416
333
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
334
|
+
#if PYTHON_VERSION < 0x3c0
|
|
335
|
+
exception_state->exception_type = PyExceptionInstance_Class(exception_state->exception_value);
|
|
336
|
+
Py_INCREF(exception_state->exception_type);
|
|
337
|
+
exception_state->exception_tb = GET_EXCEPTION_TRACEBACK(exception_state->exception_value);
|
|
338
|
+
Py_XINCREF(exception_state->exception_tb);
|
|
339
|
+
#endif
|
|
421
340
|
}
|
|
422
341
|
#endif
|
|
423
342
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
343
|
+
// Check for value to be present as well.
|
|
344
|
+
CHECK_EXCEPTION_STATE(exception_state);
|
|
345
|
+
CHECK_OBJECT(exception_state->exception_value);
|
|
427
346
|
|
|
428
347
|
return true;
|
|
429
348
|
}
|
|
430
349
|
|
|
431
350
|
// Raise NameError for a given variable name.
|
|
432
|
-
void RAISE_CURRENT_EXCEPTION_NAME_ERROR(PyThreadState *tstate,
|
|
433
|
-
PyObject
|
|
351
|
+
void RAISE_CURRENT_EXCEPTION_NAME_ERROR(PyThreadState *tstate, struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
352
|
+
PyObject *variable_name) {
|
|
434
353
|
#if PYTHON_VERSION < 0x300
|
|
435
354
|
PyObject *exception_value_str =
|
|
436
355
|
Nuitka_String_FromFormat("name '%s' is not defined", Nuitka_String_AsString_Unchecked(variable_name));
|
|
@@ -438,56 +357,82 @@ void RAISE_CURRENT_EXCEPTION_NAME_ERROR(PyThreadState *tstate, PyObject *variabl
|
|
|
438
357
|
PyObject *exception_value_str = Nuitka_String_FromFormat("name '%U' is not defined", variable_name);
|
|
439
358
|
#endif
|
|
440
359
|
|
|
441
|
-
*exception_value = MAKE_EXCEPTION_FROM_TYPE_ARG0(tstate, PyExc_NameError, exception_value_str);
|
|
360
|
+
PyObject *exception_value = MAKE_EXCEPTION_FROM_TYPE_ARG0(tstate, PyExc_NameError, exception_value_str);
|
|
442
361
|
Py_DECREF(exception_value_str);
|
|
443
362
|
|
|
444
|
-
*exception_type = PyExc_NameError;
|
|
445
|
-
Py_INCREF(PyExc_NameError);
|
|
446
|
-
|
|
447
363
|
#if PYTHON_VERSION >= 0x300
|
|
448
|
-
CHAIN_EXCEPTION(tstate,
|
|
364
|
+
CHAIN_EXCEPTION(tstate, exception_value);
|
|
449
365
|
#endif
|
|
366
|
+
|
|
367
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1_NORMALIZED(tstate, exception_state, PyExc_NameError,
|
|
368
|
+
exception_value);
|
|
450
369
|
}
|
|
451
370
|
|
|
452
|
-
#if PYTHON_VERSION < 0x340
|
|
453
|
-
void RAISE_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR(PyThreadState *tstate, PyObject *variable_name,
|
|
454
|
-
PyObject **exception_type, PyObject **exception_value) {
|
|
455
371
|
#if PYTHON_VERSION < 0x300
|
|
372
|
+
void RAISE_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR(PyThreadState *tstate,
|
|
373
|
+
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
374
|
+
PyObject *variable_name) {
|
|
456
375
|
PyObject *exception_value_str =
|
|
457
376
|
Nuitka_String_FromFormat("global name '%s' is not defined", Nuitka_String_AsString_Unchecked(variable_name));
|
|
458
|
-
|
|
459
|
-
PyObject *exception_value_str = Nuitka_String_FromFormat("global name '%U' is not defined", variable_name);
|
|
460
|
-
#endif
|
|
461
|
-
*exception_value = MAKE_EXCEPTION_FROM_TYPE_ARG0(tstate, PyExc_NameError, exception_value_str);
|
|
377
|
+
PyObject *exception_value = MAKE_EXCEPTION_FROM_TYPE_ARG0(tstate, PyExc_NameError, exception_value_str);
|
|
462
378
|
Py_DECREF(exception_value_str);
|
|
463
379
|
|
|
464
|
-
|
|
465
|
-
|
|
380
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_TYPE0_VALUE1_NORMALIZED(tstate, exception_state, PyExc_NameError,
|
|
381
|
+
exception_value);
|
|
466
382
|
}
|
|
467
383
|
#endif
|
|
468
384
|
|
|
469
|
-
|
|
385
|
+
PyObject *NORMALIZE_EXCEPTION_VALUE_FOR_RAISE(PyThreadState *tstate, PyObject *exception_type) {
|
|
386
|
+
// Allow setting the value to NULL for time savings with quick type only errors
|
|
387
|
+
CHECK_OBJECT(exception_type);
|
|
470
388
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
389
|
+
if (PyExceptionInstance_Check(exception_type)) {
|
|
390
|
+
return Py_NewRef(exception_type);
|
|
391
|
+
} else {
|
|
392
|
+
if (unlikely(!PyExceptionClass_Check(exception_type))) {
|
|
393
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
394
|
+
FORMAT_TYPE_ERROR1(tstate, &exception_state, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE,
|
|
395
|
+
Py_TYPE(exception_type)->tp_name);
|
|
396
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &exception_state);
|
|
397
|
+
return NULL;
|
|
398
|
+
}
|
|
480
399
|
|
|
481
|
-
|
|
482
|
-
// we shouldn't really need them.
|
|
483
|
-
RAISE_EXCEPTION_WITH_CAUSE(tstate, &exception_type, &exception_state->exception_value, &exception_tb,
|
|
484
|
-
exception_cause);
|
|
400
|
+
PyObject *exception_value = CALL_FUNCTION_NO_ARGS(tstate, exception_type);
|
|
485
401
|
|
|
486
|
-
|
|
487
|
-
|
|
402
|
+
if (unlikely(exception_value == NULL)) {
|
|
403
|
+
return NULL;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (unlikely(!PyExceptionInstance_Check(exception_value))) {
|
|
407
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
408
|
+
FORMAT_TYPE_ERROR2(tstate, &exception_state,
|
|
409
|
+
"calling %R should have returned an instance of BaseException, not %R",
|
|
410
|
+
(char const *)exception_type, (char const *)Py_TYPE(exception_value));
|
|
411
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &exception_state);
|
|
412
|
+
|
|
413
|
+
Py_DECREF(exception_value);
|
|
414
|
+
return NULL;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return exception_value;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
#if PYTHON_VERSION >= 0x300
|
|
422
|
+
PyObject *MAKE_STOP_ITERATION_EMPTY(void) {
|
|
423
|
+
// Fake tstate object is OK, no tuple will be needed.
|
|
424
|
+
return Nuitka_CreateStopIteration(NULL, NULL);
|
|
488
425
|
}
|
|
489
|
-
#endif
|
|
490
426
|
|
|
427
|
+
PyObject *MAKE_BASE_EXCEPTION_DERIVED_EMPTY(PyObject *exception_type) {
|
|
428
|
+
// Note: Fake tstate object is OK, no tuple will be needed to store anything
|
|
429
|
+
// in args.
|
|
430
|
+
PyBaseExceptionObject *result = Nuitka_BaseExceptionSingleArg_new(NULL, (PyTypeObject *)exception_type, NULL);
|
|
431
|
+
|
|
432
|
+
return (PyObject *)result;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
#endif
|
|
491
436
|
// Part of "Nuitka", an optimizing Python compiler that is compatible and
|
|
492
437
|
// integrates with CPython, but also works on its own.
|
|
493
438
|
//
|