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.

Files changed (234) hide show
  1. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/RECORD +234 -225
  3. nuitka/Errors.py +4 -0
  4. nuitka/HardImportRegistry.py +18 -1
  5. nuitka/MainControl.py +27 -30
  6. nuitka/OptionParsing.py +32 -30
  7. nuitka/Options.py +26 -13
  8. nuitka/OutputDirectories.py +7 -4
  9. nuitka/PostProcessing.py +9 -7
  10. nuitka/Progress.py +3 -3
  11. nuitka/PythonVersions.py +2 -2
  12. nuitka/TreeXML.py +1 -1
  13. nuitka/Version.py +1 -1
  14. nuitka/build/Backend.scons +2 -1
  15. nuitka/build/DataComposerInterface.py +1 -0
  16. nuitka/build/Onefile.scons +2 -1
  17. nuitka/build/SconsCaching.py +64 -46
  18. nuitka/build/SconsCompilerSettings.py +19 -6
  19. nuitka/build/SconsHacks.py +0 -1
  20. nuitka/build/SconsInterface.py +84 -5
  21. nuitka/build/SconsProgress.py +0 -1
  22. nuitka/build/SconsUtils.py +8 -4
  23. nuitka/build/include/nuitka/allocator.h +8 -3
  24. nuitka/build/include/nuitka/compiled_cell.h +8 -0
  25. nuitka/build/include/nuitka/exceptions.h +554 -179
  26. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  27. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  28. nuitka/build/include/nuitka/helper/ints.h +15 -2
  29. nuitka/build/include/nuitka/helper/lists.h +4 -1
  30. nuitka/build/include/nuitka/helper/raising.h +12 -0
  31. nuitka/build/include/nuitka/helper/tuples.h +5 -1
  32. nuitka/build/include/nuitka/helpers.h +4 -0
  33. nuitka/build/include/nuitka/importing.h +3 -4
  34. nuitka/build/include/nuitka/jit_sources.h +25 -0
  35. nuitka/build/include/nuitka/prelude.h +38 -11
  36. nuitka/build/include/nuitka/printing.h +3 -0
  37. nuitka/build/include/nuitka/threading.h +2 -6
  38. nuitka/build/include/nuitka/type_aliases.h +27 -0
  39. nuitka/build/inline_copy/pkg_resources/pkg_resources/__init__.py +0 -3
  40. nuitka/build/inline_copy/tqdm/tqdm/version.py +1 -4
  41. nuitka/build/static_src/CompiledAsyncgenType.c +99 -114
  42. nuitka/build/static_src/CompiledCodeHelpers.c +23 -14
  43. nuitka/build/static_src/CompiledCoroutineType.c +96 -114
  44. nuitka/build/static_src/CompiledFrameType.c +14 -11
  45. nuitka/build/static_src/CompiledFunctionType.c +34 -7
  46. nuitka/build/static_src/CompiledGeneratorType.c +248 -142
  47. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +60 -70
  48. nuitka/build/static_src/CompiledMethodType.c +8 -7
  49. nuitka/build/static_src/HelpersAttributes.c +2 -19
  50. nuitka/build/static_src/HelpersBuiltin.c +2 -1
  51. nuitka/build/static_src/HelpersComparisonEq.c +32 -18
  52. nuitka/build/static_src/HelpersComparisonGe.c +50 -36
  53. nuitka/build/static_src/HelpersComparisonGt.c +50 -36
  54. nuitka/build/static_src/HelpersComparisonLe.c +50 -36
  55. nuitka/build/static_src/HelpersComparisonLt.c +50 -36
  56. nuitka/build/static_src/HelpersComparisonNe.c +32 -18
  57. nuitka/build/static_src/HelpersDeepcopy.c +6 -8
  58. nuitka/build/static_src/HelpersDictionaries.c +8 -3
  59. nuitka/build/static_src/HelpersExceptions.c +42 -28
  60. nuitka/build/static_src/HelpersFilesystemPaths.c +7 -7
  61. nuitka/build/static_src/HelpersImportHard.c +15 -0
  62. nuitka/build/static_src/HelpersJitSources.c +46 -0
  63. nuitka/build/static_src/HelpersLists.c +40 -0
  64. nuitka/build/static_src/HelpersOperationBinaryAdd.c +66 -66
  65. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +80 -33
  66. nuitka/build/static_src/HelpersOperationBinaryMultUtils.c +16 -13
  67. nuitka/build/static_src/HelpersOperationBinarySub.c +39 -39
  68. nuitka/build/static_src/HelpersOperationInplaceAdd.c +54 -54
  69. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -1
  70. nuitka/build/static_src/HelpersOperationInplaceSub.c +50 -50
  71. nuitka/build/static_src/HelpersProfiling.c +3 -4
  72. nuitka/build/static_src/HelpersRaising.c +62 -1
  73. nuitka/build/static_src/HelpersStrings.c +203 -8
  74. nuitka/build/static_src/HelpersTypes.c +42 -0
  75. nuitka/build/static_src/MainProgram.c +1 -1
  76. nuitka/build/static_src/MetaPathBasedLoader.c +2 -1
  77. nuitka/build/static_src/OnefileBootstrap.c +3 -3
  78. nuitka/code_generation/BinaryOperationHelperDefinitions.py +5 -3
  79. nuitka/code_generation/BuiltinCodes.py +1 -0
  80. nuitka/code_generation/CodeGeneration.py +11 -0
  81. nuitka/code_generation/CodeHelpers.py +5 -3
  82. nuitka/code_generation/CodeObjectCodes.py +10 -6
  83. nuitka/code_generation/ComparisonCodes.py +19 -3
  84. nuitka/code_generation/ConstantCodes.py +5 -0
  85. nuitka/code_generation/Contexts.py +22 -6
  86. nuitka/code_generation/Emission.py +1 -0
  87. nuitka/code_generation/ErrorCodes.py +8 -16
  88. nuitka/code_generation/EvalCodes.py +5 -3
  89. nuitka/code_generation/ExceptionCodes.py +8 -1
  90. nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +1 -0
  91. nuitka/code_generation/FrameCodes.py +5 -3
  92. nuitka/code_generation/FunctionCodes.py +0 -1
  93. nuitka/code_generation/GeneratorCodes.py +3 -3
  94. nuitka/code_generation/GlobalConstants.py +0 -2
  95. nuitka/code_generation/ImportCodes.py +2 -0
  96. nuitka/code_generation/JitCodes.py +44 -0
  97. nuitka/code_generation/ListCodes.py +11 -17
  98. nuitka/code_generation/MatchCodes.py +0 -1
  99. nuitka/code_generation/ModuleCodes.py +2 -1
  100. nuitka/code_generation/Namify.py +0 -1
  101. nuitka/code_generation/NetworkxCodes.py +51 -0
  102. nuitka/code_generation/OperationCodes.py +8 -6
  103. nuitka/code_generation/PackageResourceCodes.py +7 -5
  104. nuitka/code_generation/TensorflowCodes.py +54 -0
  105. nuitka/code_generation/TypeAliasCodes.py +71 -0
  106. nuitka/code_generation/VariableCodes.py +7 -5
  107. nuitka/code_generation/VariableDeclarations.py +1 -0
  108. nuitka/code_generation/c_types/CTypeCLongs.py +0 -1
  109. nuitka/code_generation/c_types/CTypeNuitkaInts.py +0 -1
  110. nuitka/code_generation/c_types/CTypeVoids.py +1 -0
  111. nuitka/code_generation/templates/CodeTemplatesConstants.py +14 -0
  112. nuitka/code_generation/templates/CodeTemplatesExceptions.py +1 -1
  113. nuitka/code_generation/templates/CodeTemplatesIterators.py +0 -1
  114. nuitka/code_generation/templates/CodeTemplatesLoader.py +0 -1
  115. nuitka/code_generation/templates/CodeTemplatesModules.py +9 -4
  116. nuitka/code_generation/templates/CodeTemplatesVariables.py +8 -8
  117. nuitka/code_generation/templates/TemplateDebugWrapper.py +0 -1
  118. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -0
  119. nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +9 -7
  120. nuitka/containers/Namedtuples.py +0 -1
  121. nuitka/finalizations/Finalization.py +1 -0
  122. nuitka/finalizations/FinalizeMarkups.py +0 -1
  123. nuitka/freezer/DllDependenciesMacOS.py +60 -13
  124. nuitka/freezer/DllDependenciesPosix.py +0 -1
  125. nuitka/freezer/DllDependenciesWin32.py +2 -1
  126. nuitka/freezer/IncludedDataFiles.py +46 -15
  127. nuitka/freezer/IncludedEntryPoints.py +5 -3
  128. nuitka/freezer/Standalone.py +6 -1
  129. nuitka/importing/ImportCache.py +2 -2
  130. nuitka/importing/ImportResolving.py +80 -78
  131. nuitka/importing/Importing.py +34 -1
  132. nuitka/nodes/AttributeNodesGenerated.py +21 -6
  133. nuitka/nodes/BuiltinComplexNodes.py +1 -0
  134. nuitka/nodes/BuiltinFormatNodes.py +1 -0
  135. nuitka/nodes/BuiltinIteratorNodes.py +5 -3
  136. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +21 -6
  137. nuitka/nodes/BuiltinRefNodes.py +8 -1
  138. nuitka/nodes/BuiltinVarsNodes.py +0 -1
  139. nuitka/nodes/ChildrenHavingMixins.py +906 -186
  140. nuitka/nodes/CodeObjectSpecs.py +1 -1
  141. nuitka/nodes/ConditionalNodes.py +2 -6
  142. nuitka/nodes/ConstantRefNodes.py +38 -0
  143. nuitka/nodes/CtypesNodes.py +0 -1
  144. nuitka/nodes/DictionaryNodes.py +0 -1
  145. nuitka/nodes/ExceptionNodes.py +10 -0
  146. nuitka/nodes/ExpressionBases.py +15 -9
  147. nuitka/nodes/ExpressionBasesGenerated.py +32 -15
  148. nuitka/nodes/FunctionNodes.py +50 -5
  149. nuitka/nodes/HardImportNodesGenerated.py +245 -60
  150. nuitka/nodes/ImportHardNodes.py +27 -13
  151. nuitka/nodes/ImportNodes.py +92 -70
  152. nuitka/nodes/InjectCNodes.py +0 -1
  153. nuitka/nodes/ModuleNodes.py +10 -5
  154. nuitka/nodes/NetworkxNodes.py +45 -0
  155. nuitka/nodes/OperatorNodesUnary.py +1 -0
  156. nuitka/nodes/OsSysNodes.py +0 -1
  157. nuitka/nodes/PackageMetadataNodes.py +0 -1
  158. nuitka/nodes/PackageResourceNodes.py +10 -6
  159. nuitka/nodes/StatementBasesGenerated.py +107 -60
  160. nuitka/nodes/StringConcatenationNodes.py +1 -0
  161. nuitka/nodes/TensorflowNodes.py +38 -0
  162. nuitka/nodes/TypeNodes.py +21 -0
  163. nuitka/nodes/VariableRefNodes.py +1 -0
  164. nuitka/nodes/shapes/BuiltinTypeShapes.py +25 -15
  165. nuitka/optimizations/Optimization.py +7 -6
  166. nuitka/optimizations/OptimizeBuiltinCalls.py +11 -9
  167. nuitka/optimizations/Tags.py +0 -1
  168. nuitka/optimizations/TraceCollections.py +6 -55
  169. nuitka/optimizations/ValueTraces.py +49 -1
  170. nuitka/plugins/PluginBase.py +26 -4
  171. nuitka/plugins/Plugins.py +49 -12
  172. nuitka/plugins/standard/AntiBloatPlugin.py +12 -2
  173. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +0 -1
  174. nuitka/plugins/standard/DataFilesPlugin.py +2 -6
  175. nuitka/plugins/standard/DillPlugin.py +3 -3
  176. nuitka/plugins/standard/DllFilesPlugin.py +29 -23
  177. nuitka/plugins/standard/GiPlugin.py +1 -0
  178. nuitka/plugins/standard/ImplicitImports.py +8 -7
  179. nuitka/plugins/standard/MatplotlibPlugin.py +1 -0
  180. nuitka/plugins/standard/OptionsNannyPlugin.py +3 -7
  181. nuitka/plugins/standard/PkgResourcesPlugin.py +0 -1
  182. nuitka/plugins/standard/PmwPlugin.py +10 -9
  183. nuitka/plugins/standard/PySidePyQtPlugin.py +0 -28
  184. nuitka/plugins/standard/TensorflowPlugin.py +1 -0
  185. nuitka/plugins/standard/TorchPlugin.py +1 -0
  186. nuitka/plugins/standard/TrioPlugin.py +1 -0
  187. nuitka/plugins/standard/standard.nuitka-package.config.yml +249 -34
  188. nuitka/reports/CompilationReportReader.py +0 -1
  189. nuitka/reports/Reports.py +49 -5
  190. nuitka/specs/BuiltinParameterSpecs.py +10 -2
  191. nuitka/specs/BuiltinStrOperationSpecs.py +1 -1
  192. nuitka/specs/BuiltinTypeOperationSpecs.py +0 -1
  193. nuitka/specs/HardImportSpecs.py +34 -1
  194. nuitka/specs/ParameterSpecs.py +11 -9
  195. nuitka/tools/environments/Virtualenv.py +0 -1
  196. nuitka/tools/specialize/CTypeDescriptions.py +15 -11
  197. nuitka/tools/specialize/SpecializeC.py +11 -9
  198. nuitka/tools/specialize/SpecializePython.py +57 -30
  199. nuitka/tools/testing/Common.py +24 -7
  200. nuitka/tools/testing/OutputComparison.py +4 -0
  201. nuitka/tools/testing/Pythons.py +0 -1
  202. nuitka/tools/testing/compare_with_cpython/__main__.py +0 -4
  203. nuitka/tools/watch/GitHub.py +4 -1
  204. nuitka/tools/watch/__main__.py +22 -1
  205. nuitka/tree/Building.py +3 -0
  206. nuitka/tree/InternalModule.py +0 -1
  207. nuitka/tree/ReformulationAssertStatements.py +1 -0
  208. nuitka/tree/ReformulationAssignmentStatements.py +26 -3
  209. nuitka/tree/ReformulationClasses3.py +23 -26
  210. nuitka/tree/ReformulationContractionExpressions.py +5 -3
  211. nuitka/tree/ReformulationDictionaryCreation.py +6 -5
  212. nuitka/tree/ReformulationExecStatements.py +8 -6
  213. nuitka/tree/ReformulationFunctionStatements.py +10 -6
  214. nuitka/tree/SourceHandling.py +8 -0
  215. nuitka/tree/TreeHelpers.py +6 -3
  216. nuitka/utils/AppDirs.py +6 -2
  217. nuitka/utils/CStrings.py +1 -1
  218. nuitka/utils/CommandLineOptions.py +0 -1
  219. nuitka/utils/Distributions.py +3 -3
  220. nuitka/utils/Download.py +5 -1
  221. nuitka/utils/Execution.py +6 -3
  222. nuitka/utils/FileOperations.py +61 -34
  223. nuitka/utils/Importing.py +4 -4
  224. nuitka/utils/InstanceCounters.py +1 -0
  225. nuitka/utils/MacOSApp.py +1 -0
  226. nuitka/utils/Shebang.py +1 -0
  227. nuitka/utils/Utils.py +39 -1
  228. nuitka/utils/WindowsFileUsage.py +4 -3
  229. {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.2.data}/scripts/nuitka-run.bat +0 -0
  230. {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.2.data}/scripts/nuitka.bat +0 -0
  231. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/LICENSE.txt +0 -0
  232. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/WHEEL +0 -0
  233. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/entry_points.txt +0 -0
  234. {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, PyObject *exception_type,
284
- PyObject *exception_value, PyTracebackObject *exception_tb,
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
- CHECK_OBJECT_X(exception_type);
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
- PRINT_EXCEPTION(exception_type, exception_value, exception_tb);
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
- assert(exception_type == NULL);
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(exception_type != NULL)) {
341
+ if (unlikely(HAS_EXCEPTION_STATE(exception_state))) {
346
342
  assert(value == NULL);
347
343
 
348
344
  // Transfer exception ownership to published.
349
- RESTORE_ERROR_OCCURRED(tstate, exception_type, exception_value, exception_tb);
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
- PyObject *saved_exception_type, *saved_exception_value;
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
- SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "async generator raised StopIteration");
427
+ message = "async generator raised StopIteration";
438
428
  } else {
439
- SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError,
440
- "async generator raised StopAsyncIteration");
429
+ message = "async generator raised StopAsyncIteration";
441
430
  }
442
431
 
443
- FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
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
- Py_XDECREF(exception_type);
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, PyObject *exception_type, PyObject *exception_value,
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, exception_type, exception_value,
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
- Py_INCREF(PyExc_GeneratorExit);
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, PyExc_GeneratorExit, NULL, NULL);
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 _Nuitka_Generator_check_throw2(PyThreadState *tstate, PyObject **exception_type, PyObject **exception_value,
534
- PyTracebackObject **exception_tb);
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, PyObject *exception_type, PyObject *exception_value,
544
- PyTracebackObject *exception_tb) {
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
- CHECK_OBJECT(exception_type);
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
- PRINT_EXCEPTION(exception_type, exception_value, exception_tb);
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 (EXCEPTION_MATCH_BOOL_SINGLE(tstate, exception_type, PyExc_GeneratorExit)) {
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
- Py_DECREF(exception_type);
570
- Py_XDECREF(exception_value);
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, exception_type, exception_value,
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, exception_type, exception_value, exception_tb);
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, exception_type, exception_value, exception_tb);
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, exception_type, exception_value, exception_tb);
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, exception_type, exception_value, exception_tb);
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, exception_type, exception_value, exception_tb);
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
- Py_DECREF(exception_type);
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
- CHECK_OBJECT(exception_type);
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 = PyObject_CallFunctionObjArgs(meth, exception_type, exception_value, exception_tb, NULL);
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
- Py_DECREF(exception_type);
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
- ret = _Nuitka_Asyncgen_send(tstate, asyncgen, val, false, NULL, NULL, NULL);
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
- ret = _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, false, NULL, NULL, NULL);
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(_Nuitka_Generator_check_throw2(tstate, &exception_type, &exception_value, &exception_tb) == false)) {
726
- // Exception was released by _Nuitka_Generator_check_throw2 already.
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, exception_type, exception_value, exception_tb);
703
+ result = _Nuitka_Asyncgen_send(tstate, asyncgen, NULL, false, exception_state);
734
704
  } else if (asyncgen->m_status == status_Finished) {
735
- RESTORE_ERROR_OCCURRED(tstate, exception_type, exception_value, exception_tb);
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
- exception_tb = MAKE_TRACEBACK(frame, asyncgen->m_code_object->co_firstlineno);
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
- RESTORE_ERROR_OCCURRED(tstate, exception_type, exception_value, exception_tb);
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
- Py_INCREF(exception_type);
793
- Py_XINCREF(exception_value);
794
- Py_XINCREF(exception_tb);
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, exception_type, exception_value, exception_tb);
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
- CHECK_OBJECT(exception_type);
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
- PySendResult res = _Nuitka_Asyncgen_sendR(tstate, asyncgen, arg, false, NULL, NULL, NULL, result);
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
- PyObject *save_exception_type, *save_exception_value;
944
- PyTracebackObject *save_exception_tb;
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
- RESTORE_ERROR_OCCURRED(tstate, save_exception_type, save_exception_value, save_exception_tb);
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
- PyObject *save_exception_type, *save_exception_value;
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
- /* Save the current exception, if any. */
981
- FETCH_ERROR_OCCURRED(tstate, &save_exception_type, &save_exception_value, &save_exception_tb);
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
- RESTORE_ERROR_OCCURRED(tstate, save_exception_type, save_exception_value, save_exception_tb);
965
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state);
992
966
  return;
993
967
  }
994
968
 
995
- FETCH_ERROR_OCCURRED(tstate, &save_exception_type, &save_exception_value, &save_exception_tb);
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
- RESTORE_ERROR_OCCURRED(tstate, save_exception_type, save_exception_value, save_exception_tb);
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
- PyObject *result = _Nuitka_Asyncgen_send(tstate, asyncgen_asend->m_gen, arg, false, NULL, NULL, NULL);
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
- PyObject *exception_type, PyObject *exception_value,
1614
- PyTracebackObject *exception_tb) {
1593
+ struct Nuitka_ExceptionPreservationItem *exception_state) {
1615
1594
  #if _DEBUG_ASYNCGEN
1616
1595
  PRINT_ASYNCGENASEND_STATUS("Enter", asyncgen_asend);
1617
- PRINT_EXCEPTION(exception_type, exception_value, exception_tb);
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
- Py_INCREF(PyExc_GeneratorExit);
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
- PyExc_GeneratorExit, NULL, NULL);
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
- Py_INCREF(exception_type);
1933
- Py_XINCREF(exception_value);
1934
- Py_XINCREF(exception_tb);
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
- exception_type, exception_value, exception_tb);
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
- retval = _Nuitka_Asyncgen_send(tstate, asyncgen, arg, false, NULL, NULL, NULL);
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
- PyObject *exception_type, *exception_value;
714
- PyTracebackObject *exception_tb;
713
+ struct Nuitka_ExceptionPreservationItem saved_exception_state;
715
714
 
716
- FETCH_ERROR_OCCURRED_UNTRACED(tstate, &exception_type, &exception_value, &exception_tb);
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
- RESTORE_ERROR_OCCURRED_UNTRACED(tstate, exception_type, exception_value, exception_tb);
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
- PyObject *exception_type, *exception_value;
808
- PyTracebackObject *exception_tb;
806
+ struct Nuitka_ExceptionPreservationItem saved_exception_state;
809
807
 
810
- FETCH_ERROR_OCCURRED_UNTRACED(tstate, &exception_type, &exception_value, &exception_tb);
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
- RESTORE_ERROR_OCCURRED_UNTRACED(tstate, exception_type, exception_value, exception_tb);
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
- FETCH_ERROR_OCCURRED_UNTRACED(tstate, &exception_type, &exception_value, &exception_tb);
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
- RESTORE_ERROR_OCCURRED_UNTRACED(tstate, exception_type, exception_value, exception_tb);
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
  //