Nuitka-winsvc 2.2.3__cp311-cp311-win_amd64.whl → 2.3__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.
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/METADATA +1 -1
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/RECORD +198 -197
- nuitka/Bytecodes.py +4 -2
- nuitka/HardImportRegistry.py +1 -0
- nuitka/MainControl.py +16 -10
- nuitka/ModuleRegistry.py +15 -0
- nuitka/OptionParsing.py +30 -8
- nuitka/Options.py +104 -44
- nuitka/PostProcessing.py +9 -8
- nuitka/PythonVersions.py +2 -1
- nuitka/Serialization.py +47 -30
- nuitka/Version.py +1 -1
- nuitka/build/Backend.scons +46 -19
- nuitka/build/CCompilerVersion.scons +3 -3
- nuitka/build/Onefile.scons +4 -4
- nuitka/build/SconsCaching.py +3 -2
- nuitka/build/SconsCompilerSettings.py +11 -5
- nuitka/build/SconsInterface.py +22 -6
- nuitka/build/SconsUtils.py +9 -1
- nuitka/build/include/nuitka/allocator.h +58 -2
- nuitka/build/include/nuitka/compiled_frame.h +48 -13
- nuitka/build/include/nuitka/compiled_function.h +4 -0
- nuitka/build/include/nuitka/constants.h +6 -0
- nuitka/build/include/nuitka/exception_groups.h +6 -6
- nuitka/build/include/nuitka/exceptions.h +3 -3
- nuitka/build/include/nuitka/freelists.h +11 -0
- nuitka/build/include/nuitka/helper/dictionaries.h +5 -4
- nuitka/build/include/nuitka/helper/lists.h +5 -5
- nuitka/build/include/nuitka/helper/lists_generated.h +12 -12
- nuitka/build/include/nuitka/helper/sequences.h +6 -0
- nuitka/build/include/nuitka/helper/slices.h +14 -8
- nuitka/build/include/nuitka/helper/subscripts.h +1 -184
- nuitka/build/include/nuitka/helper/tuples.h +42 -33
- nuitka/build/include/nuitka/importing.h +5 -0
- nuitka/build/include/nuitka/prelude.h +35 -2
- nuitka/build/include/nuitka/safe_string_ops.h +1 -0
- nuitka/build/include/nuitka/threading.h +13 -10
- nuitka/build/static_src/CompiledAsyncgenType.c +19 -8
- nuitka/build/static_src/CompiledCellType.c +1 -1
- nuitka/build/static_src/CompiledCodeHelpers.c +18 -16
- nuitka/build/static_src/CompiledCoroutineType.c +23 -19
- nuitka/build/static_src/CompiledFrameType.c +46 -34
- nuitka/build/static_src/CompiledFunctionType.c +55 -34
- nuitka/build/static_src/CompiledGeneratorType.c +21 -19
- nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +127 -130
- nuitka/build/static_src/CompiledMethodType.c +15 -17
- nuitka/build/static_src/HelpersAllocator.c +71 -0
- nuitka/build/static_src/HelpersAttributes.c +1 -1
- nuitka/build/static_src/HelpersBuiltin.c +5 -5
- nuitka/build/static_src/HelpersBytes.c +2 -2
- nuitka/build/static_src/HelpersCalling.c +3 -0
- nuitka/build/static_src/HelpersCallingGenerated.c +131 -131
- nuitka/build/static_src/HelpersComparisonEq.c +329 -329
- nuitka/build/static_src/HelpersComparisonEqUtils.c +3 -1
- nuitka/build/static_src/HelpersComparisonGe.c +322 -322
- nuitka/build/static_src/HelpersComparisonGt.c +321 -321
- nuitka/build/static_src/HelpersComparisonLe.c +322 -322
- nuitka/build/static_src/HelpersComparisonLt.c +321 -321
- nuitka/build/static_src/HelpersComparisonNe.c +329 -329
- nuitka/build/static_src/HelpersConsole.c +96 -0
- nuitka/build/static_src/HelpersConstantsBlob.c +10 -6
- nuitka/build/static_src/HelpersDeepcopy.c +10 -8
- nuitka/build/static_src/HelpersDictionaries.c +17 -11
- nuitka/build/static_src/HelpersDictionariesGenerated.c +65 -29
- nuitka/build/static_src/HelpersExceptions.c +107 -9
- nuitka/build/static_src/HelpersFilesystemPaths.c +64 -4
- nuitka/build/static_src/HelpersFloats.c +20 -14
- nuitka/build/static_src/HelpersImport.c +1 -1
- nuitka/build/static_src/HelpersJitSources.c +1 -1
- nuitka/build/static_src/HelpersLists.c +29 -19
- nuitka/build/static_src/HelpersListsGenerated.c +24 -24
- nuitka/build/static_src/HelpersMatching.c +32 -5
- nuitka/build/static_src/HelpersOperationBinaryAdd.c +90 -63
- nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +4 -4
- nuitka/build/static_src/HelpersOperationBinaryBitand.c +33 -33
- nuitka/build/static_src/HelpersOperationBinaryBitor.c +33 -33
- nuitka/build/static_src/HelpersOperationBinaryBitxor.c +33 -33
- nuitka/build/static_src/HelpersOperationBinaryDivmod.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryLshift.c +30 -30
- nuitka/build/static_src/HelpersOperationBinaryMatmult.c +7 -7
- nuitka/build/static_src/HelpersOperationBinaryMod.c +90 -90
- nuitka/build/static_src/HelpersOperationBinaryMult.c +64 -58
- nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryPow.c +27 -27
- nuitka/build/static_src/HelpersOperationBinaryRshift.c +30 -30
- nuitka/build/static_src/HelpersOperationBinarySub.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryTruediv.c +24 -24
- nuitka/build/static_src/HelpersOperationInplaceAdd.c +67 -49
- nuitka/build/static_src/HelpersOperationInplaceBitand.c +25 -25
- nuitka/build/static_src/HelpersOperationInplaceBitor.c +25 -25
- nuitka/build/static_src/HelpersOperationInplaceBitxor.c +25 -25
- nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +28 -28
- nuitka/build/static_src/HelpersOperationInplaceLshift.c +18 -18
- nuitka/build/static_src/HelpersOperationInplaceMatmult.c +10 -10
- nuitka/build/static_src/HelpersOperationInplaceMod.c +70 -70
- nuitka/build/static_src/HelpersOperationInplaceMult.c +33 -33
- nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +28 -28
- nuitka/build/static_src/HelpersOperationInplacePow.c +28 -28
- nuitka/build/static_src/HelpersOperationInplaceRshift.c +18 -18
- nuitka/build/static_src/HelpersOperationInplaceSub.c +28 -28
- nuitka/build/static_src/HelpersOperationInplaceTruediv.c +28 -28
- nuitka/build/static_src/HelpersRaising.c +10 -3
- nuitka/build/static_src/HelpersSafeStrings.c +14 -4
- nuitka/build/static_src/HelpersSlices.c +12 -5
- nuitka/build/static_src/HelpersStrings.c +1 -1
- nuitka/build/static_src/HelpersTuples.c +20 -15
- nuitka/build/static_src/InspectPatcher.c +74 -6
- nuitka/build/static_src/MainProgram.c +90 -25
- nuitka/build/static_src/MetaPathBasedLoader.c +81 -45
- nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +2 -2
- nuitka/build/static_src/OnefileBootstrap.c +16 -17
- nuitka/code_generation/CodeGeneration.py +5 -2
- nuitka/code_generation/ConstantCodes.py +2 -2
- nuitka/code_generation/DictCodes.py +2 -2
- nuitka/code_generation/GlobalConstants.py +5 -0
- nuitka/code_generation/GlobalsLocalsCodes.py +2 -2
- nuitka/code_generation/ListCodes.py +2 -2
- nuitka/code_generation/LocalsDictCodes.py +1 -1
- nuitka/code_generation/ModuleCodes.py +19 -0
- nuitka/code_generation/PackageResourceCodes.py +14 -0
- nuitka/code_generation/SliceCodes.py +3 -3
- nuitka/code_generation/SubscriptCodes.py +5 -13
- nuitka/code_generation/TupleCodes.py +1 -1
- nuitka/code_generation/c_types/CTypePyObjectPointers.py +7 -7
- nuitka/code_generation/templates/CodeTemplatesConstants.py +7 -5
- nuitka/code_generation/templates/CodeTemplatesLoader.py +2 -0
- nuitka/code_generation/templates/CodeTemplatesModules.py +78 -54
- nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +1 -1
- nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +8 -8
- nuitka/code_generation/templates_c/CodeTemplateCallsPositionalMethodDescr.c.j2 +5 -5
- nuitka/code_generation/templates_c/CodeTemplateMakeListHinted.c.j2 +2 -2
- nuitka/code_generation/templates_c/CodeTemplateMakeListSmall.c.j2 +2 -2
- nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +57 -21
- nuitka/code_generation/templates_c/HelperImportHard.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +5 -5
- nuitka/code_generation/templates_c/HelperOperationComparison.c.j2 +18 -18
- nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +11 -11
- nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +11 -11
- nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +10 -10
- nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperSlotsList.c.j2 +4 -1
- nuitka/code_generation/templates_c/HelperSlotsTuple.c.j2 +4 -1
- nuitka/finalizations/FinalizeMarkups.py +0 -18
- nuitka/freezer/DependsExe.py +9 -4
- nuitka/freezer/DllDependenciesMacOS.py +1 -1
- nuitka/freezer/DllDependenciesWin32.py +1 -1
- nuitka/freezer/ImportDetection.py +1 -0
- nuitka/freezer/IncludedDataFiles.py +13 -4
- nuitka/freezer/Onefile.py +0 -1
- nuitka/freezer/Standalone.py +3 -1
- nuitka/importing/ImportCache.py +3 -2
- nuitka/importing/Importing.py +16 -3
- nuitka/importing/StandardLibrary.py +4 -0
- nuitka/nodes/ChildrenHavingMixins.py +2 -0
- nuitka/nodes/ExpressionBasesGenerated.py +4 -0
- nuitka/nodes/HardImportNodesGenerated.py +83 -0
- nuitka/nodes/ModuleNodes.py +10 -2
- nuitka/nodes/OsSysNodes.py +16 -0
- nuitka/nodes/SubscriptNodes.py +3 -3
- nuitka/plugins/PluginBase.py +2 -0
- nuitka/plugins/standard/DataFilesPlugin.py +22 -1
- nuitka/plugins/standard/DillPlugin/DillPlugin.c +3 -3
- nuitka/plugins/standard/OptionsNannyPlugin.py +9 -41
- nuitka/plugins/standard/PkgResourcesPlugin.py +8 -2
- nuitka/plugins/standard/PySidePyQtPlugin.py +3 -0
- nuitka/plugins/standard/standard.nuitka-package.config.yml +18 -12
- nuitka/plugins/standard/stdlib2.nuitka-package.config.yml +2 -2
- nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +2 -2
- nuitka/specs/HardImportSpecs.py +3 -0
- nuitka/specs/ParameterSpecs.py +26 -15
- nuitka/tools/general/find_module/FindModuleCode.py +3 -2
- nuitka/tools/specialize/CTypeDescriptions.py +11 -9
- nuitka/tools/testing/Common.py +12 -5
- nuitka/tools/testing/SearchModes.py +5 -1
- nuitka/tools/watch/GitHub.py +1 -7
- nuitka/tree/Building.py +9 -6
- nuitka/tree/ReformulationMatchStatements.py +39 -3
- nuitka/tree/TreeHelpers.py +8 -0
- nuitka/utils/CStrings.py +7 -0
- nuitka/utils/Execution.py +10 -1
- nuitka/utils/FileOperations.py +21 -13
- nuitka/utils/Importing.py +24 -0
- nuitka/utils/ReExecute.py +7 -3
- nuitka/utils/SharedLibraries.py +17 -0
- nuitka/utils/Yaml.py +9 -1
- {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.data}/scripts/nuitka-run.bat +0 -0
- {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.data}/scripts/nuitka.bat +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/WHEEL +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/top_level.txt +0 -0
|
@@ -46,13 +46,17 @@ void FORMAT_UNBOUND_LOCAL_ERROR(PyObject **exception_type, PyObject **exception_
|
|
|
46
46
|
*exception_type = PyExc_UnboundLocalError;
|
|
47
47
|
Py_INCREF(*exception_type);
|
|
48
48
|
|
|
49
|
-
#if PYTHON_VERSION <
|
|
49
|
+
#if PYTHON_VERSION < 0x300
|
|
50
50
|
char const *message = "local variable '%s' referenced before assignment";
|
|
51
|
+
*exception_value = Nuitka_String_FromFormat(message, Nuitka_String_AsString_Unchecked(variable_name));
|
|
52
|
+
#elif PYTHON_VERSION < 0x3b0
|
|
53
|
+
char const *message = "local variable '%U' referenced before assignment";
|
|
54
|
+
*exception_value = Nuitka_String_FromFormat(message, variable_name);
|
|
51
55
|
#else
|
|
52
|
-
char const *message = "cannot access local variable '%
|
|
56
|
+
char const *message = "cannot access local variable '%U' where it is not associated with a value";
|
|
57
|
+
*exception_value = Nuitka_String_FromFormat(message, variable_name);
|
|
53
58
|
#endif
|
|
54
59
|
|
|
55
|
-
*exception_value = Nuitka_String_FromFormat(message, Nuitka_String_AsString_Unchecked(variable_name));
|
|
56
60
|
CHECK_OBJECT(*exception_value);
|
|
57
61
|
}
|
|
58
62
|
|
|
@@ -97,6 +101,95 @@ static PyObject *_Nuitka_Err_CreateException(PyThreadState *tstate, PyObject *ex
|
|
|
97
101
|
// Our replacement for PyErr_NormalizeException, that however does not attempt
|
|
98
102
|
// to deal with recursion, i.e. exception during normalization, we just avoid
|
|
99
103
|
// the API call overhead in the normal case.
|
|
104
|
+
|
|
105
|
+
#if PYTHON_VERSION >= 0x3d0
|
|
106
|
+
// TODO: Merge with old branch for enhancements.
|
|
107
|
+
void Nuitka_Err_NormalizeException(PyThreadState *tstate, PyObject **exc, PyObject **val, PyTracebackObject **tb) {
|
|
108
|
+
int recursion_depth = 0;
|
|
109
|
+
tstate->recursion_headroom++;
|
|
110
|
+
|
|
111
|
+
PyObject *type, *value;
|
|
112
|
+
PyTracebackObject *initial_tb;
|
|
113
|
+
|
|
114
|
+
restart:
|
|
115
|
+
type = *exc;
|
|
116
|
+
|
|
117
|
+
if (type == NULL) {
|
|
118
|
+
tstate->recursion_headroom--;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
value = *val;
|
|
123
|
+
|
|
124
|
+
if (!value) {
|
|
125
|
+
Py_INCREF_IMMORTAL(Py_None);
|
|
126
|
+
value = Py_None;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (PyExceptionClass_Check(type)) {
|
|
130
|
+
PyObject *instance_class = NULL;
|
|
131
|
+
|
|
132
|
+
int is_subclass = 0;
|
|
133
|
+
|
|
134
|
+
if (PyExceptionInstance_Check(value)) {
|
|
135
|
+
instance_class = PyExceptionInstance_Class(value);
|
|
136
|
+
|
|
137
|
+
is_subclass = PyObject_IsSubclass(instance_class, type);
|
|
138
|
+
if (is_subclass < 0) {
|
|
139
|
+
goto error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!is_subclass) {
|
|
144
|
+
PyObject *fixed_value = _Nuitka_Err_CreateException(tstate, type, value);
|
|
145
|
+
|
|
146
|
+
if (fixed_value == NULL) {
|
|
147
|
+
goto error;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Py_SETREF(value, fixed_value);
|
|
151
|
+
} else if (instance_class != type) {
|
|
152
|
+
Py_SETREF(type, Py_NewRef(instance_class));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
*exc = type;
|
|
156
|
+
*val = value;
|
|
157
|
+
tstate->recursion_headroom--;
|
|
158
|
+
return;
|
|
159
|
+
|
|
160
|
+
error:
|
|
161
|
+
Py_DECREF(type);
|
|
162
|
+
Py_DECREF(value);
|
|
163
|
+
recursion_depth++;
|
|
164
|
+
if (recursion_depth == 32) {
|
|
165
|
+
_PyErr_SetString(tstate, PyExc_RecursionError,
|
|
166
|
+
"maximum recursion depth exceeded "
|
|
167
|
+
"while normalizing an exception");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
initial_tb = *tb;
|
|
171
|
+
|
|
172
|
+
FETCH_ERROR_OCCURRED(tstate, exc, val, tb);
|
|
173
|
+
|
|
174
|
+
assert(*exc != NULL);
|
|
175
|
+
if (initial_tb != NULL) {
|
|
176
|
+
if (*tb == NULL)
|
|
177
|
+
*tb = initial_tb;
|
|
178
|
+
else
|
|
179
|
+
Py_DECREF(initial_tb);
|
|
180
|
+
}
|
|
181
|
+
if (recursion_depth >= 32 + 2) {
|
|
182
|
+
if (PyErr_GivenExceptionMatches(*exc, PyExc_MemoryError)) {
|
|
183
|
+
Py_FatalError("Cannot recover from MemoryErrors "
|
|
184
|
+
"while normalizing exceptions.");
|
|
185
|
+
} else {
|
|
186
|
+
Py_FatalError("Cannot recover from the recursive normalization "
|
|
187
|
+
"of an exception.");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
goto restart;
|
|
191
|
+
}
|
|
192
|
+
#else
|
|
100
193
|
void Nuitka_Err_NormalizeException(PyThreadState *tstate, PyObject **exc, PyObject **val, PyTracebackObject **tb) {
|
|
101
194
|
PyObject *type = *exc;
|
|
102
195
|
|
|
@@ -107,11 +200,8 @@ void Nuitka_Err_NormalizeException(PyThreadState *tstate, PyObject **exc, PyObje
|
|
|
107
200
|
|
|
108
201
|
// Allow setting the value to NULL for time savings with quick type only errors
|
|
109
202
|
if (value == NULL) {
|
|
110
|
-
// TODO: For Python3.12, these kinds of assignments from immortal objects
|
|
111
|
-
// should be specialized, might need to check Python source for how they
|
|
112
|
-
// do that.
|
|
113
203
|
value = Py_None;
|
|
114
|
-
|
|
204
|
+
Py_INCREF_IMMORTAL(value);
|
|
115
205
|
}
|
|
116
206
|
|
|
117
207
|
// Normalize the exception from class to instance
|
|
@@ -182,11 +272,16 @@ error:
|
|
|
182
272
|
#endif
|
|
183
273
|
}
|
|
184
274
|
|
|
275
|
+
#endif
|
|
276
|
+
|
|
185
277
|
// Raise NameError for a given variable name.
|
|
186
278
|
void SET_CURRENT_EXCEPTION_NAME_ERROR(PyThreadState *tstate, PyObject *variable_name) {
|
|
279
|
+
#if PYTHON_VERSION >= 0x300
|
|
280
|
+
PyObject *exception_value_str = Nuitka_String_FromFormat("name '%U' is not defined", variable_name);
|
|
281
|
+
#else
|
|
187
282
|
PyObject *exception_value_str =
|
|
188
283
|
Nuitka_String_FromFormat("name '%s' is not defined", Nuitka_String_AsString_Unchecked(variable_name));
|
|
189
|
-
|
|
284
|
+
#endif
|
|
190
285
|
PyObject *exception_value = MAKE_EXCEPTION_FROM_TYPE_ARG0(tstate, PyExc_NameError, exception_value_str);
|
|
191
286
|
Py_DECREF(exception_value_str);
|
|
192
287
|
|
|
@@ -200,9 +295,12 @@ void SET_CURRENT_EXCEPTION_NAME_ERROR(PyThreadState *tstate, PyObject *variable_
|
|
|
200
295
|
// Raise NameError with "global" for a given variable name.
|
|
201
296
|
#if PYTHON_VERSION < 0x340
|
|
202
297
|
void SET_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR(PyThreadState *tstate, PyObject *variable_name) {
|
|
298
|
+
#if PYTHON_VERSION >= 0x300
|
|
299
|
+
PyObject *exception_value_str = Nuitka_String_FromFormat("global name '%U' is not defined", variable_name);
|
|
300
|
+
#else
|
|
203
301
|
PyObject *exception_value_str =
|
|
204
302
|
Nuitka_String_FromFormat("global name '%s' is not defined", Nuitka_String_AsString_Unchecked(variable_name));
|
|
205
|
-
|
|
303
|
+
#endif
|
|
206
304
|
PyObject *exception_value = MAKE_EXCEPTION_FROM_TYPE_ARG0(tstate, PyExc_NameError, exception_value_str);
|
|
207
305
|
Py_DECREF(exception_value_str);
|
|
208
306
|
|
|
@@ -34,6 +34,62 @@
|
|
|
34
34
|
#include "nuitka/filesystem_paths.h"
|
|
35
35
|
#include "nuitka/safe_string_ops.h"
|
|
36
36
|
|
|
37
|
+
#if defined(__OpenBSD__)
|
|
38
|
+
void _getBinaryPath2(char *epath) {
|
|
39
|
+
int mib[4];
|
|
40
|
+
mib[0] = CTL_KERN;
|
|
41
|
+
mib[1] = KERN_PROC_ARGS;
|
|
42
|
+
mib[2] = getpid();
|
|
43
|
+
mib[3] = KERN_PROC_ARGV;
|
|
44
|
+
|
|
45
|
+
size_t len;
|
|
46
|
+
|
|
47
|
+
if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0) {
|
|
48
|
+
abort();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
char **argv = argv = malloc(len);
|
|
52
|
+
if (argv == NULL) {
|
|
53
|
+
abort();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (sysctl(mib, 4, argv, &len, NULL, 0) < 0) {
|
|
57
|
+
abort();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const char *comm = argv[0];
|
|
61
|
+
|
|
62
|
+
if (*comm == '/' || *comm == '.') {
|
|
63
|
+
if (realpath(comm, epath) == NULL) {
|
|
64
|
+
abort();
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
char *sp;
|
|
68
|
+
char *xpath = strdup(getenv("PATH"));
|
|
69
|
+
char *path = strtok_r(xpath, ":", &sp);
|
|
70
|
+
struct stat st;
|
|
71
|
+
|
|
72
|
+
if (xpath == NULL) {
|
|
73
|
+
abort();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
while (path) {
|
|
77
|
+
snprintf(epath, PATH_MAX, "%s/%s", path, comm);
|
|
78
|
+
|
|
79
|
+
if (!stat(epath, &st) && (st.st_mode & S_IXUSR)) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
path = strtok_r(NULL, ":", &sp);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
free(xpath);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
free(argv);
|
|
90
|
+
}
|
|
91
|
+
#endif
|
|
92
|
+
|
|
37
93
|
filename_char_t *getBinaryPath(void) {
|
|
38
94
|
static filename_char_t binary_filename[MAXPATHLEN];
|
|
39
95
|
|
|
@@ -49,7 +105,9 @@ filename_char_t *getBinaryPath(void) {
|
|
|
49
105
|
if (res != 0) {
|
|
50
106
|
abort();
|
|
51
107
|
}
|
|
52
|
-
#elif defined(
|
|
108
|
+
#elif defined(__OpenBSD__)
|
|
109
|
+
_getBinaryPath2(binary_filename);
|
|
110
|
+
#elif defined(__FreeBSD__)
|
|
53
111
|
/* Not all of FreeBSD has /proc file system, so use the appropriate
|
|
54
112
|
* "sysctl" instead.
|
|
55
113
|
*/
|
|
@@ -167,7 +225,7 @@ int64_t getFileSize(FILE_HANDLE file_handle) {
|
|
|
167
225
|
#if defined(__APPLE__)
|
|
168
226
|
#include <copyfile.h>
|
|
169
227
|
#else
|
|
170
|
-
#if defined(__MSYS__) || defined(__HAIKU__)
|
|
228
|
+
#if defined(__MSYS__) || defined(__HAIKU__) || defined(__OpenBSD__)
|
|
171
229
|
static bool sendfile(int output_file, int input_file, off_t *bytesCopied, size_t count) {
|
|
172
230
|
char buffer[32768];
|
|
173
231
|
|
|
@@ -617,8 +675,10 @@ char const *getBinaryFilenameHostEncoded(bool resolve_symlinks) {
|
|
|
617
675
|
|
|
618
676
|
// Resolve any symlinks we were invoked via
|
|
619
677
|
resolveFileSymbolicLink(binary_filename_target, binary_filename_target, buffer_size, resolve_symlinks);
|
|
620
|
-
|
|
621
|
-
|
|
678
|
+
#elif defined(__OpenBSD__)
|
|
679
|
+
_getBinaryPath2(binary_filename_target);
|
|
680
|
+
resolveFileSymbolicLink(binary_filename_target, binary_filename_target, buffer_size, resolve_symlinks);
|
|
681
|
+
#elif defined(__FreeBSD__)
|
|
622
682
|
/* Not all of FreeBSD has /proc file system, so use the appropriate
|
|
623
683
|
* "sysctl" instead.
|
|
624
684
|
*/
|
|
@@ -35,34 +35,40 @@ PyObject *TO_FLOAT(PyObject *value) {
|
|
|
35
35
|
|
|
36
36
|
#if NUITKA_FLOAT_HAS_FREELIST
|
|
37
37
|
|
|
38
|
-
static
|
|
39
|
-
|
|
40
|
-
return &interp->float_state;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static PyFloatObject *_Nuitka_AllocatePyFloatObject(void) {
|
|
44
|
-
struct _Py_float_state *state = _Nuitka_Py_get_float_state();
|
|
38
|
+
static PyFloatObject *_Nuitka_AllocatePyFloatObject(PyThreadState *tstate) {
|
|
39
|
+
// This is the CPython name, spell-checker: ignore numfree
|
|
45
40
|
|
|
46
|
-
|
|
41
|
+
#if PYTHON_VERSION < 0x3d0
|
|
42
|
+
struct _Py_float_state *state = &tstate->interp->float_state;
|
|
43
|
+
PyFloatObject **free_list = &state->free_list;
|
|
44
|
+
int *numfree = &state->numfree;
|
|
45
|
+
#else
|
|
46
|
+
struct _Py_object_freelists *freelists = _Nuitka_object_freelists_GET(tstate);
|
|
47
|
+
struct _Py_float_freelist *state = &freelists->floats;
|
|
48
|
+
PyFloatObject **free_list = &state->items;
|
|
49
|
+
int *numfree = &state->numfree;
|
|
50
|
+
#endif
|
|
51
|
+
PyFloatObject *result_float = *free_list;
|
|
47
52
|
|
|
48
53
|
if (result_float) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Py_SET_TYPE(result_float, &PyFloat_Type);
|
|
54
|
+
(*numfree) -= 1;
|
|
55
|
+
*free_list = (PyFloatObject *)Py_TYPE(result_float);
|
|
53
56
|
} else {
|
|
54
|
-
result_float = (PyFloatObject *)
|
|
57
|
+
result_float = (PyFloatObject *)NuitkaObject_Malloc(sizeof(PyFloatObject));
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
Py_SET_TYPE(result_float, &PyFloat_Type);
|
|
58
61
|
Nuitka_Py_NewReference((PyObject *)result_float);
|
|
62
|
+
|
|
59
63
|
assert(result_float != NULL);
|
|
60
64
|
|
|
61
65
|
return result_float;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
PyObject *MAKE_FLOAT_FROM_DOUBLE(double value) {
|
|
65
|
-
|
|
69
|
+
PyThreadState *tstate = PyThreadState_GET();
|
|
70
|
+
|
|
71
|
+
PyFloatObject *result = _Nuitka_AllocatePyFloatObject(tstate);
|
|
66
72
|
|
|
67
73
|
PyFloat_SET_DOUBLE(result, value);
|
|
68
74
|
return (PyObject *)result;
|
|
@@ -421,7 +421,7 @@ PyObject *IMPORT_NAME_OR_MODULE(PyThreadState *tstate, PyObject *module, PyObjec
|
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
if (level_int > 0) {
|
|
424
|
-
PyObject *fromlist = MAKE_TUPLE1(import_name);
|
|
424
|
+
PyObject *fromlist = MAKE_TUPLE1(tstate, import_name);
|
|
425
425
|
|
|
426
426
|
result = IMPORT_MODULE5(tstate, const_str_empty, globals, globals, fromlist, level);
|
|
427
427
|
|
|
@@ -19,7 +19,7 @@ void SET_UNCOMPILED_FUNCTION_SOURCE_DICT(PyObject *name, PyObject *source) {
|
|
|
19
19
|
|
|
20
20
|
DROP_ERROR_OCCURRED(tstate);
|
|
21
21
|
|
|
22
|
-
uncompiled_function_sources_dict = MAKE_DICT_EMPTY();
|
|
22
|
+
uncompiled_function_sources_dict = MAKE_DICT_EMPTY(tstate);
|
|
23
23
|
|
|
24
24
|
PyObject_SetAttrString((PyObject *)builtin_module, uncompiled_sources_dict_attribute_name,
|
|
25
25
|
uncompiled_function_sources_dict);
|
|
@@ -15,22 +15,30 @@
|
|
|
15
15
|
static PyObject *Nuitka_LongFromCLong(long ival);
|
|
16
16
|
|
|
17
17
|
#if NUITKA_LIST_HAS_FREELIST
|
|
18
|
-
static struct _Py_list_state *_Nuitka_Py_get_list_state(void) {
|
|
19
|
-
PyInterpreterState *interp = _PyInterpreterState_GET();
|
|
20
|
-
return &interp->list;
|
|
21
|
-
}
|
|
22
18
|
|
|
23
|
-
PyObject *MAKE_LIST_EMPTY(Py_ssize_t size) {
|
|
19
|
+
PyObject *MAKE_LIST_EMPTY(PyThreadState *tstate, Py_ssize_t size) {
|
|
24
20
|
assert(size >= 0);
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
#if _NUITKA_EXPERIMENTAL_DISABLE_LIST_OPT
|
|
23
|
+
return PyList_New(size);
|
|
24
|
+
#else
|
|
25
|
+
// This is the CPython name, spell-checker: ignore numfree
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
#if PYTHON_VERSION < 0x3d0
|
|
28
|
+
PyListObject **items = tstate->interp->list.free_list;
|
|
29
|
+
int *numfree = &tstate->interp->list.numfree;
|
|
30
|
+
#else
|
|
31
|
+
struct _Py_object_freelists *freelists = _Nuitka_object_freelists_GET(tstate);
|
|
32
|
+
struct _Py_list_freelist *state = &freelists->lists;
|
|
33
|
+
PyListObject **items = state->items;
|
|
34
|
+
int *numfree = &state->numfree;
|
|
35
|
+
#endif
|
|
36
|
+
assert(*numfree >= 0);
|
|
37
|
+
PyListObject *result_list;
|
|
30
38
|
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
result_list =
|
|
39
|
+
if (*numfree) {
|
|
40
|
+
(*numfree) -= 1;
|
|
41
|
+
result_list = items[*numfree];
|
|
34
42
|
|
|
35
43
|
Nuitka_Py_NewReference((PyObject *)result_list);
|
|
36
44
|
} else {
|
|
@@ -39,7 +47,7 @@ PyObject *MAKE_LIST_EMPTY(Py_ssize_t size) {
|
|
|
39
47
|
|
|
40
48
|
// Elements are allocated separately.
|
|
41
49
|
if (size > 0) {
|
|
42
|
-
result_list->ob_item = (PyObject **)
|
|
50
|
+
result_list->ob_item = (PyObject **)NuitkaMem_Calloc(size, sizeof(PyObject *));
|
|
43
51
|
|
|
44
52
|
if (unlikely(result_list->ob_item == NULL)) {
|
|
45
53
|
Py_DECREF(result_list);
|
|
@@ -55,15 +63,16 @@ PyObject *MAKE_LIST_EMPTY(Py_ssize_t size) {
|
|
|
55
63
|
Nuitka_GC_Track(result_list);
|
|
56
64
|
|
|
57
65
|
return (PyObject *)result_list;
|
|
66
|
+
#endif
|
|
58
67
|
}
|
|
59
68
|
#endif
|
|
60
69
|
|
|
61
|
-
PyObject *LIST_COPY(PyObject *list) {
|
|
70
|
+
PyObject *LIST_COPY(PyThreadState *tstate, PyObject *list) {
|
|
62
71
|
CHECK_OBJECT(list);
|
|
63
72
|
assert(PyList_CheckExact(list));
|
|
64
73
|
|
|
65
74
|
Py_ssize_t size = PyList_GET_SIZE(list);
|
|
66
|
-
PyObject *result = MAKE_LIST_EMPTY(size);
|
|
75
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, size);
|
|
67
76
|
|
|
68
77
|
if (unlikely(result == NULL)) {
|
|
69
78
|
return NULL;
|
|
@@ -378,7 +387,8 @@ bool LIST_REMOVE(PyObject *target, PyObject *item) {
|
|
|
378
387
|
|
|
379
388
|
CHECK_OBJECT(item);
|
|
380
389
|
|
|
381
|
-
#if _NUITKA_EXPERIMENTAL_DISABLE_LIST_OPT
|
|
390
|
+
#if _NUITKA_EXPERIMENTAL_DISABLE_LIST_OPT && 0
|
|
391
|
+
// TODO: This is not exposed, would need to delete as slice instead.
|
|
382
392
|
int res = PyList_Remove(target, item);
|
|
383
393
|
return res == 0;
|
|
384
394
|
#else
|
|
@@ -519,7 +529,7 @@ static PyObject *_LIST_INDEX_COMMON(PyThreadState *tstate, PyListObject *list, P
|
|
|
519
529
|
|
|
520
530
|
#if PYTHON_VERSION < 0x300
|
|
521
531
|
PyObject *err_format = PyString_FromString("%r is not in list");
|
|
522
|
-
PyObject *format_tuple = MAKE_TUPLE1_0(item);
|
|
532
|
+
PyObject *format_tuple = MAKE_TUPLE1_0(tstate, item);
|
|
523
533
|
PyObject *err_string = PyString_Format(err_format, format_tuple);
|
|
524
534
|
Py_DECREF(format_tuple);
|
|
525
535
|
|
|
@@ -716,7 +726,7 @@ void LIST_REVERSE(PyObject *list) {
|
|
|
716
726
|
}
|
|
717
727
|
}
|
|
718
728
|
|
|
719
|
-
#if PYTHON_VERSION >= 0x340
|
|
729
|
+
#if PYTHON_VERSION >= 0x340 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_LIST_OPT)
|
|
720
730
|
static bool allocateListItems(PyListObject *list, Py_ssize_t size) {
|
|
721
731
|
PyObject **items = PyMem_New(PyObject *, size);
|
|
722
732
|
|
|
@@ -735,7 +745,7 @@ static bool allocateListItems(PyListObject *list, Py_ssize_t size) {
|
|
|
735
745
|
PyObject *MAKE_LIST(PyThreadState *tstate, PyObject *iterable) {
|
|
736
746
|
// Can leave the size hinting to later functions, because the list is allocated empty without
|
|
737
747
|
// items, and when then extending, etc. length hints can be used.
|
|
738
|
-
PyObject *list = MAKE_LIST_EMPTY(0);
|
|
748
|
+
PyObject *list = MAKE_LIST_EMPTY(tstate, 0);
|
|
739
749
|
|
|
740
750
|
#if _NUITKA_EXPERIMENTAL_DISABLE_LIST_OPT
|
|
741
751
|
PyObject *result = _PyList_Extend((PyListObject *)list, iterable);
|
|
@@ -748,7 +758,7 @@ PyObject *MAKE_LIST(PyThreadState *tstate, PyObject *iterable) {
|
|
|
748
758
|
}
|
|
749
759
|
#else
|
|
750
760
|
#if PYTHON_VERSION >= 0x340
|
|
751
|
-
if (
|
|
761
|
+
if (Nuitka_PyObject_HasLen(iterable)) {
|
|
752
762
|
Py_ssize_t iter_len = Nuitka_PyObject_Size(iterable);
|
|
753
763
|
|
|
754
764
|
if (unlikely(iter_len == -1)) {
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
#include "nuitka/prelude.h"
|
|
8
8
|
#endif
|
|
9
9
|
|
|
10
|
-
PyObject *MAKE_LIST1(PyObject *arg0) {
|
|
10
|
+
PyObject *MAKE_LIST1(PyThreadState *tstate, PyObject *arg0) {
|
|
11
11
|
|
|
12
|
-
PyObject *result = MAKE_LIST_EMPTY(1);
|
|
12
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 1);
|
|
13
13
|
|
|
14
14
|
if (unlikely(result == NULL)) {
|
|
15
15
|
return NULL;
|
|
@@ -21,9 +21,9 @@ PyObject *MAKE_LIST1(PyObject *arg0) {
|
|
|
21
21
|
|
|
22
22
|
return result;
|
|
23
23
|
}
|
|
24
|
-
PyObject *MAKE_LIST2(PyObject *arg0, PyObject *arg1) {
|
|
24
|
+
PyObject *MAKE_LIST2(PyThreadState *tstate, PyObject *arg0, PyObject *arg1) {
|
|
25
25
|
|
|
26
|
-
PyObject *result = MAKE_LIST_EMPTY(2);
|
|
26
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 2);
|
|
27
27
|
|
|
28
28
|
if (unlikely(result == NULL)) {
|
|
29
29
|
return NULL;
|
|
@@ -39,9 +39,9 @@ PyObject *MAKE_LIST2(PyObject *arg0, PyObject *arg1) {
|
|
|
39
39
|
|
|
40
40
|
return result;
|
|
41
41
|
}
|
|
42
|
-
PyObject *MAKE_LIST3(PyObject *arg0, PyObject *arg1, PyObject *arg2) {
|
|
42
|
+
PyObject *MAKE_LIST3(PyThreadState *tstate, PyObject *arg0, PyObject *arg1, PyObject *arg2) {
|
|
43
43
|
|
|
44
|
-
PyObject *result = MAKE_LIST_EMPTY(3);
|
|
44
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 3);
|
|
45
45
|
|
|
46
46
|
if (unlikely(result == NULL)) {
|
|
47
47
|
return NULL;
|
|
@@ -61,12 +61,12 @@ PyObject *MAKE_LIST3(PyObject *arg0, PyObject *arg1, PyObject *arg2) {
|
|
|
61
61
|
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
|
-
PyObject *MAKE_LIST4(PyObject *list) {
|
|
64
|
+
PyObject *MAKE_LIST4(PyThreadState *tstate, PyObject *list) {
|
|
65
65
|
CHECK_OBJECT(list);
|
|
66
66
|
assert(PyList_CheckExact(list));
|
|
67
67
|
assert(PyList_GET_SIZE(list) == 4);
|
|
68
68
|
|
|
69
|
-
PyObject *result = MAKE_LIST_EMPTY(4);
|
|
69
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 4);
|
|
70
70
|
|
|
71
71
|
if (unlikely(result == NULL)) {
|
|
72
72
|
return NULL;
|
|
@@ -95,12 +95,12 @@ PyObject *MAKE_LIST4(PyObject *list) {
|
|
|
95
95
|
|
|
96
96
|
return result;
|
|
97
97
|
}
|
|
98
|
-
PyObject *MAKE_LIST5(PyObject *list) {
|
|
98
|
+
PyObject *MAKE_LIST5(PyThreadState *tstate, PyObject *list) {
|
|
99
99
|
CHECK_OBJECT(list);
|
|
100
100
|
assert(PyList_CheckExact(list));
|
|
101
101
|
assert(PyList_GET_SIZE(list) == 5);
|
|
102
102
|
|
|
103
|
-
PyObject *result = MAKE_LIST_EMPTY(5);
|
|
103
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 5);
|
|
104
104
|
|
|
105
105
|
if (unlikely(result == NULL)) {
|
|
106
106
|
return NULL;
|
|
@@ -134,12 +134,12 @@ PyObject *MAKE_LIST5(PyObject *list) {
|
|
|
134
134
|
|
|
135
135
|
return result;
|
|
136
136
|
}
|
|
137
|
-
PyObject *MAKE_LIST6(PyObject *list) {
|
|
137
|
+
PyObject *MAKE_LIST6(PyThreadState *tstate, PyObject *list) {
|
|
138
138
|
CHECK_OBJECT(list);
|
|
139
139
|
assert(PyList_CheckExact(list));
|
|
140
140
|
assert(PyList_GET_SIZE(list) == 6);
|
|
141
141
|
|
|
142
|
-
PyObject *result = MAKE_LIST_EMPTY(6);
|
|
142
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 6);
|
|
143
143
|
|
|
144
144
|
if (unlikely(result == NULL)) {
|
|
145
145
|
return NULL;
|
|
@@ -178,12 +178,12 @@ PyObject *MAKE_LIST6(PyObject *list) {
|
|
|
178
178
|
|
|
179
179
|
return result;
|
|
180
180
|
}
|
|
181
|
-
PyObject *MAKE_LIST7(PyObject *list) {
|
|
181
|
+
PyObject *MAKE_LIST7(PyThreadState *tstate, PyObject *list) {
|
|
182
182
|
CHECK_OBJECT(list);
|
|
183
183
|
assert(PyList_CheckExact(list));
|
|
184
184
|
assert(PyList_GET_SIZE(list) == 7);
|
|
185
185
|
|
|
186
|
-
PyObject *result = MAKE_LIST_EMPTY(7);
|
|
186
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 7);
|
|
187
187
|
|
|
188
188
|
if (unlikely(result == NULL)) {
|
|
189
189
|
return NULL;
|
|
@@ -227,12 +227,12 @@ PyObject *MAKE_LIST7(PyObject *list) {
|
|
|
227
227
|
|
|
228
228
|
return result;
|
|
229
229
|
}
|
|
230
|
-
PyObject *MAKE_LIST8(PyObject *list) {
|
|
230
|
+
PyObject *MAKE_LIST8(PyThreadState *tstate, PyObject *list) {
|
|
231
231
|
CHECK_OBJECT(list);
|
|
232
232
|
assert(PyList_CheckExact(list));
|
|
233
233
|
assert(PyList_GET_SIZE(list) == 8);
|
|
234
234
|
|
|
235
|
-
PyObject *result = MAKE_LIST_EMPTY(8);
|
|
235
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 8);
|
|
236
236
|
|
|
237
237
|
if (unlikely(result == NULL)) {
|
|
238
238
|
return NULL;
|
|
@@ -281,12 +281,12 @@ PyObject *MAKE_LIST8(PyObject *list) {
|
|
|
281
281
|
|
|
282
282
|
return result;
|
|
283
283
|
}
|
|
284
|
-
PyObject *MAKE_LIST9(PyObject *list) {
|
|
284
|
+
PyObject *MAKE_LIST9(PyThreadState *tstate, PyObject *list) {
|
|
285
285
|
CHECK_OBJECT(list);
|
|
286
286
|
assert(PyList_CheckExact(list));
|
|
287
287
|
assert(PyList_GET_SIZE(list) == 9);
|
|
288
288
|
|
|
289
|
-
PyObject *result = MAKE_LIST_EMPTY(9);
|
|
289
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 9);
|
|
290
290
|
|
|
291
291
|
if (unlikely(result == NULL)) {
|
|
292
292
|
return NULL;
|
|
@@ -340,12 +340,12 @@ PyObject *MAKE_LIST9(PyObject *list) {
|
|
|
340
340
|
|
|
341
341
|
return result;
|
|
342
342
|
}
|
|
343
|
-
PyObject *MAKE_LIST10(PyObject *list) {
|
|
343
|
+
PyObject *MAKE_LIST10(PyThreadState *tstate, PyObject *list) {
|
|
344
344
|
CHECK_OBJECT(list);
|
|
345
345
|
assert(PyList_CheckExact(list));
|
|
346
346
|
assert(PyList_GET_SIZE(list) == 10);
|
|
347
347
|
|
|
348
|
-
PyObject *result = MAKE_LIST_EMPTY(10);
|
|
348
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 10);
|
|
349
349
|
|
|
350
350
|
if (unlikely(result == NULL)) {
|
|
351
351
|
return NULL;
|
|
@@ -404,12 +404,12 @@ PyObject *MAKE_LIST10(PyObject *list) {
|
|
|
404
404
|
|
|
405
405
|
return result;
|
|
406
406
|
}
|
|
407
|
-
PyObject *MAKE_LIST11(PyObject *list) {
|
|
407
|
+
PyObject *MAKE_LIST11(PyThreadState *tstate, PyObject *list) {
|
|
408
408
|
CHECK_OBJECT(list);
|
|
409
409
|
assert(PyList_CheckExact(list));
|
|
410
410
|
assert(PyList_GET_SIZE(list) == 11);
|
|
411
411
|
|
|
412
|
-
PyObject *result = MAKE_LIST_EMPTY(11);
|
|
412
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 11);
|
|
413
413
|
|
|
414
414
|
if (unlikely(result == NULL)) {
|
|
415
415
|
return NULL;
|
|
@@ -473,12 +473,12 @@ PyObject *MAKE_LIST11(PyObject *list) {
|
|
|
473
473
|
|
|
474
474
|
return result;
|
|
475
475
|
}
|
|
476
|
-
PyObject *MAKE_LIST12(PyObject *list) {
|
|
476
|
+
PyObject *MAKE_LIST12(PyThreadState *tstate, PyObject *list) {
|
|
477
477
|
CHECK_OBJECT(list);
|
|
478
478
|
assert(PyList_CheckExact(list));
|
|
479
479
|
assert(PyList_GET_SIZE(list) == 12);
|
|
480
480
|
|
|
481
|
-
PyObject *result = MAKE_LIST_EMPTY(12);
|
|
481
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 12);
|
|
482
482
|
|
|
483
483
|
if (unlikely(result == NULL)) {
|
|
484
484
|
return NULL;
|
|
@@ -42,10 +42,7 @@ PyObject *MATCH_CLASS_ARGS(PyThreadState *tstate, PyObject *matched, Py_ssize_t
|
|
|
42
42
|
return NULL;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
// this just fine.
|
|
47
|
-
PyObject *elements[1] = {matched};
|
|
48
|
-
return MAKE_TUPLE(elements, 1);
|
|
45
|
+
return MAKE_TUPLE1(tstate, matched);
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
actual = 0;
|
|
@@ -58,7 +55,7 @@ PyObject *MATCH_CLASS_ARGS(PyThreadState *tstate, PyObject *matched, Py_ssize_t
|
|
|
58
55
|
return NULL;
|
|
59
56
|
}
|
|
60
57
|
|
|
61
|
-
PyObject *result = MAKE_TUPLE_EMPTY_VAR(actual);
|
|
58
|
+
PyObject *result = MAKE_TUPLE_EMPTY_VAR(tstate, actual);
|
|
62
59
|
|
|
63
60
|
for (Py_ssize_t i = 0; i < max_allowed; i++) {
|
|
64
61
|
PyObject *arg_name = PyTuple_GET_ITEM(match_args, i);
|
|
@@ -89,6 +86,36 @@ PyObject *MATCH_CLASS_ARGS(PyThreadState *tstate, PyObject *matched, Py_ssize_t
|
|
|
89
86
|
Py_DECREF(match_args);
|
|
90
87
|
return result;
|
|
91
88
|
}
|
|
89
|
+
|
|
90
|
+
int MATCH_MAPPING_KEY(PyThreadState *tstate, PyObject *map, PyObject *key) {
|
|
91
|
+
// Need to use get_method with default value, so "defaultdict" do not
|
|
92
|
+
// mutate. TODO: Use a cached value across the "match".
|
|
93
|
+
PyObject *get_method = LOOKUP_ATTRIBUTE(tstate, map, const_str_plain_get);
|
|
94
|
+
if (unlikely(get_method == NULL)) {
|
|
95
|
+
return -1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
PyObject *args[] = {key, Nuitka_sentinel_value};
|
|
99
|
+
|
|
100
|
+
PyObject *value = CALL_FUNCTION_WITH_ARGS2(tstate, get_method, args);
|
|
101
|
+
|
|
102
|
+
Py_XDECREF(get_method);
|
|
103
|
+
|
|
104
|
+
if (unlikely(value == NULL)) {
|
|
105
|
+
return -1;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (value == Nuitka_sentinel_value) {
|
|
109
|
+
Py_DECREF_IMMORTAL(value);
|
|
110
|
+
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
Py_DECREF(value);
|
|
115
|
+
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
92
119
|
// Part of "Nuitka", an optimizing Python compiler that is compatible and
|
|
93
120
|
// integrates with CPython, but also works on its own.
|
|
94
121
|
//
|