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
|
@@ -55,6 +55,7 @@ from nuitka.specs.HardImportSpecs import (
|
|
|
55
55
|
importlib_resources_read_binary_spec,
|
|
56
56
|
importlib_resources_read_text_spec,
|
|
57
57
|
os_listdir_spec,
|
|
58
|
+
os_lstat_spec,
|
|
58
59
|
os_path_abspath_spec,
|
|
59
60
|
os_path_basename_spec,
|
|
60
61
|
os_path_dirname_spec,
|
|
@@ -63,6 +64,7 @@ from nuitka.specs.HardImportSpecs import (
|
|
|
63
64
|
os_path_isdir_spec,
|
|
64
65
|
os_path_isfile_spec,
|
|
65
66
|
os_path_normpath_spec,
|
|
67
|
+
os_stat_spec,
|
|
66
68
|
os_uname_spec,
|
|
67
69
|
pkg_resources_get_distribution_spec,
|
|
68
70
|
pkg_resources_iter_entry_points_spec,
|
|
@@ -92,6 +94,8 @@ from .ChildrenHavingMixins import (
|
|
|
92
94
|
ChildrenHavingPackageOrRequirementResourceNameMixin,
|
|
93
95
|
ChildrenHavingPackageResourceEncodingOptionalErrorsOptionalMixin,
|
|
94
96
|
ChildrenHavingPackageResourceMixin,
|
|
97
|
+
ChildrenHavingPathOptionalDirFdOptionalFollowSymlinksOptionalMixin,
|
|
98
|
+
ChildrenHavingPathOptionalDirFdOptionalMixin,
|
|
95
99
|
)
|
|
96
100
|
from .ExpressionBases import ExpressionBase
|
|
97
101
|
from .ExpressionShapeMixins import (
|
|
@@ -1791,6 +1795,94 @@ class ExpressionOsListdirCallBase(ChildHavingPathOptionalMixin, ExpressionBase):
|
|
|
1791
1795
|
return True
|
|
1792
1796
|
|
|
1793
1797
|
|
|
1798
|
+
class ExpressionOsLstatRef(ExpressionImportModuleNameHardExistsSpecificBase):
|
|
1799
|
+
"""Function reference os.lstat"""
|
|
1800
|
+
|
|
1801
|
+
kind = "EXPRESSION_OS_LSTAT_REF"
|
|
1802
|
+
|
|
1803
|
+
def __init__(self, source_ref):
|
|
1804
|
+
ExpressionImportModuleNameHardExistsSpecificBase.__init__(
|
|
1805
|
+
self,
|
|
1806
|
+
module_name="os",
|
|
1807
|
+
import_name="lstat",
|
|
1808
|
+
module_guaranteed=True,
|
|
1809
|
+
source_ref=source_ref,
|
|
1810
|
+
)
|
|
1811
|
+
|
|
1812
|
+
def computeExpressionCall(self, call_node, call_args, call_kw, trace_collection):
|
|
1813
|
+
# Anything may happen on call trace before this. On next pass, if
|
|
1814
|
+
# replaced, we might be better but not now.
|
|
1815
|
+
trace_collection.onExceptionRaiseExit(BaseException)
|
|
1816
|
+
|
|
1817
|
+
from .OsSysNodes import ExpressionOsLstatCall
|
|
1818
|
+
|
|
1819
|
+
result = extractBuiltinArgs(
|
|
1820
|
+
node=call_node,
|
|
1821
|
+
builtin_class=ExpressionOsLstatCall,
|
|
1822
|
+
builtin_spec=os_lstat_spec,
|
|
1823
|
+
)
|
|
1824
|
+
|
|
1825
|
+
return (
|
|
1826
|
+
result,
|
|
1827
|
+
"new_expression",
|
|
1828
|
+
"Call to 'os.lstat' recognized.",
|
|
1829
|
+
)
|
|
1830
|
+
|
|
1831
|
+
|
|
1832
|
+
hard_import_node_classes[ExpressionOsLstatRef] = os_lstat_spec
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
class ExpressionOsLstatCallBase(
|
|
1836
|
+
ChildrenHavingPathOptionalDirFdOptionalMixin, ExpressionBase
|
|
1837
|
+
):
|
|
1838
|
+
"""Base class for OsLstatCall
|
|
1839
|
+
|
|
1840
|
+
Generated boiler plate code.
|
|
1841
|
+
"""
|
|
1842
|
+
|
|
1843
|
+
named_children = (
|
|
1844
|
+
"path|optional",
|
|
1845
|
+
"dir_fd|optional",
|
|
1846
|
+
)
|
|
1847
|
+
|
|
1848
|
+
__slots__ = ("attempted",)
|
|
1849
|
+
|
|
1850
|
+
spec = os_lstat_spec
|
|
1851
|
+
|
|
1852
|
+
def __init__(self, path, dir_fd, source_ref):
|
|
1853
|
+
|
|
1854
|
+
ChildrenHavingPathOptionalDirFdOptionalMixin.__init__(
|
|
1855
|
+
self,
|
|
1856
|
+
path=path,
|
|
1857
|
+
dir_fd=dir_fd,
|
|
1858
|
+
)
|
|
1859
|
+
|
|
1860
|
+
ExpressionBase.__init__(self, source_ref)
|
|
1861
|
+
|
|
1862
|
+
self.attempted = False
|
|
1863
|
+
|
|
1864
|
+
def computeExpression(self, trace_collection):
|
|
1865
|
+
if self.attempted or not os_lstat_spec.isCompileTimeComputable(
|
|
1866
|
+
(self.subnode_path,)
|
|
1867
|
+
):
|
|
1868
|
+
trace_collection.onExceptionRaiseExit(BaseException)
|
|
1869
|
+
|
|
1870
|
+
return self, None, None
|
|
1871
|
+
|
|
1872
|
+
try:
|
|
1873
|
+
return self.replaceWithCompileTimeValue(trace_collection)
|
|
1874
|
+
finally:
|
|
1875
|
+
self.attempted = True
|
|
1876
|
+
|
|
1877
|
+
@abstractmethod
|
|
1878
|
+
def replaceWithCompileTimeValue(self, trace_collection):
|
|
1879
|
+
pass
|
|
1880
|
+
|
|
1881
|
+
@staticmethod
|
|
1882
|
+
def mayRaiseExceptionOperation():
|
|
1883
|
+
return True
|
|
1884
|
+
|
|
1885
|
+
|
|
1794
1886
|
class ExpressionOsPathAbspathRef(ExpressionImportModuleNameHardExistsSpecificBase):
|
|
1795
1887
|
"""Function reference os.path.abspath"""
|
|
1796
1888
|
|
|
@@ -2449,6 +2541,96 @@ class ExpressionOsPathNormpathCallBase(ChildHavingPathMixin, ExpressionBase):
|
|
|
2449
2541
|
return True
|
|
2450
2542
|
|
|
2451
2543
|
|
|
2544
|
+
class ExpressionOsStatRef(ExpressionImportModuleNameHardExistsSpecificBase):
|
|
2545
|
+
"""Function reference os.stat"""
|
|
2546
|
+
|
|
2547
|
+
kind = "EXPRESSION_OS_STAT_REF"
|
|
2548
|
+
|
|
2549
|
+
def __init__(self, source_ref):
|
|
2550
|
+
ExpressionImportModuleNameHardExistsSpecificBase.__init__(
|
|
2551
|
+
self,
|
|
2552
|
+
module_name="os",
|
|
2553
|
+
import_name="stat",
|
|
2554
|
+
module_guaranteed=True,
|
|
2555
|
+
source_ref=source_ref,
|
|
2556
|
+
)
|
|
2557
|
+
|
|
2558
|
+
def computeExpressionCall(self, call_node, call_args, call_kw, trace_collection):
|
|
2559
|
+
# Anything may happen on call trace before this. On next pass, if
|
|
2560
|
+
# replaced, we might be better but not now.
|
|
2561
|
+
trace_collection.onExceptionRaiseExit(BaseException)
|
|
2562
|
+
|
|
2563
|
+
from .OsSysNodes import ExpressionOsStatCall
|
|
2564
|
+
|
|
2565
|
+
result = extractBuiltinArgs(
|
|
2566
|
+
node=call_node,
|
|
2567
|
+
builtin_class=ExpressionOsStatCall,
|
|
2568
|
+
builtin_spec=os_stat_spec,
|
|
2569
|
+
)
|
|
2570
|
+
|
|
2571
|
+
return (
|
|
2572
|
+
result,
|
|
2573
|
+
"new_expression",
|
|
2574
|
+
"Call to 'os.stat' recognized.",
|
|
2575
|
+
)
|
|
2576
|
+
|
|
2577
|
+
|
|
2578
|
+
hard_import_node_classes[ExpressionOsStatRef] = os_stat_spec
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
class ExpressionOsStatCallBase(
|
|
2582
|
+
ChildrenHavingPathOptionalDirFdOptionalFollowSymlinksOptionalMixin, ExpressionBase
|
|
2583
|
+
):
|
|
2584
|
+
"""Base class for OsStatCall
|
|
2585
|
+
|
|
2586
|
+
Generated boiler plate code.
|
|
2587
|
+
"""
|
|
2588
|
+
|
|
2589
|
+
named_children = (
|
|
2590
|
+
"path|optional",
|
|
2591
|
+
"dir_fd|optional",
|
|
2592
|
+
"follow_symlinks|optional",
|
|
2593
|
+
)
|
|
2594
|
+
|
|
2595
|
+
__slots__ = ("attempted",)
|
|
2596
|
+
|
|
2597
|
+
spec = os_stat_spec
|
|
2598
|
+
|
|
2599
|
+
def __init__(self, path, dir_fd, follow_symlinks, source_ref):
|
|
2600
|
+
|
|
2601
|
+
ChildrenHavingPathOptionalDirFdOptionalFollowSymlinksOptionalMixin.__init__(
|
|
2602
|
+
self,
|
|
2603
|
+
path=path,
|
|
2604
|
+
dir_fd=dir_fd,
|
|
2605
|
+
follow_symlinks=follow_symlinks,
|
|
2606
|
+
)
|
|
2607
|
+
|
|
2608
|
+
ExpressionBase.__init__(self, source_ref)
|
|
2609
|
+
|
|
2610
|
+
self.attempted = False
|
|
2611
|
+
|
|
2612
|
+
def computeExpression(self, trace_collection):
|
|
2613
|
+
if self.attempted or not os_stat_spec.isCompileTimeComputable(
|
|
2614
|
+
(self.subnode_path,)
|
|
2615
|
+
):
|
|
2616
|
+
trace_collection.onExceptionRaiseExit(BaseException)
|
|
2617
|
+
|
|
2618
|
+
return self, None, None
|
|
2619
|
+
|
|
2620
|
+
try:
|
|
2621
|
+
return self.replaceWithCompileTimeValue(trace_collection)
|
|
2622
|
+
finally:
|
|
2623
|
+
self.attempted = True
|
|
2624
|
+
|
|
2625
|
+
@abstractmethod
|
|
2626
|
+
def replaceWithCompileTimeValue(self, trace_collection):
|
|
2627
|
+
pass
|
|
2628
|
+
|
|
2629
|
+
@staticmethod
|
|
2630
|
+
def mayRaiseExceptionOperation():
|
|
2631
|
+
return True
|
|
2632
|
+
|
|
2633
|
+
|
|
2452
2634
|
class ExpressionOsUnameRef(ExpressionImportModuleNameHardExistsSpecificBase):
|
|
2453
2635
|
"""Function reference os.uname"""
|
|
2454
2636
|
|
nuitka/nodes/ImportNodes.py
CHANGED
|
@@ -454,9 +454,9 @@ class ExpressionImportModuleHard(
|
|
|
454
454
|
|
|
455
455
|
@staticmethod
|
|
456
456
|
def _getImportNameErrorString(module, module_name, name):
|
|
457
|
-
if python_version <
|
|
457
|
+
if python_version < 0x300:
|
|
458
458
|
return "cannot import name %s" % name
|
|
459
|
-
|
|
459
|
+
elif python_version < 0x370:
|
|
460
460
|
return "cannot import name %r" % name
|
|
461
461
|
elif isStandaloneMode():
|
|
462
462
|
return "cannot import name %r from %r" % (name, module_name)
|
nuitka/nodes/NodeBases.py
CHANGED
|
@@ -185,6 +185,19 @@ class NodeBase(NodeMetaClassBase):
|
|
|
185
185
|
|
|
186
186
|
return parent
|
|
187
187
|
|
|
188
|
+
def getContainingLoopNode(self):
|
|
189
|
+
"""Return the parent that is module."""
|
|
190
|
+
parent = self.parent
|
|
191
|
+
|
|
192
|
+
while parent is not None and not parent.isExpressionFunctionBodyBase():
|
|
193
|
+
|
|
194
|
+
if parent.isStatementLoop():
|
|
195
|
+
return parent
|
|
196
|
+
|
|
197
|
+
parent = parent.getParent()
|
|
198
|
+
|
|
199
|
+
return parent
|
|
200
|
+
|
|
188
201
|
def isParentVariableProvider(self):
|
|
189
202
|
# Check if it's a closure giver, in which cases it can provide variables,
|
|
190
203
|
return isinstance(self, ClosureGiverNodeMixin)
|
|
@@ -314,6 +327,10 @@ class NodeBase(NodeMetaClassBase):
|
|
|
314
327
|
def isStatementsFrame():
|
|
315
328
|
return False
|
|
316
329
|
|
|
330
|
+
@staticmethod
|
|
331
|
+
def isStatementsSequenceButNotFrame():
|
|
332
|
+
return False
|
|
333
|
+
|
|
317
334
|
@staticmethod
|
|
318
335
|
def isCompiledPythonModule():
|
|
319
336
|
# For overload by module nodes
|
|
@@ -405,6 +422,11 @@ class NodeBase(NodeMetaClassBase):
|
|
|
405
422
|
def getVisitableNodes():
|
|
406
423
|
return ()
|
|
407
424
|
|
|
425
|
+
def checkChildren(self):
|
|
426
|
+
for c in self.getVisitableNodes():
|
|
427
|
+
assert c.parent is self, (c, "parent", self, "!=", c.parent)
|
|
428
|
+
c.checkChildren()
|
|
429
|
+
|
|
408
430
|
@staticmethod
|
|
409
431
|
def getVisitableNodesNamed():
|
|
410
432
|
"""Named children dictionary.
|
|
@@ -707,6 +729,11 @@ class StatementBase(NodeBase):
|
|
|
707
729
|
expression = trace_collection.onExpression(expression)
|
|
708
730
|
|
|
709
731
|
if expression.willRaiseAnyException():
|
|
732
|
+
# They probably have changed.
|
|
733
|
+
expressions = self.getVisitableNodes()
|
|
734
|
+
|
|
735
|
+
child_name = expression.getChildNameNice()
|
|
736
|
+
|
|
710
737
|
wrapped_expression = makeStatementOnlyNodesFromExpressions(
|
|
711
738
|
expressions[: count + 1]
|
|
712
739
|
)
|
|
@@ -717,7 +744,7 @@ class StatementBase(NodeBase):
|
|
|
717
744
|
wrapped_expression,
|
|
718
745
|
"new_raise",
|
|
719
746
|
lambda: "For %s the child expression '%s' will raise."
|
|
720
|
-
% (self.getStatementNiceName(),
|
|
747
|
+
% (self.getStatementNiceName(), child_name),
|
|
721
748
|
)
|
|
722
749
|
|
|
723
750
|
return self, None, None
|
|
@@ -31,8 +31,10 @@ def makeConstantReplacementNode(constant, node, user_provided):
|
|
|
31
31
|
def makeRaiseExceptionReplacementExpression(
|
|
32
32
|
expression, exception_type, exception_value, no_warning=False
|
|
33
33
|
):
|
|
34
|
-
from .
|
|
35
|
-
|
|
34
|
+
from .ExceptionNodes import (
|
|
35
|
+
ExpressionRaiseException,
|
|
36
|
+
makeBuiltinMakeExceptionNode,
|
|
37
|
+
)
|
|
36
38
|
|
|
37
39
|
source_ref = expression.source_ref
|
|
38
40
|
|
|
@@ -48,12 +50,22 @@ def makeRaiseExceptionReplacementExpression(
|
|
|
48
50
|
)
|
|
49
51
|
)
|
|
50
52
|
|
|
53
|
+
if type(exception_value) is not tuple:
|
|
54
|
+
exception_value = (exception_value,)
|
|
55
|
+
|
|
56
|
+
args = tuple(
|
|
57
|
+
makeConstantReplacementNode(
|
|
58
|
+
constant=element, node=expression, user_provided=False
|
|
59
|
+
)
|
|
60
|
+
for element in exception_value
|
|
61
|
+
)
|
|
62
|
+
|
|
51
63
|
result = ExpressionRaiseException(
|
|
52
|
-
exception_type=
|
|
53
|
-
exception_name=exception_type,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
exception_type=makeBuiltinMakeExceptionNode(
|
|
65
|
+
exception_name=exception_type,
|
|
66
|
+
args=args,
|
|
67
|
+
for_raise=False,
|
|
68
|
+
source_ref=source_ref,
|
|
57
69
|
),
|
|
58
70
|
source_ref=source_ref,
|
|
59
71
|
)
|
|
@@ -61,15 +73,19 @@ def makeRaiseExceptionReplacementExpression(
|
|
|
61
73
|
return result
|
|
62
74
|
|
|
63
75
|
|
|
64
|
-
def makeRaiseExceptionReplacementStatement(
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
def makeRaiseExceptionReplacementStatement(
|
|
77
|
+
statement, exception_type, exception_value, no_warning=False
|
|
78
|
+
):
|
|
79
|
+
from .ExceptionNodes import (
|
|
80
|
+
StatementRaiseException,
|
|
81
|
+
makeBuiltinMakeExceptionNode,
|
|
82
|
+
)
|
|
67
83
|
|
|
68
84
|
source_ref = statement.getSourceReference()
|
|
69
85
|
|
|
70
86
|
assert type(exception_type) is str
|
|
71
87
|
|
|
72
|
-
if Options.shallWarnImplicitRaises():
|
|
88
|
+
if not no_warning and Options.shallWarnImplicitRaises():
|
|
73
89
|
unusual_logger.warning(
|
|
74
90
|
'%s: Will always raise exception: "%s(%s)"'
|
|
75
91
|
% (
|
|
@@ -79,13 +95,18 @@ def makeRaiseExceptionReplacementStatement(statement, exception_type, exception_
|
|
|
79
95
|
)
|
|
80
96
|
)
|
|
81
97
|
|
|
82
|
-
result =
|
|
83
|
-
exception_type=
|
|
84
|
-
exception_name=exception_type,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
result = StatementRaiseException(
|
|
99
|
+
exception_type=makeBuiltinMakeExceptionNode(
|
|
100
|
+
exception_name=exception_type,
|
|
101
|
+
args=(
|
|
102
|
+
makeConstantReplacementNode(
|
|
103
|
+
constant=exception_value, node=statement, user_provided=False
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
for_raise=False,
|
|
107
|
+
source_ref=source_ref,
|
|
88
108
|
),
|
|
109
|
+
exception_value=None,
|
|
89
110
|
exception_cause=None,
|
|
90
111
|
exception_trace=None,
|
|
91
112
|
source_ref=source_ref,
|
|
@@ -97,41 +118,35 @@ def makeRaiseExceptionReplacementStatement(statement, exception_type, exception_
|
|
|
97
118
|
def makeRaiseExceptionReplacementExpressionFromInstance(expression, exception):
|
|
98
119
|
assert isinstance(exception, Exception)
|
|
99
120
|
|
|
100
|
-
args = exception.args
|
|
101
|
-
if type(args) is tuple and len(args) == 1:
|
|
102
|
-
value = args[0]
|
|
103
|
-
else:
|
|
104
|
-
assert type(args) is tuple
|
|
105
|
-
value = args
|
|
106
|
-
|
|
107
121
|
return makeRaiseExceptionReplacementExpression(
|
|
108
122
|
expression=expression,
|
|
109
123
|
exception_type=exception.__class__.__name__,
|
|
110
|
-
exception_value=
|
|
124
|
+
exception_value=exception.args,
|
|
111
125
|
)
|
|
112
126
|
|
|
113
127
|
|
|
114
128
|
def makeRaiseExceptionStatementFromInstance(exception, source_ref):
|
|
115
129
|
assert isinstance(exception, Exception)
|
|
116
130
|
|
|
117
|
-
args = exception.args
|
|
118
|
-
if type(args) is tuple and len(args) == 1:
|
|
119
|
-
value = args[0]
|
|
120
|
-
else:
|
|
121
|
-
assert type(args) is tuple
|
|
122
|
-
value = args
|
|
123
|
-
|
|
124
|
-
from .BuiltinRefNodes import ExpressionBuiltinExceptionRef
|
|
125
131
|
from .ConstantRefNodes import makeConstantRefNode
|
|
126
|
-
from .ExceptionNodes import
|
|
132
|
+
from .ExceptionNodes import (
|
|
133
|
+
StatementRaiseException,
|
|
134
|
+
makeBuiltinMakeExceptionNode,
|
|
135
|
+
)
|
|
127
136
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
args_value = tuple(
|
|
138
|
+
makeConstantRefNode(constant=arg, source_ref=source_ref, user_provided=False)
|
|
139
|
+
for arg in exception.args
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
return StatementRaiseException(
|
|
143
|
+
exception_type=makeBuiltinMakeExceptionNode(
|
|
144
|
+
exception_name=exception.__class__.__name__,
|
|
145
|
+
args=args_value,
|
|
146
|
+
for_raise=False,
|
|
147
|
+
source_ref=source_ref,
|
|
134
148
|
),
|
|
149
|
+
exception_value=None,
|
|
135
150
|
exception_cause=None,
|
|
136
151
|
exception_trace=None,
|
|
137
152
|
source_ref=source_ref,
|
|
@@ -141,10 +156,12 @@ def makeRaiseExceptionStatementFromInstance(exception, source_ref):
|
|
|
141
156
|
def makeRaiseExceptionExpressionFromTemplate(
|
|
142
157
|
exception_type, template, template_args, source_ref
|
|
143
158
|
):
|
|
144
|
-
from .BuiltinRefNodes import ExpressionBuiltinExceptionRef
|
|
145
159
|
from .ConstantRefNodes import makeConstantRefNode
|
|
146
160
|
from .ContainerMakingNodes import makeExpressionMakeTupleOrConstant
|
|
147
|
-
from .ExceptionNodes import
|
|
161
|
+
from .ExceptionNodes import (
|
|
162
|
+
ExpressionRaiseException,
|
|
163
|
+
makeBuiltinMakeExceptionNode,
|
|
164
|
+
)
|
|
148
165
|
from .OperatorNodes import makeBinaryOperationNode
|
|
149
166
|
|
|
150
167
|
if type(template_args) is tuple:
|
|
@@ -153,15 +170,19 @@ def makeRaiseExceptionExpressionFromTemplate(
|
|
|
153
170
|
)
|
|
154
171
|
|
|
155
172
|
return ExpressionRaiseException(
|
|
156
|
-
exception_type=
|
|
157
|
-
exception_name=exception_type,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
exception_type=makeBuiltinMakeExceptionNode(
|
|
174
|
+
exception_name=exception_type,
|
|
175
|
+
args=(
|
|
176
|
+
makeBinaryOperationNode(
|
|
177
|
+
operator="Mod",
|
|
178
|
+
left=makeConstantRefNode(
|
|
179
|
+
constant=template, source_ref=source_ref, user_provided=True
|
|
180
|
+
),
|
|
181
|
+
right=template_args,
|
|
182
|
+
source_ref=source_ref,
|
|
183
|
+
),
|
|
163
184
|
),
|
|
164
|
-
|
|
185
|
+
for_raise=False,
|
|
165
186
|
source_ref=source_ref,
|
|
166
187
|
),
|
|
167
188
|
source_ref=source_ref,
|
|
@@ -7,6 +7,7 @@ Some of these come from built-ins, e.g. abs, some from syntax, and repr from bot
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from nuitka import PythonOperators
|
|
10
|
+
from nuitka.Errors import NuitkaAssumptionError
|
|
10
11
|
|
|
11
12
|
from .ChildrenHavingMixins import ChildHavingOperandMixin
|
|
12
13
|
from .ConstantRefNodes import makeConstantRefNode
|
|
@@ -15,6 +16,11 @@ from .ExpressionShapeMixins import (
|
|
|
15
16
|
ExpressionBoolShapeExactMixin,
|
|
16
17
|
ExpressionStrOrUnicodeDerivedShapeMixin,
|
|
17
18
|
)
|
|
19
|
+
from .NodeMakingHelpers import (
|
|
20
|
+
makeRaiseExceptionReplacementExpressionFromInstance,
|
|
21
|
+
wrapExpressionWithSideEffects,
|
|
22
|
+
)
|
|
23
|
+
from .shapes.StandardShapes import tshape_unknown
|
|
18
24
|
|
|
19
25
|
|
|
20
26
|
class ExpressionOperationUnaryBase(ChildHavingOperandMixin, ExpressionBase):
|
|
@@ -31,10 +37,10 @@ class ExpressionOperationUnaryBase(ChildHavingOperandMixin, ExpressionBase):
|
|
|
31
37
|
return self.operator
|
|
32
38
|
|
|
33
39
|
def computeExpression(self, trace_collection):
|
|
34
|
-
operator = self.getOperator()
|
|
35
40
|
operand = self.subnode_operand
|
|
36
41
|
|
|
37
42
|
if operand.isCompileTimeConstant():
|
|
43
|
+
operator = self.getOperator()
|
|
38
44
|
operand_value = operand.getCompileTimeConstant()
|
|
39
45
|
|
|
40
46
|
return trace_collection.getCompileTimeComputationResult(
|
|
@@ -61,6 +67,10 @@ class ExpressionOperationUnaryBase(ChildHavingOperandMixin, ExpressionBase):
|
|
|
61
67
|
def isExpressionOperationUnary():
|
|
62
68
|
return True
|
|
63
69
|
|
|
70
|
+
@staticmethod
|
|
71
|
+
def mayRaiseExceptionOperation():
|
|
72
|
+
return True
|
|
73
|
+
|
|
64
74
|
|
|
65
75
|
class ExpressionOperationUnaryRepr( # TODO: Not exact
|
|
66
76
|
ExpressionStrOrUnicodeDerivedShapeMixin, ExpressionOperationUnaryBase
|
|
@@ -104,7 +114,100 @@ class ExpressionOperationUnaryRepr( # TODO: Not exact
|
|
|
104
114
|
return self.escape_desc is None or self.escape_desc.isControlFlowEscape()
|
|
105
115
|
|
|
106
116
|
|
|
107
|
-
|
|
117
|
+
# TODO: This should merge into base class.
|
|
118
|
+
class ExpressionOperationUnaryMixin(object):
|
|
119
|
+
# Mixins are not allowed to specify slots, pylint: disable=assigning-non-slot
|
|
120
|
+
__slots__ = ()
|
|
121
|
+
|
|
122
|
+
def mayRaiseExceptionOperation(self):
|
|
123
|
+
return self.escape_desc.getExceptionExit() is not None
|
|
124
|
+
|
|
125
|
+
def mayRaiseException(self, exception_type):
|
|
126
|
+
# TODO: Match getExceptionExit() more precisely against exception type given
|
|
127
|
+
return (
|
|
128
|
+
self.escape_desc is None
|
|
129
|
+
or self.escape_desc.getExceptionExit() is not None
|
|
130
|
+
or self.subnode_operand.mayRaiseException(exception_type)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
def getTypeShape(self):
|
|
134
|
+
return self.type_shape
|
|
135
|
+
|
|
136
|
+
def createUnsupportedException(self, operand_shape):
|
|
137
|
+
typical_value = operand_shape.typical_value
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
self.simulator(typical_value)
|
|
141
|
+
except TypeError as e:
|
|
142
|
+
return e
|
|
143
|
+
except Exception as e:
|
|
144
|
+
raise NuitkaAssumptionError(
|
|
145
|
+
"Unexpected exception type doing operation simulation",
|
|
146
|
+
self.operator,
|
|
147
|
+
self.simulator,
|
|
148
|
+
operand_shape,
|
|
149
|
+
e,
|
|
150
|
+
)
|
|
151
|
+
else:
|
|
152
|
+
raise NuitkaAssumptionError(
|
|
153
|
+
"Unexpected no-exception doing operation simulation",
|
|
154
|
+
self.operator,
|
|
155
|
+
self.simulator,
|
|
156
|
+
operand_shape,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
def computeExpression(self, trace_collection):
|
|
160
|
+
operand = self.subnode_operand
|
|
161
|
+
|
|
162
|
+
if operand.isCompileTimeConstant():
|
|
163
|
+
operand_value = operand.getCompileTimeConstant()
|
|
164
|
+
operator = self.getOperator()
|
|
165
|
+
|
|
166
|
+
return trace_collection.getCompileTimeComputationResult(
|
|
167
|
+
node=self,
|
|
168
|
+
computation=lambda: self.simulator(operand_value),
|
|
169
|
+
description="Operator '%s' with constant argument." % operator,
|
|
170
|
+
)
|
|
171
|
+
else:
|
|
172
|
+
operand_shape = operand.getTypeShape()
|
|
173
|
+
|
|
174
|
+
self.type_shape, self.escape_desc = self._getOperationShape(operand_shape)
|
|
175
|
+
|
|
176
|
+
if self.escape_desc.isUnsupported():
|
|
177
|
+
result = wrapExpressionWithSideEffects(
|
|
178
|
+
new_node=makeRaiseExceptionReplacementExpressionFromInstance(
|
|
179
|
+
expression=self,
|
|
180
|
+
exception=self.createUnsupportedException(operand_shape),
|
|
181
|
+
),
|
|
182
|
+
old_node=self,
|
|
183
|
+
side_effects=(operand,),
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
result,
|
|
188
|
+
"new_raise",
|
|
189
|
+
"Replaced operator '%s' with %s arguments that cannot work."
|
|
190
|
+
% (self.operator, operand_shape),
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
exception_raise_exit = self.escape_desc.getExceptionExit()
|
|
194
|
+
if exception_raise_exit is not None:
|
|
195
|
+
trace_collection.onExceptionRaiseExit(exception_raise_exit)
|
|
196
|
+
|
|
197
|
+
if self.escape_desc.isValueEscaping():
|
|
198
|
+
# The value of these nodes escaped and could change its contents.
|
|
199
|
+
trace_collection.removeKnowledge(operand)
|
|
200
|
+
|
|
201
|
+
if self.escape_desc.isControlFlowEscape():
|
|
202
|
+
# Any code could be run, note that.
|
|
203
|
+
trace_collection.onControlFlowEscape(self)
|
|
204
|
+
|
|
205
|
+
return self, None, None
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class ExpressionOperationUnarySub(
|
|
209
|
+
ExpressionOperationUnaryMixin, ExpressionOperationUnaryBase
|
|
210
|
+
):
|
|
108
211
|
"""Python unary operator -"""
|
|
109
212
|
|
|
110
213
|
kind = "EXPRESSION_OPERATION_UNARY_SUB"
|
|
@@ -112,13 +215,25 @@ class ExpressionOperationUnarySub(ExpressionOperationUnaryBase):
|
|
|
112
215
|
operator = "USub"
|
|
113
216
|
simulator = PythonOperators.unary_operator_functions[operator]
|
|
114
217
|
|
|
218
|
+
__slots__ = ("type_shape", "escape_desc")
|
|
219
|
+
|
|
115
220
|
def __init__(self, operand, source_ref):
|
|
116
221
|
ExpressionOperationUnaryBase.__init__(
|
|
117
222
|
self, operand=operand, source_ref=source_ref
|
|
118
223
|
)
|
|
119
224
|
|
|
225
|
+
self.type_shape = tshape_unknown
|
|
120
226
|
|
|
121
|
-
|
|
227
|
+
self.escape_desc = None
|
|
228
|
+
|
|
229
|
+
@staticmethod
|
|
230
|
+
def _getOperationShape(operand_shape):
|
|
231
|
+
return operand_shape.getOperationUnarySubShape()
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class ExpressionOperationUnaryAdd(
|
|
235
|
+
ExpressionOperationUnaryMixin, ExpressionOperationUnaryBase
|
|
236
|
+
):
|
|
122
237
|
"""Python unary operator +"""
|
|
123
238
|
|
|
124
239
|
kind = "EXPRESSION_OPERATION_UNARY_ADD"
|
|
@@ -126,11 +241,21 @@ class ExpressionOperationUnaryAdd(ExpressionOperationUnaryBase):
|
|
|
126
241
|
operator = "UAdd"
|
|
127
242
|
simulator = PythonOperators.unary_operator_functions[operator]
|
|
128
243
|
|
|
244
|
+
__slots__ = ("type_shape", "escape_desc")
|
|
245
|
+
|
|
129
246
|
def __init__(self, operand, source_ref):
|
|
130
247
|
ExpressionOperationUnaryBase.__init__(
|
|
131
248
|
self, operand=operand, source_ref=source_ref
|
|
132
249
|
)
|
|
133
250
|
|
|
251
|
+
self.type_shape = tshape_unknown
|
|
252
|
+
|
|
253
|
+
self.escape_desc = None
|
|
254
|
+
|
|
255
|
+
@staticmethod
|
|
256
|
+
def _getOperationShape(operand_shape):
|
|
257
|
+
return operand_shape.getOperationUnaryAddShape()
|
|
258
|
+
|
|
134
259
|
|
|
135
260
|
class ExpressionOperationUnaryInvert(ExpressionOperationUnaryBase):
|
|
136
261
|
"""Python unary operator ~"""
|