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
|
@@ -280,28 +280,24 @@ static PyObject *Nuitka_YieldFromAsyncgenInitial(PyThreadState *tstate, struct N
|
|
|
280
280
|
static PyObject *Nuitka_AsyncgenValueWrapper_New(PyObject *value);
|
|
281
281
|
|
|
282
282
|
static PySendResult _Nuitka_Asyncgen_sendR(PyThreadState *tstate, struct Nuitka_AsyncgenObject *asyncgen,
|
|
283
|
-
PyObject *value, bool closing,
|
|
284
|
-
|
|
283
|
+
PyObject *value, bool closing,
|
|
284
|
+
struct Nuitka_ExceptionPreservationItem *exception_state,
|
|
285
285
|
PyObject **result) {
|
|
286
286
|
CHECK_OBJECT(asyncgen);
|
|
287
287
|
assert(Nuitka_Asyncgen_Check((PyObject *)asyncgen));
|
|
288
288
|
CHECK_OBJECT_X(value);
|
|
289
|
-
|
|
290
|
-
CHECK_OBJECT_X(exception_value);
|
|
291
|
-
CHECK_OBJECT_X(exception_tb);
|
|
289
|
+
CHECK_EXCEPTION_STATE_X(exception_state);
|
|
292
290
|
|
|
293
291
|
#if _DEBUG_ASYNCGEN
|
|
294
292
|
PRINT_ASYNCGEN_STATUS("Enter", asyncgen);
|
|
295
293
|
PRINT_COROUTINE_VALUE("value", value);
|
|
296
|
-
|
|
294
|
+
PRINT_EXCEPTION_STATE(exception_state);
|
|
297
295
|
PRINT_CURRENT_EXCEPTION();
|
|
298
296
|
PRINT_NEW_LINE();
|
|
299
297
|
#endif
|
|
300
298
|
|
|
301
299
|
if (value != NULL) {
|
|
302
|
-
|
|
303
|
-
assert(exception_value == NULL);
|
|
304
|
-
assert(exception_tb == NULL);
|
|
300
|
+
ASSERT_EMPTY_EXCEPTION_STATE(exception_state);
|
|
305
301
|
}
|
|
306
302
|
|
|
307
303
|
if (asyncgen->m_status == status_Unused && value != NULL && value != Py_None) {
|
|
@@ -342,11 +338,11 @@ static PySendResult _Nuitka_Asyncgen_sendR(PyThreadState *tstate, struct Nuitka_
|
|
|
342
338
|
asyncgen->m_running = true;
|
|
343
339
|
|
|
344
340
|
// Check for thrown exception, and publish it.
|
|
345
|
-
if (unlikely(
|
|
341
|
+
if (unlikely(HAS_EXCEPTION_STATE(exception_state))) {
|
|
346
342
|
assert(value == NULL);
|
|
347
343
|
|
|
348
344
|
// Transfer exception ownership to published.
|
|
349
|
-
|
|
345
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
350
346
|
}
|
|
351
347
|
|
|
352
348
|
if (asyncgen->m_frame) {
|
|
@@ -426,35 +422,14 @@ static PySendResult _Nuitka_Asyncgen_sendR(PyThreadState *tstate, struct Nuitka_
|
|
|
426
422
|
PyObject *error_occurred = GET_ERROR_OCCURRED(tstate);
|
|
427
423
|
|
|
428
424
|
if (error_occurred == PyExc_StopIteration || error_occurred == PyExc_StopAsyncIteration) {
|
|
429
|
-
|
|
430
|
-
PyTracebackObject *saved_exception_tb;
|
|
431
|
-
|
|
432
|
-
// TODO: For Python3.12, this kind of code ought to use tstate methods entirely.
|
|
433
|
-
FETCH_ERROR_OCCURRED(tstate, &saved_exception_type, &saved_exception_value, &saved_exception_tb);
|
|
434
|
-
NORMALIZE_EXCEPTION(tstate, &saved_exception_type, &saved_exception_value, &saved_exception_tb);
|
|
435
|
-
|
|
425
|
+
char const *message;
|
|
436
426
|
if (error_occurred == PyExc_StopIteration) {
|
|
437
|
-
|
|
427
|
+
message = "async generator raised StopIteration";
|
|
438
428
|
} else {
|
|
439
|
-
|
|
440
|
-
"async generator raised StopAsyncIteration");
|
|
429
|
+
message = "async generator raised StopAsyncIteration";
|
|
441
430
|
}
|
|
442
431
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
RAISE_EXCEPTION_WITH_CAUSE(tstate, &exception_type, &exception_value, &exception_tb,
|
|
446
|
-
saved_exception_value);
|
|
447
|
-
|
|
448
|
-
CHECK_OBJECT(exception_value);
|
|
449
|
-
CHECK_OBJECT(saved_exception_value);
|
|
450
|
-
|
|
451
|
-
Py_INCREF(saved_exception_value);
|
|
452
|
-
PyException_SetContext(exception_value, saved_exception_value);
|
|
453
|
-
|
|
454
|
-
Py_DECREF(saved_exception_type);
|
|
455
|
-
Py_XDECREF(saved_exception_tb);
|
|
456
|
-
|
|
457
|
-
RESTORE_ERROR_OCCURRED(tstate, exception_type, exception_value, exception_tb);
|
|
432
|
+
RAISE_RUNTIME_ERROR_RAISED_STOP_ITERATION(tstate, message);
|
|
458
433
|
return PYGEN_ERROR;
|
|
459
434
|
}
|
|
460
435
|
|
|
@@ -476,21 +451,17 @@ static PySendResult _Nuitka_Asyncgen_sendR(PyThreadState *tstate, struct Nuitka_
|
|
|
476
451
|
Py_XDECREF(value);
|
|
477
452
|
|
|
478
453
|
// Release exception if any, we are finished with it and will raise another.
|
|
479
|
-
|
|
480
|
-
Py_XDECREF(exception_value);
|
|
481
|
-
Py_XDECREF(exception_tb);
|
|
454
|
+
RELEASE_ERROR_OCCURRED_STATE_X(exception_state);
|
|
482
455
|
|
|
483
456
|
return PYGEN_RETURN;
|
|
484
457
|
}
|
|
485
458
|
}
|
|
486
459
|
|
|
487
460
|
static PyObject *_Nuitka_Asyncgen_send(PyThreadState *tstate, struct Nuitka_AsyncgenObject *asyncgen, PyObject *value,
|
|
488
|
-
bool closing,
|
|
489
|
-
PyTracebackObject *exception_tb) {
|
|
461
|
+
bool closing, struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
490
462
|
|
|
491
463
|
PyObject *result;
|
|
492
|
-
PySendResult res = _Nuitka_Asyncgen_sendR(tstate, asyncgen, value, closing,
|
|
493
|
-
exception_tb, &result);
|
|
464
|
+
PySendResult res = _Nuitka_Asyncgen_sendR(tstate, asyncgen, value, closing, exception_state, &result);
|
|
494
465
|
|
|
495
466
|
switch (res) {
|
|
496
467
|
case PYGEN_RETURN:
|
|
@@ -513,9 +484,10 @@ static bool _Nuitka_Asyncgen_close(PyThreadState *tstate, struct Nuitka_Asyncgen
|
|
|
513
484
|
CHECK_OBJECT(asyncgen);
|
|
514
485
|
|
|
515
486
|
if (asyncgen->m_status == status_Running) {
|
|
516
|
-
|
|
487
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
488
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_ARGS(tstate, &exception_state, PyExc_GeneratorExit, NULL, NULL);
|
|
517
489
|
|
|
518
|
-
PyObject *result = _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, true,
|
|
490
|
+
PyObject *result = _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, true, &exception_state);
|
|
519
491
|
|
|
520
492
|
if (unlikely(result)) {
|
|
521
493
|
Py_DECREF(result);
|
|
@@ -530,8 +502,8 @@ static bool _Nuitka_Asyncgen_close(PyThreadState *tstate, struct Nuitka_Asyncgen
|
|
|
530
502
|
return true;
|
|
531
503
|
}
|
|
532
504
|
|
|
533
|
-
static bool
|
|
534
|
-
|
|
505
|
+
static bool _Nuitka_Generator_check_throw(PyThreadState *tstate,
|
|
506
|
+
struct Nuitka_ExceptionPreservationItem *exception_state);
|
|
535
507
|
|
|
536
508
|
// This function is called when yielding to a asyncgen through "_Nuitka_YieldFromPassExceptionTo"
|
|
537
509
|
// and potentially wrapper objects used by generators, or by the throw method itself.
|
|
@@ -540,25 +512,23 @@ static bool _Nuitka_Generator_check_throw2(PyThreadState *tstate, PyObject **exc
|
|
|
540
512
|
// value of exception_type will not be NULL, but the actual exception will not necessarily
|
|
541
513
|
// be normalized.
|
|
542
514
|
static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_AsyncgenObject *asyncgen,
|
|
543
|
-
bool close_on_genexit,
|
|
544
|
-
|
|
515
|
+
bool close_on_genexit,
|
|
516
|
+
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
545
517
|
CHECK_OBJECT(asyncgen);
|
|
546
518
|
assert(Nuitka_Asyncgen_Check((PyObject *)asyncgen));
|
|
547
|
-
|
|
548
|
-
CHECK_OBJECT_X(exception_value);
|
|
549
|
-
CHECK_OBJECT_X(exception_tb);
|
|
519
|
+
CHECK_EXCEPTION_STATE(exception_state);
|
|
550
520
|
|
|
551
521
|
#if _DEBUG_ASYNCGEN
|
|
552
522
|
PRINT_ASYNCGEN_STATUS("Enter", asyncgen);
|
|
553
523
|
PRINT_COROUTINE_VALUE("yield_from", asyncgen->m_yield_from);
|
|
554
|
-
|
|
524
|
+
PRINT_EXCEPTION_STATE(exception_state);
|
|
555
525
|
PRINT_NEW_LINE();
|
|
556
526
|
#endif
|
|
557
527
|
|
|
558
528
|
if (asyncgen->m_yield_from != NULL) {
|
|
559
529
|
// TODO: This check is not done for coroutines, correct?
|
|
560
530
|
if (close_on_genexit) {
|
|
561
|
-
if (
|
|
531
|
+
if (EXCEPTION_STATE_MATCH_BOOL_SINGLE(tstate, exception_state, PyExc_GeneratorExit)) {
|
|
562
532
|
// Asynchronous generators need to close the yield_from.
|
|
563
533
|
Nuitka_MarkAsyncgenAsRunning(asyncgen);
|
|
564
534
|
bool res = Nuitka_gen_close_iter(tstate, asyncgen->m_yield_from);
|
|
@@ -566,15 +536,11 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
566
536
|
|
|
567
537
|
if (res == false) {
|
|
568
538
|
// Release exception, we are done with it now and pick up the new one.
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
Py_XDECREF(exception_tb);
|
|
572
|
-
|
|
573
|
-
FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
|
|
539
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
540
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
574
541
|
}
|
|
575
542
|
|
|
576
|
-
return _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, false,
|
|
577
|
-
exception_tb);
|
|
543
|
+
return _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, false, exception_state);
|
|
578
544
|
}
|
|
579
545
|
}
|
|
580
546
|
|
|
@@ -592,7 +558,7 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
592
558
|
|
|
593
559
|
// Transferred exception ownership to "Nuitka_UncompiledGenerator_throw".
|
|
594
560
|
Nuitka_MarkAsyncgenAsRunning(asyncgen);
|
|
595
|
-
ret = Nuitka_UncompiledGenerator_throw(tstate, gen, 1,
|
|
561
|
+
ret = Nuitka_UncompiledGenerator_throw(tstate, gen, 1, exception_state);
|
|
596
562
|
Nuitka_MarkAsyncgenAsNotRunning(asyncgen);
|
|
597
563
|
} else
|
|
598
564
|
#endif
|
|
@@ -600,13 +566,13 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
600
566
|
struct Nuitka_GeneratorObject *gen = ((struct Nuitka_GeneratorObject *)asyncgen->m_yield_from);
|
|
601
567
|
// Transferred exception ownership to "_Nuitka_Generator_throw2".
|
|
602
568
|
Nuitka_MarkAsyncgenAsRunning(asyncgen);
|
|
603
|
-
ret = _Nuitka_Generator_throw2(tstate, gen,
|
|
569
|
+
ret = _Nuitka_Generator_throw2(tstate, gen, exception_state);
|
|
604
570
|
Nuitka_MarkAsyncgenAsNotRunning(asyncgen);
|
|
605
571
|
} else if (Nuitka_Coroutine_Check(asyncgen->m_yield_from)) {
|
|
606
572
|
struct Nuitka_CoroutineObject *coro = ((struct Nuitka_CoroutineObject *)asyncgen->m_yield_from);
|
|
607
573
|
// Transferred exception ownership to "_Nuitka_Coroutine_throw2".
|
|
608
574
|
Nuitka_MarkAsyncgenAsRunning(asyncgen);
|
|
609
|
-
ret = _Nuitka_Coroutine_throw2(tstate, coro, true,
|
|
575
|
+
ret = _Nuitka_Coroutine_throw2(tstate, coro, true, exception_state);
|
|
610
576
|
Nuitka_MarkAsyncgenAsNotRunning(asyncgen);
|
|
611
577
|
} else if (Nuitka_CoroutineWrapper_Check(asyncgen->m_yield_from)) {
|
|
612
578
|
struct Nuitka_CoroutineObject *coro =
|
|
@@ -614,7 +580,7 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
614
580
|
|
|
615
581
|
// Transferred exception ownership to "_Nuitka_Coroutine_throw2".
|
|
616
582
|
Nuitka_MarkAsyncgenAsRunning(asyncgen);
|
|
617
|
-
ret = _Nuitka_Coroutine_throw2(tstate, coro, true,
|
|
583
|
+
ret = _Nuitka_Coroutine_throw2(tstate, coro, true, exception_state);
|
|
618
584
|
Nuitka_MarkAsyncgenAsNotRunning(asyncgen);
|
|
619
585
|
} else if (Nuitka_AsyncgenAsend_Check(asyncgen->m_yield_from)) {
|
|
620
586
|
struct Nuitka_AsyncgenAsendObject *asyncgen_asend =
|
|
@@ -622,16 +588,15 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
622
588
|
|
|
623
589
|
// Transferred exception ownership to "_Nuitka_AsyncgenAsend_throw2".
|
|
624
590
|
Nuitka_MarkAsyncgenAsRunning(asyncgen);
|
|
625
|
-
ret = _Nuitka_AsyncgenAsend_throw2(tstate, asyncgen_asend,
|
|
591
|
+
ret = _Nuitka_AsyncgenAsend_throw2(tstate, asyncgen_asend, exception_state);
|
|
626
592
|
Nuitka_MarkAsyncgenAsNotRunning(asyncgen);
|
|
627
593
|
} else {
|
|
628
594
|
PyObject *meth = PyObject_GetAttr(asyncgen->m_yield_from, const_str_plain_throw);
|
|
595
|
+
|
|
629
596
|
if (unlikely(meth == NULL)) {
|
|
630
597
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
|
631
598
|
// Release exception, we are done with it now.
|
|
632
|
-
|
|
633
|
-
Py_XDECREF(exception_value);
|
|
634
|
-
Py_XDECREF(exception_tb);
|
|
599
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
635
600
|
|
|
636
601
|
return NULL;
|
|
637
602
|
}
|
|
@@ -642,7 +607,7 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
642
607
|
goto throw_here;
|
|
643
608
|
}
|
|
644
609
|
|
|
645
|
-
|
|
610
|
+
CHECK_EXCEPTION_STATE(exception_state);
|
|
646
611
|
|
|
647
612
|
#if 0
|
|
648
613
|
// TODO: Add slow mode traces.
|
|
@@ -651,15 +616,13 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
651
616
|
#endif
|
|
652
617
|
|
|
653
618
|
Nuitka_MarkAsyncgenAsRunning(asyncgen);
|
|
654
|
-
ret =
|
|
619
|
+
ret = Nuitka_CallGeneratorThrowMethod(meth, exception_state);
|
|
655
620
|
Nuitka_MarkAsyncgenAsNotRunning(asyncgen);
|
|
656
621
|
|
|
657
622
|
Py_DECREF(meth);
|
|
658
623
|
|
|
659
624
|
// Release exception, we are done with it now.
|
|
660
|
-
|
|
661
|
-
Py_XDECREF(exception_value);
|
|
662
|
-
Py_XDECREF(exception_tb);
|
|
625
|
+
RELEASE_ERROR_OCCURRED_STATE(exception_state);
|
|
663
626
|
}
|
|
664
627
|
|
|
665
628
|
if (unlikely(ret == NULL)) {
|
|
@@ -687,7 +650,10 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
687
650
|
PRINT_NEW_LINE();
|
|
688
651
|
#endif
|
|
689
652
|
|
|
690
|
-
|
|
653
|
+
struct Nuitka_ExceptionPreservationItem no_exception_state;
|
|
654
|
+
INIT_ERROR_OCCURRED_STATE(&no_exception_state);
|
|
655
|
+
|
|
656
|
+
ret = _Nuitka_Asyncgen_send(tstate, asyncgen, val, false, &no_exception_state);
|
|
691
657
|
} else {
|
|
692
658
|
#if _DEBUG_ASYNCGEN
|
|
693
659
|
PRINT_ASYNCGEN_STATUS("Sending exception value into ourselves", asyncgen);
|
|
@@ -695,7 +661,11 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
|
|
|
695
661
|
PRINT_CURRENT_EXCEPTION();
|
|
696
662
|
PRINT_NEW_LINE();
|
|
697
663
|
#endif
|
|
698
|
-
|
|
664
|
+
|
|
665
|
+
struct Nuitka_ExceptionPreservationItem no_exception_state;
|
|
666
|
+
INIT_ERROR_OCCURRED_STATE(&no_exception_state);
|
|
667
|
+
|
|
668
|
+
ret = _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, false, &no_exception_state);
|
|
699
669
|
}
|
|
700
670
|
|
|
701
671
|
#if _DEBUG_ASYNCGEN
|
|
@@ -722,30 +692,33 @@ throw_here:
|
|
|
722
692
|
PRINT_ASYNCGEN_STATUS("Need to throw into itself", asyncgen);
|
|
723
693
|
#endif
|
|
724
694
|
|
|
725
|
-
if (unlikely(
|
|
726
|
-
// Exception was released by
|
|
695
|
+
if (unlikely(_Nuitka_Generator_check_throw(tstate, exception_state) == false)) {
|
|
696
|
+
// Exception was released by _Nuitka_Generator_check_throw already.
|
|
727
697
|
return NULL;
|
|
728
698
|
}
|
|
729
699
|
|
|
730
700
|
PyObject *result;
|
|
731
701
|
|
|
732
702
|
if (asyncgen->m_status == status_Running) {
|
|
733
|
-
result = _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, false,
|
|
703
|
+
result = _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, false, exception_state);
|
|
734
704
|
} else if (asyncgen->m_status == status_Finished) {
|
|
735
|
-
|
|
705
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
736
706
|
result = NULL;
|
|
737
707
|
} else {
|
|
708
|
+
PyTracebackObject *exception_tb = GET_EXCEPTION_STATE_TRACEBACK(exception_state);
|
|
709
|
+
|
|
738
710
|
if (exception_tb == NULL) {
|
|
739
711
|
// TODO: Our compiled objects really need a way to store common
|
|
740
712
|
// stuff in a "shared" part across all instances, and outside of
|
|
741
713
|
// run time, so we could reuse this.
|
|
742
714
|
struct Nuitka_FrameObject *frame =
|
|
743
715
|
MAKE_FUNCTION_FRAME(tstate, asyncgen->m_code_object, asyncgen->m_module, 0);
|
|
744
|
-
|
|
716
|
+
SET_EXCEPTION_STATE_TRACEBACK(exception_state,
|
|
717
|
+
MAKE_TRACEBACK(frame, asyncgen->m_code_object->co_firstlineno));
|
|
745
718
|
Py_DECREF(frame);
|
|
746
719
|
}
|
|
747
720
|
|
|
748
|
-
|
|
721
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, exception_state);
|
|
749
722
|
|
|
750
723
|
#if _DEBUG_ASYNCGEN
|
|
751
724
|
PRINT_ASYNCGEN_STATUS("Finishing from exception", asyncgen);
|
|
@@ -789,11 +762,13 @@ static PyObject *Nuitka_Asyncgen_throw(PyThreadState *tstate, struct Nuitka_Asyn
|
|
|
789
762
|
#endif
|
|
790
763
|
|
|
791
764
|
// Handing ownership of exception over, we need not release it ourselves
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
765
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
766
|
+
if (_Nuitka_Generator_make_throw_exception_state(tstate, &exception_state, exception_type, exception_value,
|
|
767
|
+
exception_tb) == false) {
|
|
768
|
+
return NULL;
|
|
769
|
+
}
|
|
795
770
|
|
|
796
|
-
PyObject *result = _Nuitka_Asyncgen_throw2(tstate, asyncgen, false,
|
|
771
|
+
PyObject *result = _Nuitka_Asyncgen_throw2(tstate, asyncgen, false, &exception_state);
|
|
797
772
|
|
|
798
773
|
if (result == NULL) {
|
|
799
774
|
if (HAS_ERROR_OCCURRED(tstate) == false) {
|
|
@@ -807,9 +782,7 @@ static PyObject *Nuitka_Asyncgen_throw(PyThreadState *tstate, struct Nuitka_Asyn
|
|
|
807
782
|
PRINT_CURRENT_EXCEPTION();
|
|
808
783
|
#endif
|
|
809
784
|
|
|
810
|
-
|
|
811
|
-
CHECK_OBJECT_X(exception_value);
|
|
812
|
-
CHECK_OBJECT_X(exception_tb);
|
|
785
|
+
CHECK_EXCEPTION_STATE(&exception_state);
|
|
813
786
|
|
|
814
787
|
return result;
|
|
815
788
|
}
|
|
@@ -922,7 +895,10 @@ static PySendResult _Nuitka_Asyncgen_am_send(struct Nuitka_AsyncgenObject *async
|
|
|
922
895
|
|
|
923
896
|
PyThreadState *tstate = PyThreadState_GET();
|
|
924
897
|
|
|
925
|
-
|
|
898
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
899
|
+
INIT_ERROR_OCCURRED_STATE(&exception_state);
|
|
900
|
+
|
|
901
|
+
PySendResult res = _Nuitka_Asyncgen_sendR(tstate, asyncgen, arg, false, &exception_state, result);
|
|
926
902
|
|
|
927
903
|
#if _DEBUG_ASYNCGEN
|
|
928
904
|
PRINT_ASYNCGEN_STATUS("Leave", asyncgen);
|
|
@@ -940,9 +916,8 @@ static void Nuitka_Asyncgen_tp_finalize(struct Nuitka_AsyncgenObject *asyncgen)
|
|
|
940
916
|
|
|
941
917
|
PyThreadState *tstate = PyThreadState_GET();
|
|
942
918
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
FETCH_ERROR_OCCURRED(tstate, &save_exception_type, &save_exception_value, &save_exception_tb);
|
|
919
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
920
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
946
921
|
|
|
947
922
|
bool close_result = _Nuitka_Asyncgen_close(tstate, asyncgen);
|
|
948
923
|
|
|
@@ -951,7 +926,7 @@ static void Nuitka_Asyncgen_tp_finalize(struct Nuitka_AsyncgenObject *asyncgen)
|
|
|
951
926
|
}
|
|
952
927
|
|
|
953
928
|
/* Restore the saved exception if any. */
|
|
954
|
-
|
|
929
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
955
930
|
}
|
|
956
931
|
|
|
957
932
|
#define MAX_ASYNCGEN_FREE_LIST_COUNT 100
|
|
@@ -972,13 +947,12 @@ static void Nuitka_Asyncgen_tp_dealloc(struct Nuitka_AsyncgenObject *asyncgen) {
|
|
|
972
947
|
PyThreadState *tstate = PyThreadState_GET();
|
|
973
948
|
|
|
974
949
|
// Save the current exception, if any, we must preserve it.
|
|
975
|
-
|
|
976
|
-
PyTracebackObject *save_exception_tb;
|
|
950
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
977
951
|
|
|
978
952
|
PyObject *finalizer = asyncgen->m_finalizer;
|
|
979
953
|
if (finalizer != NULL && asyncgen->m_closed == false) {
|
|
980
|
-
|
|
981
|
-
|
|
954
|
+
// Save the current exception, if any.
|
|
955
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
982
956
|
|
|
983
957
|
PyObject *res = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, finalizer, (PyObject *)asyncgen);
|
|
984
958
|
|
|
@@ -988,11 +962,11 @@ static void Nuitka_Asyncgen_tp_dealloc(struct Nuitka_AsyncgenObject *asyncgen) {
|
|
|
988
962
|
Py_DECREF(res);
|
|
989
963
|
}
|
|
990
964
|
|
|
991
|
-
|
|
965
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
992
966
|
return;
|
|
993
967
|
}
|
|
994
968
|
|
|
995
|
-
|
|
969
|
+
FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
996
970
|
|
|
997
971
|
bool close_result = _Nuitka_Asyncgen_close(tstate, asyncgen);
|
|
998
972
|
|
|
@@ -1031,7 +1005,7 @@ static void Nuitka_Asyncgen_tp_dealloc(struct Nuitka_AsyncgenObject *asyncgen) {
|
|
|
1031
1005
|
/* Put the object into free list or release to GC */
|
|
1032
1006
|
releaseToFreeList(free_list_asyncgens, asyncgen, MAX_ASYNCGEN_FREE_LIST_COUNT);
|
|
1033
1007
|
|
|
1034
|
-
|
|
1008
|
+
RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
|
|
1035
1009
|
}
|
|
1036
1010
|
|
|
1037
1011
|
static PyObject *Nuitka_Asyncgen_tp_repr(struct Nuitka_AsyncgenObject *asyncgen) {
|
|
@@ -1404,6 +1378,8 @@ static PyObject *_Nuitka_Asyncgen_unwrap_value(PyThreadState *tstate, struct Nui
|
|
|
1404
1378
|
|
|
1405
1379
|
if (_PyAsyncGenWrappedValue_CheckExact(result)) {
|
|
1406
1380
|
/* async yield */
|
|
1381
|
+
// TODO: Unify with coroutines and generators, who do things manually with a shared
|
|
1382
|
+
// helper, "Nuitka_SetStopIterationValue" should be usable instead.
|
|
1407
1383
|
_PyGen_SetStopIterationValue(((struct _PyAsyncGenWrappedValue *)result)->agw_val);
|
|
1408
1384
|
|
|
1409
1385
|
Py_DECREF(result);
|
|
@@ -1515,7 +1491,11 @@ static PyObject *Nuitka_AsyncgenAsend_send(struct Nuitka_AsyncgenAsendObject *as
|
|
|
1515
1491
|
#endif
|
|
1516
1492
|
|
|
1517
1493
|
Py_INCREF(arg);
|
|
1518
|
-
|
|
1494
|
+
|
|
1495
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
1496
|
+
INIT_ERROR_OCCURRED_STATE(&exception_state);
|
|
1497
|
+
|
|
1498
|
+
PyObject *result = _Nuitka_Asyncgen_send(tstate, asyncgen_asend->m_gen, arg, false, &exception_state);
|
|
1519
1499
|
|
|
1520
1500
|
#if _DEBUG_ASYNCGEN
|
|
1521
1501
|
PRINT_STRING("Returned from _Nuitka_Asyncgen_send\n");
|
|
@@ -1610,11 +1590,10 @@ static PyObject *Nuitka_AsyncgenAsend_throw(struct Nuitka_AsyncgenAsendObject *a
|
|
|
1610
1590
|
}
|
|
1611
1591
|
|
|
1612
1592
|
static PyObject *_Nuitka_AsyncgenAsend_throw2(PyThreadState *tstate, struct Nuitka_AsyncgenAsendObject *asyncgen_asend,
|
|
1613
|
-
|
|
1614
|
-
PyTracebackObject *exception_tb) {
|
|
1593
|
+
struct Nuitka_ExceptionPreservationItem *exception_state) {
|
|
1615
1594
|
#if _DEBUG_ASYNCGEN
|
|
1616
1595
|
PRINT_ASYNCGENASEND_STATUS("Enter", asyncgen_asend);
|
|
1617
|
-
|
|
1596
|
+
PRINT_EXCEPTION_STATE(exception_state);
|
|
1618
1597
|
PRINT_CURRENT_EXCEPTION();
|
|
1619
1598
|
PRINT_NEW_LINE();
|
|
1620
1599
|
#endif
|
|
@@ -1624,8 +1603,7 @@ static PyObject *_Nuitka_AsyncgenAsend_throw2(PyThreadState *tstate, struct Nuit
|
|
|
1624
1603
|
return NULL;
|
|
1625
1604
|
}
|
|
1626
1605
|
|
|
1627
|
-
PyObject *result =
|
|
1628
|
-
_Nuitka_Asyncgen_throw2(tstate, asyncgen_asend->m_gen, false, exception_type, exception_value, exception_tb);
|
|
1606
|
+
PyObject *result = _Nuitka_Asyncgen_throw2(tstate, asyncgen_asend->m_gen, false, exception_state);
|
|
1629
1607
|
|
|
1630
1608
|
// TODO: This might not be all that necessary as this is not directly outside facing,
|
|
1631
1609
|
// but there were tests failing when this was not the specific value.
|
|
@@ -1899,10 +1877,12 @@ static PyObject *Nuitka_AsyncgenAthrow_send(struct Nuitka_AsyncgenAthrowObject *
|
|
|
1899
1877
|
if (asyncgen_athrow->m_args == NULL) {
|
|
1900
1878
|
asyncgen->m_closed = true;
|
|
1901
1879
|
|
|
1902
|
-
|
|
1880
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
1881
|
+
SET_EXCEPTION_PRESERVATION_STATE_FROM_ARGS(tstate, &exception_state, PyExc_GeneratorExit, NULL, NULL);
|
|
1882
|
+
|
|
1903
1883
|
retval = _Nuitka_Asyncgen_throw2(tstate, asyncgen,
|
|
1904
1884
|
1, /* Do not close generator when PyExc_GeneratorExit is passed */
|
|
1905
|
-
|
|
1885
|
+
&exception_state);
|
|
1906
1886
|
|
|
1907
1887
|
if (retval) {
|
|
1908
1888
|
if (_PyAsyncGenWrappedValue_CheckExact(retval) || Nuitka_AsyncgenWrappedValue_CheckExact(retval)) {
|
|
@@ -1929,13 +1909,15 @@ static PyObject *Nuitka_AsyncgenAthrow_send(struct Nuitka_AsyncgenAthrowObject *
|
|
|
1929
1909
|
}
|
|
1930
1910
|
|
|
1931
1911
|
// Handing ownership of exception over, we need not release it ourselves
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1912
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
1913
|
+
if (_Nuitka_Generator_make_throw_exception_state(tstate, &exception_state, exception_type, exception_value,
|
|
1914
|
+
exception_tb) == false) {
|
|
1915
|
+
return NULL;
|
|
1916
|
+
}
|
|
1935
1917
|
|
|
1936
1918
|
retval = _Nuitka_Asyncgen_throw2(tstate, asyncgen,
|
|
1937
1919
|
0, /* Do not close generator when PyExc_GeneratorExit is passed */
|
|
1938
|
-
|
|
1920
|
+
&exception_state);
|
|
1939
1921
|
|
|
1940
1922
|
retval = _Nuitka_Asyncgen_unwrap_value(tstate, asyncgen, retval);
|
|
1941
1923
|
}
|
|
@@ -1949,7 +1931,10 @@ static PyObject *Nuitka_AsyncgenAthrow_send(struct Nuitka_AsyncgenAthrowObject *
|
|
|
1949
1931
|
|
|
1950
1932
|
assert(asyncgen_athrow->m_state == AWAITABLE_STATE_ITER);
|
|
1951
1933
|
|
|
1952
|
-
|
|
1934
|
+
struct Nuitka_ExceptionPreservationItem exception_state;
|
|
1935
|
+
INIT_ERROR_OCCURRED_STATE(&exception_state);
|
|
1936
|
+
|
|
1937
|
+
retval = _Nuitka_Asyncgen_send(tstate, asyncgen, arg, false, &exception_state);
|
|
1953
1938
|
|
|
1954
1939
|
if (asyncgen_athrow->m_args) {
|
|
1955
1940
|
return _Nuitka_Asyncgen_unwrap_value(tstate, asyncgen, retval);
|
|
@@ -710,10 +710,9 @@ bool PRINT_NEW_LINE_TO(PyObject *file) {
|
|
|
710
710
|
#else
|
|
711
711
|
NUITKA_ASSIGN_BUILTIN(print);
|
|
712
712
|
|
|
713
|
-
|
|
714
|
-
PyTracebackObject *exception_tb;
|
|
713
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
715
714
|
|
|
716
|
-
|
|
715
|
+
FETCH_ERROR_OCCURRED_STATE_UNTRACED(tstate, &saved_exception_state);
|
|
717
716
|
|
|
718
717
|
PyObject *result;
|
|
719
718
|
|
|
@@ -732,7 +731,7 @@ bool PRINT_NEW_LINE_TO(PyObject *file) {
|
|
|
732
731
|
|
|
733
732
|
Py_XDECREF(result);
|
|
734
733
|
|
|
735
|
-
|
|
734
|
+
RESTORE_ERROR_OCCURRED_STATE_UNTRACED(tstate, &saved_exception_state);
|
|
736
735
|
|
|
737
736
|
return result != NULL;
|
|
738
737
|
#endif
|
|
@@ -804,10 +803,9 @@ bool PRINT_ITEM_TO(PyObject *file, PyObject *object) {
|
|
|
804
803
|
#else
|
|
805
804
|
NUITKA_ASSIGN_BUILTIN(print);
|
|
806
805
|
|
|
807
|
-
|
|
808
|
-
PyTracebackObject *exception_tb;
|
|
806
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
809
807
|
|
|
810
|
-
|
|
808
|
+
FETCH_ERROR_OCCURRED_STATE_UNTRACED(tstate, &saved_exception_state);
|
|
811
809
|
|
|
812
810
|
// TODO: Have a helper that creates a dictionary for PyObject **
|
|
813
811
|
PyObject *print_kw = MAKE_DICT_EMPTY();
|
|
@@ -828,7 +826,7 @@ bool PRINT_ITEM_TO(PyObject *file, PyObject *object) {
|
|
|
828
826
|
|
|
829
827
|
Py_XDECREF(result);
|
|
830
828
|
|
|
831
|
-
|
|
829
|
+
RESTORE_ERROR_OCCURRED_STATE_UNTRACED(tstate, &saved_exception_state);
|
|
832
830
|
|
|
833
831
|
return result != NULL;
|
|
834
832
|
#endif
|
|
@@ -836,12 +834,18 @@ bool PRINT_ITEM_TO(PyObject *file, PyObject *object) {
|
|
|
836
834
|
|
|
837
835
|
void PRINT_REFCOUNT(PyObject *object) {
|
|
838
836
|
if (object) {
|
|
837
|
+
#if PYTHON_VERSION >= 0x3c0
|
|
838
|
+
if (_Py_IsImmortal(object)) {
|
|
839
|
+
PRINT_STRING(" recnf IMMORTAL");
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
#endif
|
|
839
843
|
char buffer[1024];
|
|
840
844
|
snprintf(buffer, sizeof(buffer) - 1, " refcnt %" PY_FORMAT_SIZE_T "d ", Py_REFCNT(object));
|
|
841
845
|
|
|
842
846
|
PRINT_STRING(buffer);
|
|
843
847
|
} else {
|
|
844
|
-
PRINT_STRING("<null>");
|
|
848
|
+
PRINT_STRING(" <null>");
|
|
845
849
|
}
|
|
846
850
|
}
|
|
847
851
|
|
|
@@ -868,12 +872,11 @@ bool PRINT_FORMAT(char const *fmt, ...) {
|
|
|
868
872
|
}
|
|
869
873
|
|
|
870
874
|
bool PRINT_REPR(PyObject *object) {
|
|
871
|
-
PyObject *exception_type, *exception_value;
|
|
872
|
-
PyTracebackObject *exception_tb;
|
|
873
|
-
|
|
874
875
|
PyThreadState *tstate = PyThreadState_GET();
|
|
875
876
|
|
|
876
|
-
|
|
877
|
+
struct Nuitka_ExceptionPreservationItem saved_exception_state;
|
|
878
|
+
|
|
879
|
+
FETCH_ERROR_OCCURRED_STATE_UNTRACED(tstate, &saved_exception_state);
|
|
877
880
|
|
|
878
881
|
bool res;
|
|
879
882
|
|
|
@@ -890,7 +893,7 @@ bool PRINT_REPR(PyObject *object) {
|
|
|
890
893
|
res = PRINT_NULL();
|
|
891
894
|
}
|
|
892
895
|
|
|
893
|
-
|
|
896
|
+
RESTORE_ERROR_OCCURRED_STATE_UNTRACED(tstate, &saved_exception_state);
|
|
894
897
|
|
|
895
898
|
return res;
|
|
896
899
|
}
|
|
@@ -935,7 +938,11 @@ void PRINT_CURRENT_EXCEPTION(void) {
|
|
|
935
938
|
PyThreadState *tstate = PyThreadState_GET();
|
|
936
939
|
|
|
937
940
|
PRINT_STRING("current_exc=");
|
|
941
|
+
#if PYTHON_VERSION < 0x3c0
|
|
938
942
|
PRINT_EXCEPTION(tstate->curexc_type, tstate->curexc_value, (PyTracebackObject *)tstate->curexc_traceback);
|
|
943
|
+
#else
|
|
944
|
+
_PRINT_EXCEPTION(tstate->exc_info->exc_value);
|
|
945
|
+
#endif
|
|
939
946
|
}
|
|
940
947
|
|
|
941
948
|
void PRINT_PUBLISHED_EXCEPTION(void) {
|
|
@@ -2108,6 +2115,8 @@ PyObject *MAKE_UNION_TYPE(PyObject *args) {
|
|
|
2108
2115
|
#include "HelpersDumpBacktraces.c"
|
|
2109
2116
|
#endif
|
|
2110
2117
|
|
|
2118
|
+
#include "HelpersJitSources.c"
|
|
2119
|
+
|
|
2111
2120
|
// Part of "Nuitka", an optimizing Python compiler that is compatible and
|
|
2112
2121
|
// integrates with CPython, but also works on its own.
|
|
2113
2122
|
//
|