Nuitka-winsvc 2.1.6__cp311-cp311-win_amd64.whl → 2.2.2__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.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/METADATA +1 -1
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/RECORD +234 -225
- nuitka/Errors.py +4 -0
- nuitka/HardImportRegistry.py +18 -1
- nuitka/MainControl.py +27 -30
- nuitka/OptionParsing.py +32 -30
- nuitka/Options.py +26 -13
- nuitka/OutputDirectories.py +7 -4
- nuitka/PostProcessing.py +9 -7
- nuitka/Progress.py +3 -3
- nuitka/PythonVersions.py +2 -2
- nuitka/TreeXML.py +1 -1
- nuitka/Version.py +1 -1
- nuitka/build/Backend.scons +2 -1
- nuitka/build/DataComposerInterface.py +1 -0
- nuitka/build/Onefile.scons +2 -1
- nuitka/build/SconsCaching.py +64 -46
- nuitka/build/SconsCompilerSettings.py +19 -6
- nuitka/build/SconsHacks.py +0 -1
- nuitka/build/SconsInterface.py +84 -5
- nuitka/build/SconsProgress.py +0 -1
- nuitka/build/SconsUtils.py +8 -4
- nuitka/build/include/nuitka/allocator.h +8 -3
- nuitka/build/include/nuitka/compiled_cell.h +8 -0
- nuitka/build/include/nuitka/exceptions.h +554 -179
- nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
- nuitka/build/include/nuitka/helper/import_hard.h +3 -0
- nuitka/build/include/nuitka/helper/ints.h +15 -2
- nuitka/build/include/nuitka/helper/lists.h +4 -1
- nuitka/build/include/nuitka/helper/raising.h +12 -0
- nuitka/build/include/nuitka/helper/tuples.h +5 -1
- nuitka/build/include/nuitka/helpers.h +4 -0
- nuitka/build/include/nuitka/importing.h +3 -4
- nuitka/build/include/nuitka/jit_sources.h +25 -0
- nuitka/build/include/nuitka/prelude.h +38 -11
- nuitka/build/include/nuitka/printing.h +3 -0
- nuitka/build/include/nuitka/threading.h +2 -6
- nuitka/build/include/nuitka/type_aliases.h +27 -0
- nuitka/build/inline_copy/pkg_resources/pkg_resources/__init__.py +0 -3
- nuitka/build/inline_copy/tqdm/tqdm/version.py +1 -4
- nuitka/build/static_src/CompiledAsyncgenType.c +99 -114
- nuitka/build/static_src/CompiledCodeHelpers.c +23 -14
- nuitka/build/static_src/CompiledCoroutineType.c +96 -114
- nuitka/build/static_src/CompiledFrameType.c +14 -11
- nuitka/build/static_src/CompiledFunctionType.c +34 -7
- nuitka/build/static_src/CompiledGeneratorType.c +248 -142
- nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +60 -70
- nuitka/build/static_src/CompiledMethodType.c +8 -7
- nuitka/build/static_src/HelpersAttributes.c +2 -19
- nuitka/build/static_src/HelpersBuiltin.c +2 -1
- nuitka/build/static_src/HelpersComparisonEq.c +32 -18
- nuitka/build/static_src/HelpersComparisonGe.c +50 -36
- nuitka/build/static_src/HelpersComparisonGt.c +50 -36
- nuitka/build/static_src/HelpersComparisonLe.c +50 -36
- nuitka/build/static_src/HelpersComparisonLt.c +50 -36
- nuitka/build/static_src/HelpersComparisonNe.c +32 -18
- nuitka/build/static_src/HelpersDeepcopy.c +6 -8
- nuitka/build/static_src/HelpersDictionaries.c +8 -3
- nuitka/build/static_src/HelpersExceptions.c +42 -28
- nuitka/build/static_src/HelpersFilesystemPaths.c +7 -7
- nuitka/build/static_src/HelpersImportHard.c +15 -0
- nuitka/build/static_src/HelpersJitSources.c +46 -0
- nuitka/build/static_src/HelpersLists.c +40 -0
- nuitka/build/static_src/HelpersOperationBinaryAdd.c +66 -66
- nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +80 -33
- nuitka/build/static_src/HelpersOperationBinaryMultUtils.c +16 -13
- nuitka/build/static_src/HelpersOperationBinarySub.c +39 -39
- nuitka/build/static_src/HelpersOperationInplaceAdd.c +54 -54
- nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -1
- nuitka/build/static_src/HelpersOperationInplaceSub.c +50 -50
- nuitka/build/static_src/HelpersProfiling.c +3 -4
- nuitka/build/static_src/HelpersRaising.c +62 -1
- nuitka/build/static_src/HelpersStrings.c +203 -8
- nuitka/build/static_src/HelpersTypes.c +42 -0
- nuitka/build/static_src/MainProgram.c +1 -1
- nuitka/build/static_src/MetaPathBasedLoader.c +2 -1
- nuitka/build/static_src/OnefileBootstrap.c +3 -3
- nuitka/code_generation/BinaryOperationHelperDefinitions.py +5 -3
- nuitka/code_generation/BuiltinCodes.py +1 -0
- nuitka/code_generation/CodeGeneration.py +11 -0
- nuitka/code_generation/CodeHelpers.py +5 -3
- nuitka/code_generation/CodeObjectCodes.py +10 -6
- nuitka/code_generation/ComparisonCodes.py +19 -3
- nuitka/code_generation/ConstantCodes.py +5 -0
- nuitka/code_generation/Contexts.py +22 -6
- nuitka/code_generation/Emission.py +1 -0
- nuitka/code_generation/ErrorCodes.py +8 -16
- nuitka/code_generation/EvalCodes.py +5 -3
- nuitka/code_generation/ExceptionCodes.py +8 -1
- nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +1 -0
- nuitka/code_generation/FrameCodes.py +5 -3
- nuitka/code_generation/FunctionCodes.py +0 -1
- nuitka/code_generation/GeneratorCodes.py +3 -3
- nuitka/code_generation/GlobalConstants.py +0 -2
- nuitka/code_generation/ImportCodes.py +2 -0
- nuitka/code_generation/JitCodes.py +44 -0
- nuitka/code_generation/ListCodes.py +11 -17
- nuitka/code_generation/MatchCodes.py +0 -1
- nuitka/code_generation/ModuleCodes.py +2 -1
- nuitka/code_generation/Namify.py +0 -1
- nuitka/code_generation/NetworkxCodes.py +51 -0
- nuitka/code_generation/OperationCodes.py +8 -6
- nuitka/code_generation/PackageResourceCodes.py +7 -5
- nuitka/code_generation/TensorflowCodes.py +54 -0
- nuitka/code_generation/TypeAliasCodes.py +71 -0
- nuitka/code_generation/VariableCodes.py +7 -5
- nuitka/code_generation/VariableDeclarations.py +1 -0
- nuitka/code_generation/c_types/CTypeCLongs.py +0 -1
- nuitka/code_generation/c_types/CTypeNuitkaInts.py +0 -1
- nuitka/code_generation/c_types/CTypeVoids.py +1 -0
- nuitka/code_generation/templates/CodeTemplatesConstants.py +14 -0
- nuitka/code_generation/templates/CodeTemplatesExceptions.py +1 -1
- nuitka/code_generation/templates/CodeTemplatesIterators.py +0 -1
- nuitka/code_generation/templates/CodeTemplatesLoader.py +0 -1
- nuitka/code_generation/templates/CodeTemplatesModules.py +9 -4
- nuitka/code_generation/templates/CodeTemplatesVariables.py +8 -8
- nuitka/code_generation/templates/TemplateDebugWrapper.py +0 -1
- nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -0
- nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +9 -7
- nuitka/containers/Namedtuples.py +0 -1
- nuitka/finalizations/Finalization.py +1 -0
- nuitka/finalizations/FinalizeMarkups.py +0 -1
- nuitka/freezer/DllDependenciesMacOS.py +60 -13
- nuitka/freezer/DllDependenciesPosix.py +0 -1
- nuitka/freezer/DllDependenciesWin32.py +2 -1
- nuitka/freezer/IncludedDataFiles.py +46 -15
- nuitka/freezer/IncludedEntryPoints.py +5 -3
- nuitka/freezer/Standalone.py +6 -1
- nuitka/importing/ImportCache.py +2 -2
- nuitka/importing/ImportResolving.py +80 -78
- nuitka/importing/Importing.py +34 -1
- nuitka/nodes/AttributeNodesGenerated.py +21 -6
- nuitka/nodes/BuiltinComplexNodes.py +1 -0
- nuitka/nodes/BuiltinFormatNodes.py +1 -0
- nuitka/nodes/BuiltinIteratorNodes.py +5 -3
- nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +21 -6
- nuitka/nodes/BuiltinRefNodes.py +8 -1
- nuitka/nodes/BuiltinVarsNodes.py +0 -1
- nuitka/nodes/ChildrenHavingMixins.py +906 -186
- nuitka/nodes/CodeObjectSpecs.py +1 -1
- nuitka/nodes/ConditionalNodes.py +2 -6
- nuitka/nodes/ConstantRefNodes.py +38 -0
- nuitka/nodes/CtypesNodes.py +0 -1
- nuitka/nodes/DictionaryNodes.py +0 -1
- nuitka/nodes/ExceptionNodes.py +10 -0
- nuitka/nodes/ExpressionBases.py +15 -9
- nuitka/nodes/ExpressionBasesGenerated.py +32 -15
- nuitka/nodes/FunctionNodes.py +50 -5
- nuitka/nodes/HardImportNodesGenerated.py +245 -60
- nuitka/nodes/ImportHardNodes.py +27 -13
- nuitka/nodes/ImportNodes.py +92 -70
- nuitka/nodes/InjectCNodes.py +0 -1
- nuitka/nodes/ModuleNodes.py +10 -5
- nuitka/nodes/NetworkxNodes.py +45 -0
- nuitka/nodes/OperatorNodesUnary.py +1 -0
- nuitka/nodes/OsSysNodes.py +0 -1
- nuitka/nodes/PackageMetadataNodes.py +0 -1
- nuitka/nodes/PackageResourceNodes.py +10 -6
- nuitka/nodes/StatementBasesGenerated.py +107 -60
- nuitka/nodes/StringConcatenationNodes.py +1 -0
- nuitka/nodes/TensorflowNodes.py +38 -0
- nuitka/nodes/TypeNodes.py +21 -0
- nuitka/nodes/VariableRefNodes.py +1 -0
- nuitka/nodes/shapes/BuiltinTypeShapes.py +25 -15
- nuitka/optimizations/Optimization.py +7 -6
- nuitka/optimizations/OptimizeBuiltinCalls.py +11 -9
- nuitka/optimizations/Tags.py +0 -1
- nuitka/optimizations/TraceCollections.py +6 -55
- nuitka/optimizations/ValueTraces.py +49 -1
- nuitka/plugins/PluginBase.py +26 -4
- nuitka/plugins/Plugins.py +49 -12
- nuitka/plugins/standard/AntiBloatPlugin.py +12 -2
- nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +0 -1
- nuitka/plugins/standard/DataFilesPlugin.py +2 -6
- nuitka/plugins/standard/DillPlugin.py +3 -3
- nuitka/plugins/standard/DllFilesPlugin.py +29 -23
- nuitka/plugins/standard/GiPlugin.py +1 -0
- nuitka/plugins/standard/ImplicitImports.py +8 -7
- nuitka/plugins/standard/MatplotlibPlugin.py +1 -0
- nuitka/plugins/standard/OptionsNannyPlugin.py +3 -7
- nuitka/plugins/standard/PkgResourcesPlugin.py +0 -1
- nuitka/plugins/standard/PmwPlugin.py +10 -9
- nuitka/plugins/standard/PySidePyQtPlugin.py +0 -28
- nuitka/plugins/standard/TensorflowPlugin.py +1 -0
- nuitka/plugins/standard/TorchPlugin.py +1 -0
- nuitka/plugins/standard/TrioPlugin.py +1 -0
- nuitka/plugins/standard/standard.nuitka-package.config.yml +249 -34
- nuitka/reports/CompilationReportReader.py +0 -1
- nuitka/reports/Reports.py +49 -5
- nuitka/specs/BuiltinParameterSpecs.py +10 -2
- nuitka/specs/BuiltinStrOperationSpecs.py +1 -1
- nuitka/specs/BuiltinTypeOperationSpecs.py +0 -1
- nuitka/specs/HardImportSpecs.py +34 -1
- nuitka/specs/ParameterSpecs.py +11 -9
- nuitka/tools/environments/Virtualenv.py +0 -1
- nuitka/tools/specialize/CTypeDescriptions.py +15 -11
- nuitka/tools/specialize/SpecializeC.py +11 -9
- nuitka/tools/specialize/SpecializePython.py +57 -30
- nuitka/tools/testing/Common.py +24 -7
- nuitka/tools/testing/OutputComparison.py +4 -0
- nuitka/tools/testing/Pythons.py +0 -1
- nuitka/tools/testing/compare_with_cpython/__main__.py +0 -4
- nuitka/tools/watch/GitHub.py +4 -1
- nuitka/tools/watch/__main__.py +22 -1
- nuitka/tree/Building.py +3 -0
- nuitka/tree/InternalModule.py +0 -1
- nuitka/tree/ReformulationAssertStatements.py +1 -0
- nuitka/tree/ReformulationAssignmentStatements.py +26 -3
- nuitka/tree/ReformulationClasses3.py +23 -26
- nuitka/tree/ReformulationContractionExpressions.py +5 -3
- nuitka/tree/ReformulationDictionaryCreation.py +6 -5
- nuitka/tree/ReformulationExecStatements.py +8 -6
- nuitka/tree/ReformulationFunctionStatements.py +10 -6
- nuitka/tree/SourceHandling.py +8 -0
- nuitka/tree/TreeHelpers.py +6 -3
- nuitka/utils/AppDirs.py +6 -2
- nuitka/utils/CStrings.py +1 -1
- nuitka/utils/CommandLineOptions.py +0 -1
- nuitka/utils/Distributions.py +3 -3
- nuitka/utils/Download.py +5 -1
- nuitka/utils/Execution.py +6 -3
- nuitka/utils/FileOperations.py +61 -34
- nuitka/utils/Importing.py +4 -4
- nuitka/utils/InstanceCounters.py +1 -0
- nuitka/utils/MacOSApp.py +1 -0
- nuitka/utils/Shebang.py +1 -0
- nuitka/utils/Utils.py +39 -1
- nuitka/utils/WindowsFileUsage.py +4 -3
- {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.2.data}/scripts/nuitka-run.bat +0 -0
- {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.2.data}/scripts/nuitka.bat +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/WHEEL +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/top_level.txt +0 -0
|
@@ -57,8 +57,8 @@ static void Nuitka_MarkCoroutineAsNotRunning(struct Nuitka_CoroutineObject *coro
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
static PyObject *_Nuitka_Coroutine_send(PyThreadState *tstate, struct Nuitka_CoroutineObject *coroutine,
|
|
60
|
-
PyObject *value, bool closing,
|
|
61
|
-
|
|
60
|
+
PyObject *value, bool closing,
|
|
61
|
+
struct Nuitka_ExceptionPreservationItem *exception_state);
|
|
62
62
|
|
|
63
63
|
static long Nuitka_Coroutine_tp_hash(struct Nuitka_CoroutineObject *coroutine) { return coroutine->m_counter; }
|
|
64
64
|
|
|
@@ -194,17 +194,16 @@ static PyObject *_Nuitka_YieldFromCore(PyThreadState *tstate, PyObject *yield_fr
|
|
|
194
194
|
|
|
195
195
|
PyObject *retval;
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
PyTracebackObject *exception_tb;
|
|
197
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
199
198
|
|
|
200
|
-
|
|
199
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &exception_state);
|
|
201
200
|
|
|
202
|
-
if (
|
|
201
|
+
if (HAS_EXCEPTION_STATE(&exception_state)) {
|
|
203
202
|
// Exception, was thrown into us, need to send that to sub-generator.
|
|
204
203
|
// We acquired ownership of the published exception and need to release it potentially.
|
|
205
204
|
|
|
206
205
|
// Transfer exception owner this.
|
|
207
|
-
retval = _Nuitka_YieldFromPassExceptionTo(tstate, yield_from,
|
|
206
|
+
retval = _Nuitka_YieldFromPassExceptionTo(tstate, yield_from, &exception_state);
|
|
208
207
|
|
|
209
208
|
// TODO: This wants to look at retval most definitely, send_value is going to be NULL.
|
|
210
209
|
if (unlikely(send_value == NULL)) {
|
|
@@ -224,7 +223,11 @@ static PyObject *_Nuitka_YieldFromCore(PyThreadState *tstate, PyObject *yield_fr
|
|
|
224
223
|
((struct Nuitka_CoroutineWrapperObject *)yield_from)->m_coroutine;
|
|
225
224
|
|
|
226
225
|
Py_INCREF(Py_None);
|
|
227
|
-
|
|
226
|
+
|
|
227
|
+
struct Nuitka_ExceptionPreservationItem no_exception_state;
|
|
228
|
+
INIT_ERROR_OCCURRED_STATE(&no_exception_state);
|
|
229
|
+
|
|
230
|
+
retval = _Nuitka_Coroutine_send(tstate, yieldfrom_coroutine, Py_None, mode ? false : true, &no_exception_state);
|
|
228
231
|
} else if (send_value == Py_None && Py_TYPE(yield_from)->tp_iternext != NULL) {
|
|
229
232
|
retval = Py_TYPE(yield_from)->tp_iternext(yield_from);
|
|
230
233
|
} else {
|
|
@@ -369,30 +372,26 @@ static void Nuitka_SetStopIterationValue(PyThreadState *tstate, PyObject *value)
|
|
|
369
372
|
// be normalized.
|
|
370
373
|
|
|
371
374
|
static PySendResult _Nuitka_Coroutine_sendR(PyThreadState *tstate, struct Nuitka_CoroutineObject *coroutine,
|
|
372
|
-
PyObject *value, bool closing,
|
|
373
|
-
|
|
375
|
+
PyObject *value, bool closing,
|
|
376
|
+
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
374
377
|
PyObject **result) {
|
|
375
378
|
CHECK_OBJECT(coroutine);
|
|
376
379
|
assert(Nuitka_Coroutine_Check((PyObject *)coroutine));
|
|
377
|
-
|
|
378
|
-
CHECK_OBJECT_X(exception_value);
|
|
379
|
-
CHECK_OBJECT_X(exception_tb);
|
|
380
|
+
CHECK_EXCEPTION_STATE_X(exception_state);
|
|
380
381
|
CHECK_OBJECT_X(value);
|
|
381
382
|
|
|
382
383
|
#if _DEBUG_COROUTINE
|
|
383
384
|
PRINT_COROUTINE_STATUS("Enter", coroutine);
|
|
384
385
|
PRINT_COROUTINE_STRING("closing", closing ? "(closing) " : "(not closing) ");
|
|
385
386
|
PRINT_COROUTINE_VALUE("value", value);
|
|
386
|
-
|
|
387
|
+
PRINT_EXCEPTION_STATE(exception_state);
|
|
387
388
|
PRINT_CURRENT_EXCEPTION();
|
|
388
389
|
PRINT_NEW_LINE();
|
|
389
390
|
#endif
|
|
390
391
|
|
|
391
392
|
// Not both a value and an exception please.
|
|
392
393
|
if (value != NULL) {
|
|
393
|
-
|
|
394
|
-
assert(exception_value == NULL);
|
|
395
|
-
assert(exception_tb == NULL);
|
|
394
|
+
ASSERT_EMPTY_EXCEPTION_STATE(exception_state);
|
|
396
395
|
}
|
|
397
396
|
|
|
398
397
|
if (coroutine->m_status == status_Unused && value != NULL && value != Py_None) {
|
|
@@ -434,11 +433,11 @@ static PySendResult _Nuitka_Coroutine_sendR(PyThreadState *tstate, struct Nuitka
|
|
|
434
433
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
435
434
|
|
|
436
435
|
// Check for thrown exception, publish it to the coroutine code.
|
|
437
|
-
if (unlikely(
|
|
436
|
+
if (unlikely(HAS_EXCEPTION_STATE(exception_state))) {
|
|
438
437
|
assert(value == NULL);
|
|
439
438
|
|
|
440
439
|
// Transfer exception ownership to published.
|
|
441
|
-
|
|
440
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
442
441
|
}
|
|
443
442
|
|
|
444
443
|
#if _DEBUG_COROUTINE
|
|
@@ -535,30 +534,7 @@ static PySendResult _Nuitka_Coroutine_sendR(PyThreadState *tstate, struct Nuitka
|
|
|
535
534
|
|
|
536
535
|
return PYGEN_RETURN;
|
|
537
536
|
} else if (error == PyExc_StopIteration) {
|
|
538
|
-
|
|
539
|
-
PyTracebackObject *saved_exception_tb;
|
|
540
|
-
|
|
541
|
-
// TODO: For Python3.12, this kind of code ought to use tstate methods entirely.
|
|
542
|
-
FETCH_ERROR_OCCURRED(tstate, &saved_exception_type, &saved_exception_value, &saved_exception_tb);
|
|
543
|
-
NORMALIZE_EXCEPTION(tstate, &saved_exception_type, &saved_exception_value, &saved_exception_tb);
|
|
544
|
-
|
|
545
|
-
PyErr_Format(PyExc_RuntimeError, "coroutine raised StopIteration");
|
|
546
|
-
|
|
547
|
-
FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
|
|
548
|
-
|
|
549
|
-
RAISE_EXCEPTION_WITH_CAUSE(tstate, &exception_type, &exception_value, &exception_tb,
|
|
550
|
-
saved_exception_value);
|
|
551
|
-
|
|
552
|
-
CHECK_OBJECT(exception_value);
|
|
553
|
-
CHECK_OBJECT(saved_exception_value);
|
|
554
|
-
|
|
555
|
-
Py_INCREF(saved_exception_value);
|
|
556
|
-
PyException_SetContext(exception_value, saved_exception_value);
|
|
557
|
-
|
|
558
|
-
Py_DECREF(saved_exception_type);
|
|
559
|
-
Py_XDECREF(saved_exception_tb);
|
|
560
|
-
|
|
561
|
-
RESTORE_ERROR_OCCURRED(tstate, exception_type, exception_value, exception_tb);
|
|
537
|
+
RAISE_RUNTIME_ERROR_RAISED_STOP_ITERATION(tstate, "coroutine raised StopIteration");
|
|
562
538
|
|
|
563
539
|
#if _DEBUG_COROUTINE
|
|
564
540
|
PRINT_COROUTINE_STATUS("Leave with exception set", coroutine);
|
|
@@ -577,9 +553,7 @@ static PySendResult _Nuitka_Coroutine_sendR(PyThreadState *tstate, struct Nuitka
|
|
|
577
553
|
Py_XDECREF(value);
|
|
578
554
|
|
|
579
555
|
// Release exception if any, we are finished with it and will raise another.
|
|
580
|
-
|
|
581
|
-
Py_XDECREF(exception_value);
|
|
582
|
-
Py_XDECREF(exception_tb);
|
|
556
|
+
RELEASE_ERROR_OCCURRED_STATE_X(exception_state);
|
|
583
557
|
|
|
584
558
|
/* This is for status_Finished */
|
|
585
559
|
assert(coroutine->m_status == status_Finished);
|
|
@@ -611,12 +585,11 @@ static PySendResult _Nuitka_Coroutine_sendR(PyThreadState *tstate, struct Nuitka
|
|
|
611
585
|
}
|
|
612
586
|
|
|
613
587
|
static PyObject *_Nuitka_Coroutine_send(PyThreadState *tstate, struct Nuitka_CoroutineObject *coroutine,
|
|
614
|
-
PyObject *value, bool closing,
|
|
615
|
-
|
|
588
|
+
PyObject *value, bool closing,
|
|
589
|
+
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
616
590
|
|
|
617
591
|
PyObject *result;
|
|
618
|
-
PySendResult res = _Nuitka_Coroutine_sendR(tstate, coroutine, value, closing,
|
|
619
|
-
exception_tb, &result);
|
|
592
|
+
PySendResult res = _Nuitka_Coroutine_sendR(tstate, coroutine, value, closing, exception_state, &result);
|
|
620
593
|
|
|
621
594
|
switch (res) {
|
|
622
595
|
case PYGEN_RETURN:
|
|
@@ -648,7 +621,11 @@ static PyObject *Nuitka_Coroutine_send(struct Nuitka_CoroutineObject *coroutine,
|
|
|
648
621
|
Py_INCREF(value);
|
|
649
622
|
|
|
650
623
|
PyThreadState *tstate = PyThreadState_GET();
|
|
651
|
-
|
|
624
|
+
|
|
625
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
626
|
+
INIT_ERROR_OCCURRED_STATE(&exception_state);
|
|
627
|
+
|
|
628
|
+
PyObject *result = _Nuitka_Coroutine_send(tstate, coroutine, value, false, &exception_state);
|
|
652
629
|
|
|
653
630
|
if (result == NULL) {
|
|
654
631
|
if (HAS_ERROR_OCCURRED(tstate) == false) {
|
|
@@ -667,9 +644,10 @@ static bool _Nuitka_Coroutine_close(PyThreadState *tstate, struct Nuitka_Corouti
|
|
|
667
644
|
CHECK_OBJECT(coroutine);
|
|
668
645
|
|
|
669
646
|
if (coroutine->m_status == status_Running) {
|
|
670
|
-
|
|
647
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
648
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_ARGS(tstate, &exception_state, PyExc_GeneratorExit, NULL, NULL);
|
|
671
649
|
|
|
672
|
-
PyObject *result = _Nuitka_Coroutine_send(tstate, coroutine, NULL, true,
|
|
650
|
+
PyObject *result = _Nuitka_Coroutine_send(tstate, coroutine, NULL, true, &exception_state);
|
|
673
651
|
|
|
674
652
|
if (unlikely(result)) {
|
|
675
653
|
Py_DECREF(result);
|
|
@@ -701,12 +679,11 @@ static PyObject *Nuitka_Coroutine_close(struct Nuitka_CoroutineObject *coroutine
|
|
|
701
679
|
static bool Nuitka_AsyncgenAsend_Check(PyObject *object);
|
|
702
680
|
struct Nuitka_AsyncgenAsendObject;
|
|
703
681
|
static PyObject *_Nuitka_AsyncgenAsend_throw2(PyThreadState *tstate, struct Nuitka_AsyncgenAsendObject *asyncgen_asend,
|
|
704
|
-
|
|
705
|
-
PyTracebackObject *exception_tb);
|
|
682
|
+
struct Nuitka_ExceptionPreservationItem *exception_state);
|
|
706
683
|
#endif
|
|
707
684
|
|
|
708
|
-
static bool
|
|
709
|
-
|
|
685
|
+
static bool _Nuitka_Generator_check_throw(PyThreadState *tstate,
|
|
686
|
+
struct Nuitka_ExceptionPreservationItem *exception_state);
|
|
710
687
|
|
|
711
688
|
// This function is called when yielding to a coroutine through "_Nuitka_YieldFromPassExceptionTo"
|
|
712
689
|
// and potentially wrapper objects used by generators, or by the throw method itself.
|
|
@@ -715,24 +692,21 @@ static bool _Nuitka_Generator_check_throw2(PyThreadState *tstate, PyObject **exc
|
|
|
715
692
|
// value of exception_type will not be NULL, but the actual exception will not necessarily
|
|
716
693
|
// be normalized.
|
|
717
694
|
static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_CoroutineObject *coroutine, bool closing,
|
|
718
|
-
|
|
719
|
-
PyTracebackObject *exception_tb) {
|
|
695
|
+
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
720
696
|
CHECK_OBJECT(coroutine);
|
|
721
697
|
assert(Nuitka_Coroutine_Check((PyObject *)coroutine));
|
|
722
|
-
|
|
723
|
-
CHECK_OBJECT_X(exception_value);
|
|
724
|
-
CHECK_OBJECT_X(exception_tb);
|
|
698
|
+
CHECK_EXCEPTION_STATE(exception_state);
|
|
725
699
|
|
|
726
700
|
#if _DEBUG_COROUTINE
|
|
727
701
|
PRINT_COROUTINE_STATUS("Enter", coroutine);
|
|
728
702
|
PRINT_COROUTINE_STRING("closing", closing ? "(closing) " : "(not closing) ");
|
|
729
703
|
PRINT_COROUTINE_VALUE("yield_from", coroutine->m_yield_from);
|
|
730
|
-
|
|
704
|
+
PRINT_EXCEPTION_STATE(exception_state);
|
|
731
705
|
PRINT_NEW_LINE();
|
|
732
706
|
#endif
|
|
733
707
|
|
|
734
708
|
if (coroutine->m_yield_from != NULL) {
|
|
735
|
-
if (
|
|
709
|
+
if (EXCEPTION_STATE_MATCH_BOOL_SINGLE(tstate, exception_state, PyExc_GeneratorExit)) {
|
|
736
710
|
// Coroutines need to close the yield_from.
|
|
737
711
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
738
712
|
bool res = Nuitka_gen_close_iter(tstate, coroutine->m_yield_from);
|
|
@@ -740,16 +714,13 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
740
714
|
|
|
741
715
|
if (res == false) {
|
|
742
716
|
// Release exception, we are done with it now and pick up the new one.
|
|
743
|
-
|
|
744
|
-
Py_XDECREF(exception_value);
|
|
745
|
-
Py_XDECREF(exception_tb);
|
|
717
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
746
718
|
|
|
747
|
-
|
|
719
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
748
720
|
}
|
|
749
721
|
|
|
750
722
|
// Transferred exception ownership to "_Nuitka_Coroutine_send".
|
|
751
|
-
return _Nuitka_Coroutine_send(tstate, coroutine, NULL, false,
|
|
752
|
-
exception_tb);
|
|
723
|
+
return _Nuitka_Coroutine_send(tstate, coroutine, NULL, false, exception_state);
|
|
753
724
|
}
|
|
754
725
|
|
|
755
726
|
PyObject *ret;
|
|
@@ -764,13 +735,13 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
764
735
|
struct Nuitka_GeneratorObject *gen = ((struct Nuitka_GeneratorObject *)coroutine->m_yield_from);
|
|
765
736
|
// Transferred exception ownership to "_Nuitka_Generator_throw2".
|
|
766
737
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
767
|
-
ret = _Nuitka_Generator_throw2(tstate, gen,
|
|
738
|
+
ret = _Nuitka_Generator_throw2(tstate, gen, exception_state);
|
|
768
739
|
Nuitka_MarkCoroutineAsNotRunning(coroutine);
|
|
769
740
|
} else if (Nuitka_Coroutine_Check(coroutine->m_yield_from)) {
|
|
770
741
|
struct Nuitka_CoroutineObject *coro = ((struct Nuitka_CoroutineObject *)coroutine->m_yield_from);
|
|
771
742
|
// Transferred exception ownership to "_Nuitka_Coroutine_throw2".
|
|
772
743
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
773
|
-
ret = _Nuitka_Coroutine_throw2(tstate, coro, true,
|
|
744
|
+
ret = _Nuitka_Coroutine_throw2(tstate, coro, true, exception_state);
|
|
774
745
|
Nuitka_MarkCoroutineAsNotRunning(coroutine);
|
|
775
746
|
#if NUITKA_UNCOMPILED_THROW_INTEGRATION
|
|
776
747
|
} else if (PyGen_CheckExact(coroutine->m_yield_from) || PyCoro_CheckExact(coroutine->m_yield_from)) {
|
|
@@ -778,7 +749,7 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
778
749
|
|
|
779
750
|
// Transferred exception ownership to "Nuitka_UncompiledGenerator_throw".
|
|
780
751
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
781
|
-
ret = Nuitka_UncompiledGenerator_throw(tstate, gen, 1,
|
|
752
|
+
ret = Nuitka_UncompiledGenerator_throw(tstate, gen, 1, exception_state);
|
|
782
753
|
Nuitka_MarkCoroutineAsNotRunning(coroutine);
|
|
783
754
|
#endif
|
|
784
755
|
} else if (Nuitka_CoroutineWrapper_Check(coroutine->m_yield_from)) {
|
|
@@ -787,7 +758,7 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
787
758
|
|
|
788
759
|
// Transferred exception ownership to "_Nuitka_Coroutine_throw2".
|
|
789
760
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
790
|
-
ret = _Nuitka_Coroutine_throw2(tstate, coro, true,
|
|
761
|
+
ret = _Nuitka_Coroutine_throw2(tstate, coro, true, exception_state);
|
|
791
762
|
Nuitka_MarkCoroutineAsNotRunning(coroutine);
|
|
792
763
|
#if PYTHON_VERSION >= 0x360
|
|
793
764
|
} else if (Nuitka_AsyncgenAsend_Check(coroutine->m_yield_from)) {
|
|
@@ -796,7 +767,7 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
796
767
|
|
|
797
768
|
// Transferred exception ownership to "_Nuitka_AsyncgenAsend_throw2".
|
|
798
769
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
799
|
-
ret = _Nuitka_AsyncgenAsend_throw2(tstate, asyncgen_asend,
|
|
770
|
+
ret = _Nuitka_AsyncgenAsend_throw2(tstate, asyncgen_asend, exception_state);
|
|
800
771
|
Nuitka_MarkCoroutineAsNotRunning(coroutine);
|
|
801
772
|
#endif
|
|
802
773
|
} else {
|
|
@@ -804,9 +775,7 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
804
775
|
if (unlikely(meth == NULL)) {
|
|
805
776
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
|
806
777
|
// Release exception, we are done with it now.
|
|
807
|
-
|
|
808
|
-
Py_XDECREF(exception_value);
|
|
809
|
-
Py_XDECREF(exception_tb);
|
|
778
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
810
779
|
|
|
811
780
|
return NULL;
|
|
812
781
|
}
|
|
@@ -817,7 +786,7 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
817
786
|
goto throw_here;
|
|
818
787
|
}
|
|
819
788
|
|
|
820
|
-
|
|
789
|
+
CHECK_EXCEPTION_STATE(exception_state);
|
|
821
790
|
|
|
822
791
|
#if 0
|
|
823
792
|
// TODO: Add slow mode traces.
|
|
@@ -825,15 +794,13 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
825
794
|
PRINT_NEW_LINE();
|
|
826
795
|
#endif
|
|
827
796
|
Nuitka_MarkCoroutineAsRunning(coroutine);
|
|
828
|
-
ret =
|
|
797
|
+
ret = Nuitka_CallGeneratorThrowMethod(meth, exception_state);
|
|
829
798
|
Nuitka_MarkCoroutineAsNotRunning(coroutine);
|
|
830
799
|
|
|
831
800
|
Py_DECREF(meth);
|
|
832
801
|
|
|
833
802
|
// Release exception, we are done with it now.
|
|
834
|
-
|
|
835
|
-
Py_XDECREF(exception_value);
|
|
836
|
-
Py_XDECREF(exception_tb);
|
|
803
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
837
804
|
}
|
|
838
805
|
|
|
839
806
|
if (unlikely(ret == NULL)) {
|
|
@@ -858,15 +825,22 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
858
825
|
PRINT_NEW_LINE();
|
|
859
826
|
#endif
|
|
860
827
|
|
|
828
|
+
struct Nuitka_ExceptionPreservationItem no_exception_state;
|
|
829
|
+
INIT_ERROR_OCCURRED_STATE(&no_exception_state);
|
|
830
|
+
|
|
861
831
|
// The ownership of val is transferred.
|
|
862
|
-
ret = _Nuitka_Coroutine_send(tstate, coroutine, val, false,
|
|
832
|
+
ret = _Nuitka_Coroutine_send(tstate, coroutine, val, false, &no_exception_state);
|
|
863
833
|
} else {
|
|
864
834
|
#if _DEBUG_COROUTINE
|
|
865
835
|
PRINT_COROUTINE_STATUS("Sending exception value into ourselves", coroutine);
|
|
866
836
|
PRINT_CURRENT_EXCEPTION();
|
|
867
837
|
PRINT_NEW_LINE();
|
|
868
838
|
#endif
|
|
869
|
-
|
|
839
|
+
|
|
840
|
+
struct Nuitka_ExceptionPreservationItem no_exception_state;
|
|
841
|
+
INIT_ERROR_OCCURRED_STATE(&no_exception_state);
|
|
842
|
+
|
|
843
|
+
ret = _Nuitka_Coroutine_send(tstate, coroutine, NULL, false, &no_exception_state);
|
|
870
844
|
}
|
|
871
845
|
|
|
872
846
|
#if _DEBUG_COROUTINE
|
|
@@ -892,15 +866,14 @@ static PyObject *_Nuitka_Coroutine_throw2(PyThreadState *tstate, struct Nuitka_C
|
|
|
892
866
|
throw_here:
|
|
893
867
|
// We continue to have exception ownership here.
|
|
894
868
|
|
|
895
|
-
if (unlikely(
|
|
896
|
-
// Exception was released by
|
|
869
|
+
if (unlikely(_Nuitka_Generator_check_throw(tstate, exception_state) == false)) {
|
|
870
|
+
// Exception was released by _Nuitka_Generator_check_throw already.
|
|
897
871
|
return NULL;
|
|
898
872
|
}
|
|
899
873
|
|
|
900
874
|
if (coroutine->m_status == status_Running) {
|
|
901
875
|
// Transferred exception ownership to "_Nuitka_Coroutine_send".
|
|
902
|
-
PyObject *result =
|
|
903
|
-
_Nuitka_Coroutine_send(tstate, coroutine, NULL, false, exception_type, exception_value, exception_tb);
|
|
876
|
+
PyObject *result = _Nuitka_Coroutine_send(tstate, coroutine, NULL, false, exception_state);
|
|
904
877
|
return result;
|
|
905
878
|
} else if (coroutine->m_status == status_Finished) {
|
|
906
879
|
|
|
@@ -922,30 +895,31 @@ throw_here:
|
|
|
922
895
|
#endif
|
|
923
896
|
);
|
|
924
897
|
|
|
925
|
-
|
|
926
|
-
Py_XDECREF(exception_value);
|
|
927
|
-
Py_XDECREF(exception_tb);
|
|
898
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
928
899
|
|
|
929
900
|
return NULL;
|
|
930
901
|
}
|
|
931
902
|
#endif
|
|
932
903
|
// Passing exception to publication.
|
|
933
|
-
|
|
904
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
934
905
|
|
|
935
906
|
return NULL;
|
|
936
907
|
} else {
|
|
908
|
+
PyTracebackObject *exception_tb = GET_EXCEPTION_STATE_TRACEBACK(exception_state);
|
|
909
|
+
|
|
937
910
|
if (exception_tb == NULL) {
|
|
938
911
|
// TODO: Our compiled objects really need a way to store common
|
|
939
912
|
// stuff in a "shared" part across all instances, and outside of
|
|
940
913
|
// run time, so we could reuse this.
|
|
941
914
|
struct Nuitka_FrameObject *frame =
|
|
942
915
|
MAKE_FUNCTION_FRAME(tstate, coroutine->m_code_object, coroutine->m_module, 0);
|
|
943
|
-
|
|
916
|
+
SET_EXCEPTION_STATE_TRACEBACK(exception_state,
|
|
917
|
+
MAKE_TRACEBACK(frame, coroutine->m_code_object->co_firstlineno));
|
|
944
918
|
Py_DECREF(frame);
|
|
945
919
|
}
|
|
946
920
|
|
|
947
921
|
// Passing exception to publication.
|
|
948
|
-
|
|
922
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
949
923
|
|
|
950
924
|
#if _DEBUG_COROUTINE
|
|
951
925
|
PRINT_COROUTINE_STATUS("Finishing from exception", coroutine);
|
|
@@ -979,14 +953,16 @@ static PyObject *Nuitka_Coroutine_throw(struct Nuitka_CoroutineObject *coroutine
|
|
|
979
953
|
PRINT_NEW_LINE();
|
|
980
954
|
#endif
|
|
981
955
|
|
|
956
|
+
PyThreadState *tstate = PyThreadState_GET();
|
|
957
|
+
|
|
982
958
|
// Handing ownership of exception over, we need not release it ourselves
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
959
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
960
|
+
if (_Nuitka_Generator_make_throw_exception_state(tstate, &exception_state, exception_type, exception_value,
|
|
961
|
+
exception_tb) == false) {
|
|
962
|
+
return NULL;
|
|
963
|
+
}
|
|
986
964
|
|
|
987
|
-
|
|
988
|
-
PyObject *result =
|
|
989
|
-
_Nuitka_Coroutine_throw2(tstate, coroutine, false, exception_type, exception_value, exception_tb);
|
|
965
|
+
PyObject *result = _Nuitka_Coroutine_throw2(tstate, coroutine, false, &exception_state);
|
|
990
966
|
|
|
991
967
|
if (result == NULL) {
|
|
992
968
|
if (HAS_ERROR_OCCURRED(tstate) == false) {
|
|
@@ -1070,7 +1046,11 @@ static PySendResult _Nuitka_Coroutine_am_send(struct Nuitka_CoroutineObject *cor
|
|
|
1070
1046
|
|
|
1071
1047
|
// We need to transfer ownership of the sent value.
|
|
1072
1048
|
Py_INCREF(arg);
|
|
1073
|
-
|
|
1049
|
+
|
|
1050
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
1051
|
+
INIT_ERROR_OCCURRED_STATE(&exception_state);
|
|
1052
|
+
|
|
1053
|
+
PySendResult res = _Nuitka_Coroutine_sendR(tstate, coroutine, arg, false, &exception_state, result);
|
|
1074
1054
|
|
|
1075
1055
|
#if _DEBUG_COROUTINE
|
|
1076
1056
|
PRINT_COROUTINE_STATUS("Leave", coroutine);
|
|
@@ -1088,9 +1068,8 @@ static void Nuitka_Coroutine_tp_finalize(struct Nuitka_CoroutineObject *coroutin
|
|
|
1088
1068
|
|
|
1089
1069
|
PyThreadState *tstate = PyThreadState_GET();
|
|
1090
1070
|
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
FETCH_ERROR_OCCURRED(tstate, &save_exception_type, &save_exception_value, &save_exception_tb);
|
|
1071
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
1072
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1094
1073
|
|
|
1095
1074
|
bool close_result = _Nuitka_Coroutine_close(tstate, coroutine);
|
|
1096
1075
|
|
|
@@ -1099,7 +1078,7 @@ static void Nuitka_Coroutine_tp_finalize(struct Nuitka_CoroutineObject *coroutin
|
|
|
1099
1078
|
}
|
|
1100
1079
|
|
|
1101
1080
|
/* Restore the saved exception if any. */
|
|
1102
|
-
|
|
1081
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1103
1082
|
}
|
|
1104
1083
|
|
|
1105
1084
|
#define MAX_COROUTINE_FREE_LIST_COUNT 100
|
|
@@ -1119,9 +1098,8 @@ static void Nuitka_Coroutine_tp_dealloc(struct Nuitka_CoroutineObject *coroutine
|
|
|
1119
1098
|
PyThreadState *tstate = PyThreadState_GET();
|
|
1120
1099
|
|
|
1121
1100
|
// Save the current exception, if any, we must preserve it.
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
FETCH_ERROR_OCCURRED(tstate, &save_exception_type, &save_exception_value, &save_exception_tb);
|
|
1101
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
1102
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1125
1103
|
|
|
1126
1104
|
#if _DEBUG_COROUTINE
|
|
1127
1105
|
PRINT_COROUTINE_STATUS("Enter", coroutine);
|
|
@@ -1139,7 +1117,7 @@ static void Nuitka_Coroutine_tp_dealloc(struct Nuitka_CoroutineObject *coroutine
|
|
|
1139
1117
|
// Allow for above code to resurrect the coroutine.
|
|
1140
1118
|
Py_SET_REFCNT(coroutine, Py_REFCNT(coroutine) - 1);
|
|
1141
1119
|
if (Py_REFCNT(coroutine) >= 1) {
|
|
1142
|
-
|
|
1120
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1143
1121
|
return;
|
|
1144
1122
|
}
|
|
1145
1123
|
|
|
@@ -1167,7 +1145,7 @@ static void Nuitka_Coroutine_tp_dealloc(struct Nuitka_CoroutineObject *coroutine
|
|
|
1167
1145
|
/* Put the object into free list or release to GC */
|
|
1168
1146
|
releaseToFreeList(free_list_coros, coroutine, MAX_COROUTINE_FREE_LIST_COUNT);
|
|
1169
1147
|
|
|
1170
|
-
|
|
1148
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1171
1149
|
}
|
|
1172
1150
|
|
|
1173
1151
|
// TODO: Set "__doc__" automatically for method clones of compiled types from
|
|
@@ -1673,14 +1651,18 @@ static PyObject *Nuitka_AIterWrapper_iternext(struct Nuitka_AIterWrapper *aw) {
|
|
|
1673
1651
|
SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_StopIteration, aw->aw_aiter);
|
|
1674
1652
|
#else
|
|
1675
1653
|
if (!PyTuple_Check(aw->aw_aiter) && !PyExceptionInstance_Check(aw->aw_aiter)) {
|
|
1676
|
-
|
|
1654
|
+
Py_INCREF(PyExc_StopIteration);
|
|
1655
|
+
Py_INCREF(aw->aw_aiter);
|
|
1656
|
+
|
|
1657
|
+
RESTORE_ERROR_OCCURRED(tstate, PyExc_StopIteration, aw->aw_aiter, NULL);
|
|
1677
1658
|
} else {
|
|
1678
|
-
PyObject *result =
|
|
1659
|
+
PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, PyExc_StopIteration, aw->aw_aiter);
|
|
1679
1660
|
if (unlikely(result == NULL)) {
|
|
1680
1661
|
return NULL;
|
|
1681
1662
|
}
|
|
1682
1663
|
|
|
1683
|
-
|
|
1664
|
+
Py_INCREF(PyExc_StopIteration);
|
|
1665
|
+
RESTORE_ERROR_OCCURRED(tstate, PyExc_StopIteration, result, NULL);
|
|
1684
1666
|
}
|
|
1685
1667
|
#endif
|
|
1686
1668
|
|
|
@@ -419,10 +419,9 @@ static void Nuitka_Frame_tp_dealloc(struct Nuitka_FrameObject *nuitka_frame) {
|
|
|
419
419
|
// Save the current exception, if any, we must to not corrupt it.
|
|
420
420
|
PyThreadState *tstate = PyThreadState_GET();
|
|
421
421
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
RESTORE_ERROR_OCCURRED(tstate, save_exception_type, save_exception_value, save_exception_tb);
|
|
422
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state1;
|
|
423
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state1);
|
|
424
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state1);
|
|
426
425
|
#endif
|
|
427
426
|
|
|
428
427
|
Nuitka_GC_UnTrack(nuitka_frame);
|
|
@@ -463,9 +462,11 @@ static void Nuitka_Frame_tp_dealloc(struct Nuitka_FrameObject *nuitka_frame) {
|
|
|
463
462
|
releaseToFreeList(free_list_frames, nuitka_frame, MAX_FRAME_FREE_LIST_COUNT);
|
|
464
463
|
|
|
465
464
|
#ifndef __NUITKA_NO_ASSERT__
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
465
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state2;
|
|
466
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state2);
|
|
467
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state2);
|
|
468
|
+
|
|
469
|
+
ASSERT_SAME_EXCEPTION_STATE(&saved_exception_state1, &saved_exception_state2);
|
|
469
470
|
#endif
|
|
470
471
|
}
|
|
471
472
|
|
|
@@ -694,21 +695,22 @@ void _initCompiledFrameType(void) {
|
|
|
694
695
|
assert(Nuitka_Frame_Type.tp_methods != PyFrame_Type.tp_methods);
|
|
695
696
|
assert(Nuitka_Frame_Type.tp_members != PyFrame_Type.tp_members);
|
|
696
697
|
assert(Nuitka_Frame_Type.tp_getset != PyFrame_Type.tp_getset);
|
|
697
|
-
|
|
698
|
+
|
|
698
699
|
assert(Nuitka_Frame_Type.tp_descr_get != PyFrame_Type.tp_descr_get || PyFrame_Type.tp_descr_get == NULL);
|
|
699
700
|
|
|
700
701
|
assert(Nuitka_Frame_Type.tp_descr_set != PyFrame_Type.tp_descr_set || PyFrame_Type.tp_descr_set == NULL);
|
|
701
702
|
assert(Nuitka_Frame_Type.tp_dictoffset != PyFrame_Type.tp_dictoffset || PyFrame_Type.tp_dictoffset == 0);
|
|
702
703
|
// TODO: These get changed and into the same thing, not sure what to compare against, project something
|
|
704
|
+
// assert(Nuitka_Frame_Type.tp_dict != PyFrame_Type.tp_dict);
|
|
703
705
|
// assert(Nuitka_Frame_Type.tp_init != PyFrame_Type.tp_init || PyFrame_Type.tp_init == NULL);
|
|
704
706
|
// assert(Nuitka_Frame_Type.tp_alloc != PyFrame_Type.tp_alloc || PyFrame_Type.tp_alloc == NULL);
|
|
705
707
|
// assert(Nuitka_Frame_Type.tp_new != PyFrame_Type.tp_new || PyFrame_Type.tp_new == NULL);
|
|
706
708
|
// assert(Nuitka_Frame_Type.tp_free != PyFrame_Type.tp_free || PyFrame_Type.tp_free == NULL);
|
|
709
|
+
// assert(Nuitka_Frame_Type.tp_weaklist != PyFrame_Type.tp_weaklist);
|
|
707
710
|
assert(Nuitka_Frame_Type.tp_bases != PyFrame_Type.tp_bases);
|
|
708
711
|
assert(Nuitka_Frame_Type.tp_mro != PyFrame_Type.tp_mro);
|
|
709
712
|
assert(Nuitka_Frame_Type.tp_cache != PyFrame_Type.tp_cache || PyFrame_Type.tp_cache == NULL);
|
|
710
713
|
assert(Nuitka_Frame_Type.tp_subclasses != PyFrame_Type.tp_subclasses || PyFrame_Type.tp_cache == NULL);
|
|
711
|
-
assert(Nuitka_Frame_Type.tp_weaklist != PyFrame_Type.tp_weaklist);
|
|
712
714
|
assert(Nuitka_Frame_Type.tp_del != PyFrame_Type.tp_del || PyFrame_Type.tp_del == NULL);
|
|
713
715
|
#if PYTHON_VERSION >= 0x340
|
|
714
716
|
assert(Nuitka_Frame_Type.tp_finalize != PyFrame_Type.tp_finalize || PyFrame_Type.tp_finalize == NULL);
|
|
@@ -1079,7 +1081,8 @@ void dumpFrameStack(void) {
|
|
|
1079
1081
|
PyObject *saved_exception_type, *saved_exception_value;
|
|
1080
1082
|
PyTracebackObject *saved_exception_tb;
|
|
1081
1083
|
|
|
1082
|
-
|
|
1084
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
1085
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1083
1086
|
|
|
1084
1087
|
int total = 0;
|
|
1085
1088
|
|
|
@@ -1133,7 +1136,7 @@ void dumpFrameStack(void) {
|
|
|
1133
1136
|
|
|
1134
1137
|
PRINT_STRING(">---------<\n");
|
|
1135
1138
|
|
|
1136
|
-
|
|
1139
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1137
1140
|
}
|
|
1138
1141
|
|
|
1139
1142
|
static void PRINT_UNCOMPILED_FRAME(char const *prefix, PyFrameObject *frame) {
|
|
@@ -517,6 +517,29 @@ static PyObject *Nuitka_Function_get_builtins(struct Nuitka_FunctionObject *func
|
|
|
517
517
|
}
|
|
518
518
|
#endif
|
|
519
519
|
|
|
520
|
+
#if PYTHON_VERSION >= 0x3c0
|
|
521
|
+
static int Nuitka_Function_set_type_params(struct Nuitka_FunctionObject *function, PyObject *value) {
|
|
522
|
+
CHECK_OBJECT((PyObject *)function);
|
|
523
|
+
assert(Nuitka_Function_Check((PyObject *)function));
|
|
524
|
+
assert(_PyObject_GC_IS_TRACKED(function));
|
|
525
|
+
|
|
526
|
+
PyThreadState *tstate = PyThreadState_GET();
|
|
527
|
+
|
|
528
|
+
SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "readonly attribute");
|
|
529
|
+
return -1;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
static PyObject *Nuitka_Function_get_type_params(struct Nuitka_FunctionObject *function) {
|
|
533
|
+
CHECK_OBJECT((PyObject *)function);
|
|
534
|
+
assert(Nuitka_Function_Check((PyObject *)function));
|
|
535
|
+
assert(_PyObject_GC_IS_TRACKED(function));
|
|
536
|
+
|
|
537
|
+
// TODO: Probably not needed anymore?
|
|
538
|
+
Py_INCREF(const_tuple_empty);
|
|
539
|
+
return const_tuple_empty;
|
|
540
|
+
}
|
|
541
|
+
#endif
|
|
542
|
+
|
|
520
543
|
static int Nuitka_Function_set_module(struct Nuitka_FunctionObject *function, PyObject *value) {
|
|
521
544
|
CHECK_OBJECT((PyObject *)function);
|
|
522
545
|
assert(Nuitka_Function_Check((PyObject *)function));
|
|
@@ -595,6 +618,9 @@ static PyGetSetDef Nuitka_Function_getset[] = {
|
|
|
595
618
|
#endif
|
|
596
619
|
#if PYTHON_VERSION >= 0x3a0
|
|
597
620
|
{(char *)"__builtins__", (getter)Nuitka_Function_get_builtins, (setter)Nuitka_Function_set_builtins, NULL},
|
|
621
|
+
#endif
|
|
622
|
+
#if PYTHON_VERSION >= 0x3c0
|
|
623
|
+
{(char *)"__type_params__", (getter)Nuitka_Function_get_type_params, (setter)Nuitka_Function_set_type_params, NULL},
|
|
598
624
|
#endif
|
|
599
625
|
{(char *)"__compiled__", (getter)Nuitka_Function_get_compiled, (setter)Nuitka_Function_set_compiled, NULL},
|
|
600
626
|
{(char *)"__compiled_constant__", (getter)Nuitka_Function_get_compiled_constant,
|
|
@@ -687,10 +713,9 @@ static void Nuitka_Function_tp_dealloc(struct Nuitka_FunctionObject *function) {
|
|
|
687
713
|
PyThreadState *tstate = PyThreadState_GET();
|
|
688
714
|
|
|
689
715
|
// Save the current exception, if any, we must to not corrupt it.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
RESTORE_ERROR_OCCURRED(tstate, save_exception_type, save_exception_value, save_exception_tb);
|
|
716
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state1;
|
|
717
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state1);
|
|
718
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state1);
|
|
694
719
|
#endif
|
|
695
720
|
assert(_PyObject_GC_IS_TRACKED(function));
|
|
696
721
|
Nuitka_GC_UnTrack(function);
|
|
@@ -727,9 +752,11 @@ static void Nuitka_Function_tp_dealloc(struct Nuitka_FunctionObject *function) {
|
|
|
727
752
|
releaseToFreeList(free_list_functions, function, MAX_FUNCTION_FREE_LIST_COUNT);
|
|
728
753
|
|
|
729
754
|
#ifndef __NUITKA_NO_ASSERT__
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
755
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state2;
|
|
756
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state2);
|
|
757
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state2);
|
|
758
|
+
|
|
759
|
+
ASSERT_SAME_EXCEPTION_STATE(&saved_exception_state1, &saved_exception_state2);
|
|
733
760
|
#endif
|
|
734
761
|
}
|
|
735
762
|
|