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
|
@@ -16,12 +16,11 @@ And releasing of values, as this is what the error case commonly does.
|
|
|
16
16
|
|
|
17
17
|
from nuitka.PythonVersions import python_version
|
|
18
18
|
|
|
19
|
-
from .ExceptionCodes import getExceptionIdentifier
|
|
20
19
|
from .Indentation import indented
|
|
21
20
|
from .LineNumberCodes import getErrorLineNumberUpdateCode
|
|
22
21
|
from .templates.CodeTemplatesExceptions import (
|
|
23
22
|
template_error_catch_exception,
|
|
24
|
-
|
|
23
|
+
template_error_catch_fetched_exception,
|
|
25
24
|
template_error_format_name_error_exception,
|
|
26
25
|
template_error_format_string_exception,
|
|
27
26
|
)
|
|
@@ -32,12 +31,15 @@ def getErrorExitReleaseCode(context):
|
|
|
32
31
|
"Py_DECREF(%s);" % tmp_name for tmp_name in context.getCleanupTempNames()
|
|
33
32
|
)
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
(
|
|
35
|
+
keeper_exception_state_name,
|
|
36
|
+
_keeper_lineno,
|
|
37
|
+
) = context.getExceptionKeeperVariables()
|
|
36
38
|
|
|
37
|
-
if
|
|
38
|
-
temp_release +=
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if keeper_exception_state_name is not None:
|
|
40
|
+
temp_release += (
|
|
41
|
+
"\nRELEASE_ERROR_OCCURRED_STATE(&%s);" % keeper_exception_state_name
|
|
42
|
+
)
|
|
41
43
|
|
|
42
44
|
return temp_release
|
|
43
45
|
|
|
@@ -60,8 +62,8 @@ def getErrorExitBoolCode(
|
|
|
60
62
|
context,
|
|
61
63
|
release_names=(),
|
|
62
64
|
release_name=None,
|
|
65
|
+
fetched_exception=False,
|
|
63
66
|
needs_check=True,
|
|
64
|
-
quick_exception=None,
|
|
65
67
|
):
|
|
66
68
|
assert not condition.endswith(";")
|
|
67
69
|
|
|
@@ -79,23 +81,18 @@ def getErrorExitBoolCode(
|
|
|
79
81
|
return
|
|
80
82
|
|
|
81
83
|
(
|
|
82
|
-
|
|
83
|
-
exception_value,
|
|
84
|
-
exception_tb,
|
|
84
|
+
exception_state_name,
|
|
85
85
|
_exception_lineno,
|
|
86
86
|
) = context.variable_storage.getExceptionVariableDescriptions()
|
|
87
87
|
|
|
88
|
-
if
|
|
88
|
+
if fetched_exception:
|
|
89
89
|
emit(
|
|
90
90
|
indented(
|
|
91
|
-
|
|
91
|
+
template_error_catch_fetched_exception
|
|
92
92
|
% {
|
|
93
93
|
"condition": condition,
|
|
94
|
-
"
|
|
95
|
-
"exception_value": exception_value,
|
|
96
|
-
"exception_tb": exception_tb,
|
|
94
|
+
"exception_state_name": exception_state_name,
|
|
97
95
|
"exception_exit": context.getExceptionEscape(),
|
|
98
|
-
"quick_exception": getExceptionIdentifier(quick_exception),
|
|
99
96
|
"release_temps": indented(getErrorExitReleaseCode(context)),
|
|
100
97
|
"var_description_code": indented(
|
|
101
98
|
getFrameVariableTypeDescriptionCode(context)
|
|
@@ -111,9 +108,7 @@ def getErrorExitBoolCode(
|
|
|
111
108
|
template_error_catch_exception
|
|
112
109
|
% {
|
|
113
110
|
"condition": condition,
|
|
114
|
-
"
|
|
115
|
-
"exception_value": exception_value,
|
|
116
|
-
"exception_tb": exception_tb,
|
|
111
|
+
"exception_state_name": exception_state_name,
|
|
117
112
|
"exception_exit": context.getExceptionEscape(),
|
|
118
113
|
"release_temps": indented(getErrorExitReleaseCode(context)),
|
|
119
114
|
"var_description_code": indented(
|
|
@@ -132,7 +127,7 @@ def getErrorExitCode(
|
|
|
132
127
|
context,
|
|
133
128
|
release_names=(),
|
|
134
129
|
release_name=None,
|
|
135
|
-
|
|
130
|
+
fetched_exception=False,
|
|
136
131
|
needs_check=True,
|
|
137
132
|
):
|
|
138
133
|
getErrorExitBoolCode(
|
|
@@ -140,7 +135,7 @@ def getErrorExitCode(
|
|
|
140
135
|
release_names=release_names,
|
|
141
136
|
release_name=release_name,
|
|
142
137
|
needs_check=needs_check,
|
|
143
|
-
|
|
138
|
+
fetched_exception=fetched_exception,
|
|
144
139
|
emit=emit,
|
|
145
140
|
context=context,
|
|
146
141
|
)
|
|
@@ -148,25 +143,22 @@ def getErrorExitCode(
|
|
|
148
143
|
|
|
149
144
|
def _getExceptionChainingCode(context):
|
|
150
145
|
(
|
|
151
|
-
|
|
152
|
-
exception_value,
|
|
153
|
-
exception_tb,
|
|
146
|
+
exception_state_name,
|
|
154
147
|
_exception_lineno,
|
|
155
148
|
) = context.variable_storage.getExceptionVariableDescriptions()
|
|
156
149
|
|
|
157
|
-
|
|
150
|
+
(
|
|
151
|
+
keeper_exception_state_name,
|
|
152
|
+
_keeper_lineno,
|
|
153
|
+
) = context.getExceptionKeeperVariables()
|
|
158
154
|
|
|
159
|
-
if
|
|
160
|
-
|
|
161
|
-
"ADD_EXCEPTION_CONTEXT(tstate, &%s, &%s);"
|
|
162
|
-
% (keeper_vars[0], keeper_vars[1]),
|
|
163
|
-
)
|
|
155
|
+
if keeper_exception_state_name is not None:
|
|
156
|
+
yield "ADD_EXCEPTION_CONTEXT(tstate, &%s);" % keeper_exception_state_name
|
|
164
157
|
else:
|
|
165
|
-
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)
|
|
158
|
+
if python_version < 0x3C0:
|
|
159
|
+
yield "NORMALIZE_EXCEPTION_STATE(tstate, &%s);" % exception_state_name
|
|
160
|
+
|
|
161
|
+
yield "CHAIN_EXCEPTION(tstate, %s.exception_value);" % exception_state_name
|
|
170
162
|
|
|
171
163
|
|
|
172
164
|
def getTakeReferenceCode(value_name, emit):
|
|
@@ -204,9 +196,7 @@ def getLocalVariableReferenceErrorCode(variable, condition, emit, context):
|
|
|
204
196
|
variable_name = variable.getName()
|
|
205
197
|
|
|
206
198
|
(
|
|
207
|
-
|
|
208
|
-
exception_value,
|
|
209
|
-
exception_tb,
|
|
199
|
+
exception_state_name,
|
|
210
200
|
_exception_lineno,
|
|
211
201
|
) = context.variable_storage.getExceptionVariableDescriptions()
|
|
212
202
|
|
|
@@ -216,14 +206,12 @@ def getLocalVariableReferenceErrorCode(variable, condition, emit, context):
|
|
|
216
206
|
helper_code = "FORMAT_UNBOUND_LOCAL_ERROR"
|
|
217
207
|
|
|
218
208
|
set_exception = [
|
|
219
|
-
"%s(
|
|
209
|
+
"%s(tstate, &%s, %s);"
|
|
220
210
|
% (
|
|
221
211
|
helper_code,
|
|
222
|
-
|
|
223
|
-
exception_value,
|
|
212
|
+
exception_state_name,
|
|
224
213
|
context.getConstantCode(variable_name),
|
|
225
214
|
),
|
|
226
|
-
"%s = NULL;" % exception_tb,
|
|
227
215
|
]
|
|
228
216
|
|
|
229
217
|
# TODO: Move this into the helper code.
|
|
@@ -249,16 +237,14 @@ def getLocalVariableReferenceErrorCode(variable, condition, emit, context):
|
|
|
249
237
|
def getNameReferenceErrorCode(variable_name, condition, emit, context):
|
|
250
238
|
helper_code = "RAISE_CURRENT_EXCEPTION_NAME_ERROR"
|
|
251
239
|
|
|
252
|
-
if python_version <
|
|
240
|
+
if python_version < 0x300:
|
|
253
241
|
owner = context.getOwner()
|
|
254
242
|
|
|
255
243
|
if not owner.isCompiledPythonModule() and not owner.isExpressionClassBodyBase():
|
|
256
244
|
helper_code = "RAISE_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR"
|
|
257
245
|
|
|
258
246
|
(
|
|
259
|
-
|
|
260
|
-
exception_value,
|
|
261
|
-
exception_tb,
|
|
247
|
+
exception_state_name,
|
|
262
248
|
_exception_lineno,
|
|
263
249
|
) = context.variable_storage.getExceptionVariableDescriptions()
|
|
264
250
|
|
|
@@ -274,9 +260,7 @@ def getNameReferenceErrorCode(variable_name, condition, emit, context):
|
|
|
274
260
|
getFrameVariableTypeDescriptionCode(context)
|
|
275
261
|
),
|
|
276
262
|
"line_number_code": indented(getErrorLineNumberUpdateCode(context)),
|
|
277
|
-
"
|
|
278
|
-
"exception_value": exception_value,
|
|
279
|
-
"exception_tb": exception_tb,
|
|
263
|
+
"exception_state_name": exception_state_name,
|
|
280
264
|
}
|
|
281
265
|
)
|
|
282
266
|
|
|
@@ -11,6 +11,7 @@ from .CodeHelpers import (
|
|
|
11
11
|
generateExpressionCode,
|
|
12
12
|
withObjectCodeTemporaryAssignment,
|
|
13
13
|
)
|
|
14
|
+
from .ErrorCodes import getErrorExitCode
|
|
14
15
|
from .templates.CodeTemplatesExceptions import (
|
|
15
16
|
template_publish_exception_to_handler,
|
|
16
17
|
)
|
|
@@ -42,57 +43,83 @@ def getTracebackMakingIdentifier(context, lineno_name):
|
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
def generateExceptionCaughtTypeCode(to_name, expression, emit, context):
|
|
45
|
-
|
|
46
|
+
(
|
|
47
|
+
keeper_exception_state_name,
|
|
48
|
+
_keeper_lineno,
|
|
49
|
+
) = context.getExceptionKeeperVariables()
|
|
46
50
|
|
|
47
51
|
with withObjectCodeTemporaryAssignment(
|
|
48
52
|
to_name, "exception_caught_type", expression, emit, context
|
|
49
53
|
) as value_name:
|
|
50
|
-
if
|
|
51
|
-
emit("%s = EXC_TYPE(
|
|
54
|
+
if keeper_exception_state_name is None:
|
|
55
|
+
emit("%s = EXC_TYPE(tstate);" % (value_name,))
|
|
52
56
|
else:
|
|
53
|
-
|
|
57
|
+
if python_version < 0x3C0:
|
|
58
|
+
emit(
|
|
59
|
+
"%s = %s.exception_type;"
|
|
60
|
+
% (value_name, keeper_exception_state_name)
|
|
61
|
+
)
|
|
62
|
+
else:
|
|
63
|
+
emit(
|
|
64
|
+
"%s = %s.exception_value;"
|
|
65
|
+
% (value_name, keeper_exception_state_name)
|
|
66
|
+
)
|
|
54
67
|
|
|
55
68
|
|
|
56
69
|
def generateExceptionCaughtValueCode(to_name, expression, emit, context):
|
|
57
|
-
|
|
70
|
+
(
|
|
71
|
+
keeper_exception_state_name,
|
|
72
|
+
_keeper_lineno,
|
|
73
|
+
) = context.getExceptionKeeperVariables()
|
|
58
74
|
|
|
59
75
|
with withObjectCodeTemporaryAssignment(
|
|
60
76
|
to_name, "exception_caught_value", expression, emit, context
|
|
61
77
|
) as value_name:
|
|
62
|
-
if
|
|
63
|
-
emit("%s = EXC_VALUE(
|
|
78
|
+
if keeper_exception_state_name is None:
|
|
79
|
+
emit("%s = EXC_VALUE(tstate);" % value_name)
|
|
80
|
+
elif python_version >= 0x270:
|
|
81
|
+
emit("%s = %s.exception_value;" % (value_name, keeper_exception_state_name))
|
|
64
82
|
else:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
# For Python2.6, value can be NULL.
|
|
84
|
+
emit(
|
|
85
|
+
"%s = %s.exception_value ? %s.exception_value : Py_None;"
|
|
86
|
+
% (
|
|
87
|
+
value_name,
|
|
88
|
+
keeper_exception_state_name,
|
|
89
|
+
keeper_exception_state_name,
|
|
71
90
|
)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
emit("CHECK_OBJECT(%s); " % value_name)
|
|
72
94
|
|
|
73
95
|
|
|
74
96
|
def generateExceptionCaughtTracebackCode(to_name, expression, emit, context):
|
|
75
|
-
|
|
97
|
+
(
|
|
98
|
+
keeper_exception_state_name,
|
|
99
|
+
keeper_lineno,
|
|
100
|
+
) = context.getExceptionKeeperVariables()
|
|
76
101
|
|
|
77
102
|
with withObjectCodeTemporaryAssignment(
|
|
78
103
|
to_name, "exception_caught_tb", expression, emit, context
|
|
79
104
|
) as value_name:
|
|
80
|
-
if
|
|
105
|
+
if keeper_exception_state_name is None:
|
|
81
106
|
if python_version < 0x3B0:
|
|
82
|
-
emit(
|
|
83
|
-
"%s = (PyObject *)EXC_TRACEBACK(PyThreadState_GET());"
|
|
84
|
-
% (value_name,)
|
|
85
|
-
)
|
|
107
|
+
emit("%s = (PyObject *)EXC_TRACEBACK(tstate);" % (value_name,))
|
|
86
108
|
else:
|
|
87
109
|
emit(
|
|
88
|
-
"
|
|
89
|
-
|
|
110
|
+
"""\
|
|
111
|
+
%(value_name)s = (PyObject *)GET_EXCEPTION_TRACEBACK(EXC_VALUE(tstate));
|
|
112
|
+
if (%(value_name)s == NULL) {
|
|
113
|
+
%(value_name)s = Py_None;
|
|
114
|
+
}"""
|
|
115
|
+
% {"value_name": value_name}
|
|
90
116
|
)
|
|
117
|
+
|
|
91
118
|
else:
|
|
92
119
|
emit(
|
|
93
120
|
"""\
|
|
94
|
-
if (%(
|
|
95
|
-
%(to_name)s = (PyObject *)%(
|
|
121
|
+
if (%(keeper_exception_state_name)s.exception_tb != NULL) {
|
|
122
|
+
%(to_name)s = (PyObject *)%(keeper_exception_state_name)s.exception_tb;
|
|
96
123
|
Py_INCREF(%(to_name)s);
|
|
97
124
|
} else {
|
|
98
125
|
%(to_name)s = (PyObject *)%(tb_making)s;
|
|
@@ -100,9 +127,9 @@ if (%(keeper_tb)s != NULL) {
|
|
|
100
127
|
"""
|
|
101
128
|
% {
|
|
102
129
|
"to_name": value_name,
|
|
103
|
-
"
|
|
130
|
+
"keeper_exception_state_name": keeper_exception_state_name,
|
|
104
131
|
"tb_making": getTracebackMakingIdentifier(
|
|
105
|
-
context=context, lineno_name=
|
|
132
|
+
context=context, lineno_name=keeper_lineno
|
|
106
133
|
),
|
|
107
134
|
}
|
|
108
135
|
)
|
|
@@ -111,12 +138,13 @@ if (%(keeper_tb)s != NULL) {
|
|
|
111
138
|
|
|
112
139
|
|
|
113
140
|
def getExceptionUnpublishedReleaseCode(emit, context):
|
|
114
|
-
|
|
141
|
+
(
|
|
142
|
+
keeper_exception_state_name,
|
|
143
|
+
_keeper_lineno,
|
|
144
|
+
) = context.getExceptionKeeperVariables()
|
|
115
145
|
|
|
116
|
-
if
|
|
117
|
-
emit("
|
|
118
|
-
emit("Py_XDECREF(%s);" % keeper_variables[1])
|
|
119
|
-
emit("Py_XDECREF(%s);" % keeper_variables[2])
|
|
146
|
+
if keeper_exception_state_name is not None:
|
|
147
|
+
emit("RELEASE_ERROR_OCCURRED_STATE(&%s);" % keeper_exception_state_name)
|
|
120
148
|
|
|
121
149
|
|
|
122
150
|
def generateExceptionPublishCode(statement, emit, context):
|
|
@@ -124,11 +152,9 @@ def generateExceptionPublishCode(statement, emit, context):
|
|
|
124
152
|
|
|
125
153
|
# Current variables cannot be used anymore now.
|
|
126
154
|
(
|
|
127
|
-
|
|
128
|
-
keeper_value,
|
|
129
|
-
keeper_tb,
|
|
155
|
+
keeper_exception_state_name,
|
|
130
156
|
keeper_lineno,
|
|
131
|
-
) = context.setExceptionKeeperVariables((None, None
|
|
157
|
+
) = context.setExceptionKeeperVariables((None, None))
|
|
132
158
|
|
|
133
159
|
emit(
|
|
134
160
|
template_publish_exception_to_handler
|
|
@@ -136,7 +162,7 @@ def generateExceptionPublishCode(statement, emit, context):
|
|
|
136
162
|
"tb_making": getTracebackMakingIdentifier(
|
|
137
163
|
context=context, lineno_name=keeper_lineno
|
|
138
164
|
),
|
|
139
|
-
"
|
|
165
|
+
"keeper_exception_state_name": keeper_exception_state_name,
|
|
140
166
|
"keeper_lineno": keeper_lineno,
|
|
141
167
|
"frame_identifier": context.getFrameHandle(),
|
|
142
168
|
}
|
|
@@ -144,15 +170,44 @@ def generateExceptionPublishCode(statement, emit, context):
|
|
|
144
170
|
|
|
145
171
|
# TODO: Make this one thing for performance with thread state shared, also for less code,
|
|
146
172
|
# then we should not make it in header anymore. Might be more scalable too.
|
|
147
|
-
emit(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
173
|
+
emit("PUBLISH_CURRENT_EXCEPTION(tstate, &%s);" % keeper_exception_state_name)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _attachExceptionAttributeCode(
|
|
177
|
+
to_name,
|
|
178
|
+
attribute_expression,
|
|
179
|
+
c_type_name,
|
|
180
|
+
c_attribute_name,
|
|
181
|
+
base_name_str,
|
|
182
|
+
emit,
|
|
183
|
+
context,
|
|
184
|
+
):
|
|
185
|
+
if attribute_expression is not None:
|
|
186
|
+
from .PythonAPICodes import getReferenceExportCode
|
|
187
|
+
|
|
188
|
+
exception_attribute_name = context.allocateTempName(
|
|
189
|
+
base_name_str + "_" + c_attribute_name
|
|
190
|
+
)
|
|
151
191
|
|
|
192
|
+
generateExpressionCode(
|
|
193
|
+
to_name=exception_attribute_name,
|
|
194
|
+
expression=attribute_expression,
|
|
195
|
+
emit=emit,
|
|
196
|
+
context=context,
|
|
197
|
+
allow_none=True,
|
|
198
|
+
)
|
|
152
199
|
|
|
153
|
-
|
|
154
|
-
|
|
200
|
+
getReferenceExportCode(exception_attribute_name, emit, context)
|
|
201
|
+
if context.needsCleanup(exception_attribute_name):
|
|
202
|
+
context.removeCleanupTempName(exception_attribute_name)
|
|
155
203
|
|
|
204
|
+
emit(
|
|
205
|
+
"((%s *)%s)->%s = %s;"
|
|
206
|
+
% (c_type_name, to_name, c_attribute_name, exception_attribute_name)
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _generateBuiltinMakeExceptionCode(to_name, expression, for_raise, emit, context):
|
|
156
211
|
from .CallCodes import getCallCodeNoArgs, getCallCodePosArgsQuick
|
|
157
212
|
|
|
158
213
|
exception_arg_names = []
|
|
@@ -174,10 +229,27 @@ def generateBuiltinMakeExceptionCode(to_name, expression, emit, context):
|
|
|
174
229
|
with withObjectCodeTemporaryAssignment(
|
|
175
230
|
to_name, "exception_made", expression, emit, context
|
|
176
231
|
) as value_name:
|
|
177
|
-
|
|
232
|
+
exception_name = getExceptionIdentifier(exception_type)
|
|
233
|
+
|
|
234
|
+
if len(exception_arg_names) == 1 and for_raise:
|
|
235
|
+
emit(
|
|
236
|
+
"%s = MAKE_EXCEPTION_WITH_VALUE(tstate, %s, %s);"
|
|
237
|
+
% (value_name, exception_name, exception_arg_names[0])
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
getErrorExitCode(
|
|
241
|
+
check_name=value_name,
|
|
242
|
+
release_names=exception_arg_names,
|
|
243
|
+
needs_check=expression.mayRaiseExceptionOperation(),
|
|
244
|
+
emit=emit,
|
|
245
|
+
context=context,
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
context.addCleanupTempName(value_name)
|
|
249
|
+
elif exception_arg_names:
|
|
178
250
|
getCallCodePosArgsQuick(
|
|
179
251
|
to_name=value_name,
|
|
180
|
-
called_name=
|
|
252
|
+
called_name=exception_name,
|
|
181
253
|
expression=expression,
|
|
182
254
|
arg_names=exception_arg_names,
|
|
183
255
|
emit=emit,
|
|
@@ -187,69 +259,66 @@ def generateBuiltinMakeExceptionCode(to_name, expression, emit, context):
|
|
|
187
259
|
else:
|
|
188
260
|
getCallCodeNoArgs(
|
|
189
261
|
to_name=value_name,
|
|
190
|
-
called_name=
|
|
262
|
+
called_name=exception_name,
|
|
191
263
|
expression=expression,
|
|
192
264
|
emit=emit,
|
|
193
265
|
context=context,
|
|
194
266
|
)
|
|
195
267
|
|
|
196
|
-
if
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
exception_importerror_name = context.allocateTempName(
|
|
210
|
-
"make_exception_importerror_name"
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
generateExpressionCode(
|
|
214
|
-
to_name=exception_importerror_name,
|
|
215
|
-
expression=import_error_name_expression,
|
|
216
|
-
emit=emit,
|
|
217
|
-
context=context,
|
|
218
|
-
allow_none=True,
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
getReferenceExportCode(exception_importerror_name, emit, context)
|
|
222
|
-
if context.needsCleanup(exception_importerror_name):
|
|
223
|
-
context.removeCleanupTempName(exception_importerror_name)
|
|
224
|
-
|
|
225
|
-
emit(
|
|
226
|
-
"((PyImportErrorObject *)%s)->name = %s;"
|
|
227
|
-
% (to_name, exception_importerror_name)
|
|
228
|
-
)
|
|
268
|
+
if (
|
|
269
|
+
expression.isExpressionBuiltinMakeExceptionImportError()
|
|
270
|
+
or expression.isExpressionBuiltinMakeExceptionModuleNotFoundError()
|
|
271
|
+
):
|
|
272
|
+
_attachExceptionAttributeCode(
|
|
273
|
+
to_name=to_name,
|
|
274
|
+
attribute_expression=expression.subnode_name,
|
|
275
|
+
base_name_str="exception_import_error",
|
|
276
|
+
c_type_name="PyImportErrorObject",
|
|
277
|
+
c_attribute_name="name",
|
|
278
|
+
emit=emit,
|
|
279
|
+
context=context,
|
|
280
|
+
)
|
|
229
281
|
|
|
230
|
-
|
|
282
|
+
_attachExceptionAttributeCode(
|
|
283
|
+
to_name=to_name,
|
|
284
|
+
attribute_expression=expression.subnode_path,
|
|
285
|
+
base_name_str="exception_import_error",
|
|
286
|
+
c_type_name="PyImportErrorObject",
|
|
287
|
+
c_attribute_name="path",
|
|
288
|
+
emit=emit,
|
|
289
|
+
context=context,
|
|
290
|
+
)
|
|
231
291
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
292
|
+
elif expression.isExpressionBuiltinMakeExceptionAttributeError():
|
|
293
|
+
_attachExceptionAttributeCode(
|
|
294
|
+
to_name=to_name,
|
|
295
|
+
attribute_expression=expression.subnode_name,
|
|
296
|
+
base_name_str="exception_import_error",
|
|
297
|
+
c_type_name="PyAttributeErrorObject",
|
|
298
|
+
c_attribute_name="name",
|
|
299
|
+
emit=emit,
|
|
300
|
+
context=context,
|
|
301
|
+
)
|
|
236
302
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
303
|
+
_attachExceptionAttributeCode(
|
|
304
|
+
to_name=to_name,
|
|
305
|
+
attribute_expression=expression.subnode_obj,
|
|
306
|
+
base_name_str="exception_import_error",
|
|
307
|
+
c_type_name="PyAttributeErrorObject",
|
|
308
|
+
c_attribute_name="obj",
|
|
309
|
+
emit=emit,
|
|
310
|
+
context=context,
|
|
311
|
+
)
|
|
244
312
|
|
|
245
|
-
getReferenceExportCode(exception_importerror_path, emit, context)
|
|
246
|
-
if context.needsCleanup(exception_importerror_path):
|
|
247
|
-
context.removeCleanupTempName(exception_importerror_path)
|
|
248
313
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
314
|
+
def generateBuiltinMakeExceptionCode(to_name, expression, emit, context):
|
|
315
|
+
_generateBuiltinMakeExceptionCode(
|
|
316
|
+
to_name=to_name,
|
|
317
|
+
expression=expression,
|
|
318
|
+
for_raise=expression.for_raise,
|
|
319
|
+
emit=emit,
|
|
320
|
+
context=context,
|
|
321
|
+
)
|
|
253
322
|
|
|
254
323
|
|
|
255
324
|
# Part of "Nuitka", an optimizing Python compiler that is compatible and
|
|
@@ -20,26 +20,39 @@ from nuitka.nodes.shapes.BuiltinTypeShapes import (
|
|
|
20
20
|
from nuitka.PythonVersions import (
|
|
21
21
|
isPythonValidCLongValue,
|
|
22
22
|
isPythonValidDigitValue,
|
|
23
|
-
python_version,
|
|
24
23
|
)
|
|
25
24
|
|
|
26
25
|
from .c_types.CTypeCFloats import CTypeCFloat
|
|
27
26
|
from .c_types.CTypeCLongs import CTypeCLong, CTypeCLongDigit
|
|
27
|
+
from .c_types.CTypeNuitkaInts import CTypeNuitkaIntOrLongStruct
|
|
28
28
|
from .c_types.CTypePyObjectPointers import CTypePyObjectPtr
|
|
29
|
+
from .VariableCodes import getLocalVariableDeclaration
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
def _pickIntFamilyType(expression):
|
|
32
|
+
def _pickIntFamilyType(expression, context):
|
|
32
33
|
if expression.isCompileTimeConstant():
|
|
33
|
-
|
|
34
|
-
# of it, for Python3, it should be avoided, it usually is around 2**30.
|
|
35
|
-
if python_version < 0x300:
|
|
36
|
-
c_type = CTypeCLong
|
|
37
|
-
elif isPythonValidDigitValue(expression.getCompileTimeConstant()):
|
|
34
|
+
if isPythonValidDigitValue(expression.getCompileTimeConstant()):
|
|
38
35
|
c_type = CTypeCLongDigit
|
|
39
36
|
elif isPythonValidCLongValue(expression.getCompileTimeConstant()):
|
|
40
37
|
c_type = CTypeCLong
|
|
41
38
|
else:
|
|
42
39
|
c_type = CTypePyObjectPtr
|
|
40
|
+
elif expression.isExpressionVariableRefOrTempVariableRef():
|
|
41
|
+
# TODO: Module variables are not doing it (yet?)
|
|
42
|
+
variable = expression.getVariable()
|
|
43
|
+
|
|
44
|
+
# TODO: Closure variables should be possible to have non
|
|
45
|
+
# CTypePyObjectPtr eventually.
|
|
46
|
+
if variable.isLocalVariable() and not variable.isSharedTechnically():
|
|
47
|
+
variable_declaration = getLocalVariableDeclaration(
|
|
48
|
+
context=context,
|
|
49
|
+
variable=expression.getVariable(),
|
|
50
|
+
variable_trace=expression.getVariableTrace(),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
c_type = variable_declaration.getCType()
|
|
54
|
+
else:
|
|
55
|
+
c_type = CTypePyObjectPtr
|
|
43
56
|
else:
|
|
44
57
|
c_type = CTypePyObjectPtr
|
|
45
58
|
|
|
@@ -84,6 +97,8 @@ _long_argument_normalization = {
|
|
|
84
97
|
(CTypeCLong, CTypePyObjectPtr): True,
|
|
85
98
|
(CTypePyObjectPtr, CTypeCLongDigit): False,
|
|
86
99
|
(CTypeCLongDigit, CTypePyObjectPtr): True,
|
|
100
|
+
(CTypeNuitkaIntOrLongStruct, CTypeCLongDigit): False,
|
|
101
|
+
(CTypeCLongDigit, CTypeNuitkaIntOrLongStruct): True,
|
|
87
102
|
}
|
|
88
103
|
|
|
89
104
|
_str_argument_normalization = {
|
|
@@ -95,7 +110,7 @@ _bytes_argument_normalization = {
|
|
|
95
110
|
}
|
|
96
111
|
|
|
97
112
|
|
|
98
|
-
def decideExpressionCTypes(left, right, may_swap_arguments):
|
|
113
|
+
def decideExpressionCTypes(left, right, may_swap_arguments, context):
|
|
99
114
|
# Complex stuff with many cases, pylint: disable=too-many-branches
|
|
100
115
|
|
|
101
116
|
left_shape = left.getTypeShape()
|
|
@@ -104,8 +119,8 @@ def decideExpressionCTypes(left, right, may_swap_arguments):
|
|
|
104
119
|
if left_shape in _int_types_family and right_shape in _int_types_family:
|
|
105
120
|
may_swap_arguments = may_swap_arguments in ("number", "always")
|
|
106
121
|
|
|
107
|
-
left_c_type = _pickIntFamilyType(left)
|
|
108
|
-
right_c_type = _pickIntFamilyType(right)
|
|
122
|
+
left_c_type = _pickIntFamilyType(left, context)
|
|
123
|
+
right_c_type = _pickIntFamilyType(right, context)
|
|
109
124
|
|
|
110
125
|
needs_argument_swap = (
|
|
111
126
|
may_swap_arguments
|