Nuitka-winsvc 2.2.3__cp311-cp311-win_amd64.whl → 2.3.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 (201) hide show
  1. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/METADATA +2 -1
  2. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/RECORD +201 -200
  3. nuitka/Bytecodes.py +4 -2
  4. nuitka/HardImportRegistry.py +1 -0
  5. nuitka/MainControl.py +16 -10
  6. nuitka/ModuleRegistry.py +15 -0
  7. nuitka/OptionParsing.py +30 -8
  8. nuitka/Options.py +106 -45
  9. nuitka/PostProcessing.py +9 -8
  10. nuitka/PythonVersions.py +2 -1
  11. nuitka/Serialization.py +47 -30
  12. nuitka/Version.py +1 -1
  13. nuitka/build/Backend.scons +46 -19
  14. nuitka/build/CCompilerVersion.scons +3 -3
  15. nuitka/build/Onefile.scons +4 -4
  16. nuitka/build/SconsCaching.py +3 -2
  17. nuitka/build/SconsCompilerSettings.py +18 -6
  18. nuitka/build/SconsInterface.py +28 -8
  19. nuitka/build/SconsUtils.py +9 -1
  20. nuitka/build/include/nuitka/allocator.h +58 -2
  21. nuitka/build/include/nuitka/compiled_frame.h +48 -13
  22. nuitka/build/include/nuitka/compiled_function.h +4 -0
  23. nuitka/build/include/nuitka/constants.h +6 -0
  24. nuitka/build/include/nuitka/exception_groups.h +6 -6
  25. nuitka/build/include/nuitka/exceptions.h +3 -3
  26. nuitka/build/include/nuitka/freelists.h +11 -0
  27. nuitka/build/include/nuitka/helper/dictionaries.h +5 -4
  28. nuitka/build/include/nuitka/helper/lists.h +5 -5
  29. nuitka/build/include/nuitka/helper/lists_generated.h +12 -12
  30. nuitka/build/include/nuitka/helper/sequences.h +6 -0
  31. nuitka/build/include/nuitka/helper/slices.h +14 -8
  32. nuitka/build/include/nuitka/helper/subscripts.h +1 -184
  33. nuitka/build/include/nuitka/helper/tuples.h +42 -33
  34. nuitka/build/include/nuitka/importing.h +5 -0
  35. nuitka/build/include/nuitka/prelude.h +49 -5
  36. nuitka/build/include/nuitka/safe_string_ops.h +1 -0
  37. nuitka/build/include/nuitka/threading.h +13 -10
  38. nuitka/build/static_src/CompiledAsyncgenType.c +19 -8
  39. nuitka/build/static_src/CompiledCellType.c +1 -1
  40. nuitka/build/static_src/CompiledCodeHelpers.c +18 -16
  41. nuitka/build/static_src/CompiledCoroutineType.c +23 -19
  42. nuitka/build/static_src/CompiledFrameType.c +46 -34
  43. nuitka/build/static_src/CompiledFunctionType.c +55 -34
  44. nuitka/build/static_src/CompiledGeneratorType.c +21 -19
  45. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +127 -130
  46. nuitka/build/static_src/CompiledMethodType.c +15 -17
  47. nuitka/build/static_src/HelpersAllocator.c +71 -0
  48. nuitka/build/static_src/HelpersAttributes.c +1 -1
  49. nuitka/build/static_src/HelpersBuiltin.c +5 -5
  50. nuitka/build/static_src/HelpersBytes.c +2 -2
  51. nuitka/build/static_src/HelpersCalling.c +3 -0
  52. nuitka/build/static_src/HelpersCallingGenerated.c +952 -133
  53. nuitka/build/static_src/HelpersComparisonEq.c +329 -329
  54. nuitka/build/static_src/HelpersComparisonEqUtils.c +3 -1
  55. nuitka/build/static_src/HelpersComparisonGe.c +322 -322
  56. nuitka/build/static_src/HelpersComparisonGt.c +321 -321
  57. nuitka/build/static_src/HelpersComparisonLe.c +322 -322
  58. nuitka/build/static_src/HelpersComparisonLt.c +321 -321
  59. nuitka/build/static_src/HelpersComparisonNe.c +329 -329
  60. nuitka/build/static_src/HelpersConsole.c +96 -0
  61. nuitka/build/static_src/HelpersConstantsBlob.c +10 -6
  62. nuitka/build/static_src/HelpersDeepcopy.c +10 -8
  63. nuitka/build/static_src/HelpersDictionaries.c +17 -11
  64. nuitka/build/static_src/HelpersDictionariesGenerated.c +65 -29
  65. nuitka/build/static_src/HelpersExceptions.c +107 -9
  66. nuitka/build/static_src/HelpersFilesystemPaths.c +64 -4
  67. nuitka/build/static_src/HelpersFloats.c +20 -14
  68. nuitka/build/static_src/HelpersImport.c +1 -1
  69. nuitka/build/static_src/HelpersJitSources.c +1 -1
  70. nuitka/build/static_src/HelpersLists.c +29 -19
  71. nuitka/build/static_src/HelpersListsGenerated.c +24 -24
  72. nuitka/build/static_src/HelpersMatching.c +32 -5
  73. nuitka/build/static_src/HelpersOperationBinaryAdd.c +90 -63
  74. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +4 -4
  75. nuitka/build/static_src/HelpersOperationBinaryBitand.c +33 -33
  76. nuitka/build/static_src/HelpersOperationBinaryBitor.c +33 -33
  77. nuitka/build/static_src/HelpersOperationBinaryBitxor.c +33 -33
  78. nuitka/build/static_src/HelpersOperationBinaryDivmod.c +24 -24
  79. nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +24 -24
  80. nuitka/build/static_src/HelpersOperationBinaryLshift.c +30 -30
  81. nuitka/build/static_src/HelpersOperationBinaryMatmult.c +7 -7
  82. nuitka/build/static_src/HelpersOperationBinaryMod.c +90 -90
  83. nuitka/build/static_src/HelpersOperationBinaryMult.c +64 -58
  84. nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +24 -24
  85. nuitka/build/static_src/HelpersOperationBinaryPow.c +27 -27
  86. nuitka/build/static_src/HelpersOperationBinaryRshift.c +30 -30
  87. nuitka/build/static_src/HelpersOperationBinarySub.c +24 -24
  88. nuitka/build/static_src/HelpersOperationBinaryTruediv.c +24 -24
  89. nuitka/build/static_src/HelpersOperationInplaceAdd.c +67 -49
  90. nuitka/build/static_src/HelpersOperationInplaceBitand.c +25 -25
  91. nuitka/build/static_src/HelpersOperationInplaceBitor.c +25 -25
  92. nuitka/build/static_src/HelpersOperationInplaceBitxor.c +25 -25
  93. nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +28 -28
  94. nuitka/build/static_src/HelpersOperationInplaceLshift.c +18 -18
  95. nuitka/build/static_src/HelpersOperationInplaceMatmult.c +10 -10
  96. nuitka/build/static_src/HelpersOperationInplaceMod.c +70 -70
  97. nuitka/build/static_src/HelpersOperationInplaceMult.c +33 -33
  98. nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +28 -28
  99. nuitka/build/static_src/HelpersOperationInplacePow.c +28 -28
  100. nuitka/build/static_src/HelpersOperationInplaceRshift.c +18 -18
  101. nuitka/build/static_src/HelpersOperationInplaceSub.c +28 -28
  102. nuitka/build/static_src/HelpersOperationInplaceTruediv.c +28 -28
  103. nuitka/build/static_src/HelpersRaising.c +10 -3
  104. nuitka/build/static_src/HelpersSafeStrings.c +14 -4
  105. nuitka/build/static_src/HelpersSlices.c +12 -5
  106. nuitka/build/static_src/HelpersStrings.c +1 -1
  107. nuitka/build/static_src/HelpersTuples.c +20 -15
  108. nuitka/build/static_src/InspectPatcher.c +74 -6
  109. nuitka/build/static_src/MainProgram.c +90 -25
  110. nuitka/build/static_src/MetaPathBasedLoader.c +81 -45
  111. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +2 -2
  112. nuitka/build/static_src/OnefileBootstrap.c +16 -17
  113. nuitka/code_generation/CodeGeneration.py +5 -2
  114. nuitka/code_generation/ConstantCodes.py +2 -2
  115. nuitka/code_generation/DictCodes.py +2 -2
  116. nuitka/code_generation/GlobalConstants.py +5 -0
  117. nuitka/code_generation/GlobalsLocalsCodes.py +2 -2
  118. nuitka/code_generation/ListCodes.py +2 -2
  119. nuitka/code_generation/LocalsDictCodes.py +1 -1
  120. nuitka/code_generation/ModuleCodes.py +19 -0
  121. nuitka/code_generation/PackageResourceCodes.py +14 -0
  122. nuitka/code_generation/SliceCodes.py +3 -3
  123. nuitka/code_generation/SubscriptCodes.py +5 -13
  124. nuitka/code_generation/TupleCodes.py +1 -1
  125. nuitka/code_generation/c_types/CTypePyObjectPointers.py +7 -7
  126. nuitka/code_generation/templates/CodeTemplatesConstants.py +7 -5
  127. nuitka/code_generation/templates/CodeTemplatesLoader.py +2 -0
  128. nuitka/code_generation/templates/CodeTemplatesModules.py +80 -54
  129. nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +1 -1
  130. nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +59 -8
  131. nuitka/code_generation/templates_c/CodeTemplateCallsPositionalMethodDescr.c.j2 +5 -5
  132. nuitka/code_generation/templates_c/CodeTemplateMakeListHinted.c.j2 +2 -2
  133. nuitka/code_generation/templates_c/CodeTemplateMakeListSmall.c.j2 +2 -2
  134. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +57 -21
  135. nuitka/code_generation/templates_c/HelperImportHard.c.j2 +1 -1
  136. nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +5 -5
  137. nuitka/code_generation/templates_c/HelperOperationComparison.c.j2 +18 -18
  138. nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +11 -11
  139. nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +3 -3
  140. nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +3 -3
  141. nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +7 -7
  142. nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +3 -3
  143. nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +11 -11
  144. nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +7 -7
  145. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +10 -10
  146. nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
  147. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +3 -3
  148. nuitka/code_generation/templates_c/HelperSlotsList.c.j2 +4 -1
  149. nuitka/code_generation/templates_c/HelperSlotsTuple.c.j2 +4 -1
  150. nuitka/finalizations/FinalizeMarkups.py +0 -18
  151. nuitka/freezer/DependsExe.py +9 -4
  152. nuitka/freezer/DllDependenciesMacOS.py +1 -1
  153. nuitka/freezer/DllDependenciesWin32.py +1 -1
  154. nuitka/freezer/ImportDetection.py +1 -0
  155. nuitka/freezer/IncludedDataFiles.py +13 -4
  156. nuitka/freezer/IncludedEntryPoints.py +16 -0
  157. nuitka/freezer/Onefile.py +0 -1
  158. nuitka/freezer/Standalone.py +38 -21
  159. nuitka/importing/ImportCache.py +3 -2
  160. nuitka/importing/Importing.py +16 -3
  161. nuitka/importing/StandardLibrary.py +4 -0
  162. nuitka/nodes/ChildrenHavingMixins.py +2 -0
  163. nuitka/nodes/ExpressionBasesGenerated.py +4 -0
  164. nuitka/nodes/HardImportNodesGenerated.py +83 -0
  165. nuitka/nodes/ModuleNodes.py +10 -2
  166. nuitka/nodes/OsSysNodes.py +16 -0
  167. nuitka/nodes/SubscriptNodes.py +3 -3
  168. nuitka/plugins/PluginBase.py +2 -0
  169. nuitka/plugins/standard/DataFilesPlugin.py +22 -1
  170. nuitka/plugins/standard/DillPlugin/DillPlugin.c +3 -3
  171. nuitka/plugins/standard/ImplicitImports.py +3 -0
  172. nuitka/plugins/standard/OptionsNannyPlugin.py +9 -41
  173. nuitka/plugins/standard/PkgResourcesPlugin.py +8 -2
  174. nuitka/plugins/standard/PySidePyQtPlugin.py +3 -0
  175. nuitka/plugins/standard/standard.nuitka-package.config.yml +28 -13
  176. nuitka/plugins/standard/stdlib2.nuitka-package.config.yml +2 -2
  177. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +7 -2
  178. nuitka/specs/HardImportSpecs.py +3 -0
  179. nuitka/specs/ParameterSpecs.py +26 -15
  180. nuitka/tools/general/find_module/FindModuleCode.py +3 -2
  181. nuitka/tools/specialize/CTypeDescriptions.py +11 -9
  182. nuitka/tools/testing/Common.py +12 -5
  183. nuitka/tools/testing/SearchModes.py +5 -1
  184. nuitka/tools/testing/run_nuitka_tests/__main__.py +37 -0
  185. nuitka/tools/watch/GitHub.py +1 -7
  186. nuitka/tree/Building.py +9 -6
  187. nuitka/tree/ReformulationMatchStatements.py +51 -14
  188. nuitka/tree/TreeHelpers.py +8 -0
  189. nuitka/utils/CStrings.py +7 -0
  190. nuitka/utils/Execution.py +10 -1
  191. nuitka/utils/FileOperations.py +21 -13
  192. nuitka/utils/Importing.py +24 -0
  193. nuitka/utils/ReExecute.py +12 -3
  194. nuitka/utils/SharedLibraries.py +26 -1
  195. nuitka/utils/Yaml.py +9 -1
  196. {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.2.data}/scripts/nuitka-run.bat +0 -0
  197. {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.2.data}/scripts/nuitka.bat +0 -0
  198. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/LICENSE.txt +0 -0
  199. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/WHEEL +0 -0
  200. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/entry_points.txt +0 -0
  201. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/top_level.txt +0 -0
@@ -24,9 +24,34 @@ static PyObject *Nuitka_CallGeneratorThrowMethod(PyObject *throw_method,
24
24
  struct Nuitka_ExceptionPreservationItem *exception_state);
25
25
  #endif
26
26
 
27
+ #if PYTHON_VERSION >= 0x300
28
+ static PyBaseExceptionObject *Nuitka_BaseExceptionSingleArg_new(PyThreadState *tstate, PyTypeObject *type,
29
+ PyObject *arg) {
30
+ PyBaseExceptionObject *result = (PyBaseExceptionObject *)type->tp_alloc(type, 0);
31
+
32
+ result->dict = NULL;
33
+ result->traceback = NULL;
34
+ result->cause = NULL;
35
+ result->context = NULL;
36
+ result->suppress_context = 0;
37
+
38
+ result->args = MAKE_TUPLE1(tstate, arg);
39
+
40
+ return result;
41
+ }
42
+
43
+ static PyObject *Nuitka_CreateStopIteration(PyThreadState *tstate, PyObject *value) {
44
+ PyStopIterationObject *result =
45
+ (PyStopIterationObject *)Nuitka_BaseExceptionSingleArg_new(tstate, (PyTypeObject *)PyExc_StopIteration, value);
46
+
47
+ result->value = value;
48
+ Py_INCREF(value);
49
+
50
+ return (PyObject *)result;
51
+ }
52
+
27
53
  // This function takes no reference to value, and publishes a StopIteration
28
54
  // exception with it.
29
- #if PYTHON_VERSION >= 0x300
30
55
  static void Nuitka_SetStopIterationValue(PyThreadState *tstate, PyObject *value) {
31
56
  CHECK_OBJECT(value);
32
57
 
@@ -38,6 +63,10 @@ static void Nuitka_SetStopIterationValue(PyThreadState *tstate, PyObject *value)
38
63
  }
39
64
 
40
65
  SET_CURRENT_EXCEPTION_TYPE0_VALUE1(tstate, PyExc_StopIteration, stop_value);
66
+ #elif PYTHON_VERSION >= 0x3c0
67
+ struct Nuitka_ExceptionPreservationItem exception_state = {Nuitka_CreateStopIteration(tstate, value)};
68
+
69
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &exception_state);
41
70
  #else
42
71
  if (likely(!PyTuple_Check(value) && !PyExceptionInstance_Check(value))) {
43
72
  Py_INCREF(PyExc_StopIteration);
@@ -45,14 +74,10 @@ static void Nuitka_SetStopIterationValue(PyThreadState *tstate, PyObject *value)
45
74
 
46
75
  RESTORE_ERROR_OCCURRED(tstate, PyExc_StopIteration, value, NULL);
47
76
  } else {
48
- PyObject *stop_value = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, (PyObject *)PyExc_StopIteration, value);
77
+ struct Nuitka_ExceptionPreservationItem exception_state = {Py_NewRef(PyExc_StopIteration),
78
+ Nuitka_CreateStopIteration(tstate, value)};
49
79
 
50
- if (unlikely(stop_value == NULL)) {
51
- return;
52
- }
53
-
54
- Py_INCREF(PyExc_StopIteration);
55
- RESTORE_ERROR_OCCURRED(tstate, PyExc_StopIteration, stop_value, NULL);
80
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &exception_state);
56
81
  }
57
82
  #endif
58
83
  }
@@ -103,45 +128,10 @@ static inline bool Nuitka_PyFrameHasCompleted(PyFrameObject *const frame) {
103
128
  // what it does. It's unrelated to compiled generators, and used from coroutines
104
129
  // and asyncgen to interact with them.
105
130
  static PyObject *Nuitka_PyGen_Send(PyThreadState *tstate, PyGenObject *gen, PyObject *arg) {
106
- #if defined(PY_NOGIL)
107
- PyObject *res;
108
-
109
- if (gen->status == GEN_CREATED) {
110
- if (unlikely(arg != Py_None)) {
111
- char const *msg = "generator raised StopIteration";
112
- if (PyCoro_CheckExact(gen)) {
113
- msg = "coroutine raised StopIteration";
114
- } else if (PyAsyncGen_CheckExact(gen)) {
115
- msg = "async generator raised StopIteration";
116
- }
117
-
118
- _PyErr_FormatFromCause(PyExc_RuntimeError, "%s", msg);
119
- return NULL;
120
- }
121
- arg = NULL;
122
- }
123
-
124
- res = PyEval2_EvalGen(gen, arg);
125
-
126
- if (likely(res != NULL)) {
127
- assert(gen->status == GEN_SUSPENDED);
128
- return res;
129
- }
130
-
131
- if (likely(gen->return_value == Py_None)) {
132
- gen->return_value = NULL;
133
- SET_CURRENT_EXCEPTION_TYPE0(tstate,
134
- PyAsyncGen_CheckExact(gen) ? PyExc_StopAsyncIteration : PyExc_StopIteration);
135
- return NULL;
136
- } else if (gen->return_value != NULL) {
137
- Nuitka_SetStopIterationValue(tstate, gen->return_value);
138
- return NULL;
139
- } else {
140
- return gen_wrap_exception(gen);
141
- }
142
- #elif PYTHON_VERSION >= 0x3a0
131
+ #if PYTHON_VERSION >= 0x3a0
143
132
  PyObject *result;
144
133
 
134
+ // TODO: Avoid API call for performance.
145
135
  PySendResult res = PyIter_Send((PyObject *)gen, arg, &result);
146
136
 
147
137
  switch (res) {
@@ -302,7 +292,7 @@ static PyObject *Nuitka_PyGen_Send(PyThreadState *tstate, PyGenObject *gen, PyOb
302
292
  assert(result == Py_None || !PyAsyncGen_CheckExact(gen));
303
293
 
304
294
  if (result == Py_None && !PyAsyncGen_CheckExact(gen)) {
305
- Py_DECREF(result);
295
+ Py_DECREF_IMMORTAL(result);
306
296
  result = NULL;
307
297
  }
308
298
  } else {
@@ -337,20 +327,14 @@ static PyObject *Nuitka_PyGen_Send(PyThreadState *tstate, PyGenObject *gen, PyOb
337
327
 
338
328
  #endif
339
329
 
340
- // TODO: Disabled for NOGIL until it becomes more ready.
330
+ // TODO: Disabled for Python 3.13 until it becomes more ready.
341
331
  // Not done for earlier versions yet, indicate usability for compiled
342
332
  // generators, but it seems that mostly coroutines need it anyway, so the
343
333
  // benefit would be only for performance and not by a lot.
344
- #if PYTHON_VERSION >= 0x340 && !defined(PY_NOGIL)
334
+ #if PYTHON_VERSION >= 0x340 && PYTHON_VERSION < 0x3d0
345
335
  #define NUITKA_UNCOMPILED_THROW_INTEGRATION 1
346
336
  #endif
347
337
 
348
- // TODO: Disabled for Python3.12 until release of it
349
- #if PYTHON_VERSION >= 0x3c0
350
- #undef NUITKA_UNCOMPILED_THROW_INTEGRATION
351
- #define NUITKA_UNCOMPILED_THROW_INTEGRATION 0
352
- #endif
353
-
354
338
  #if NUITKA_UNCOMPILED_THROW_INTEGRATION
355
339
 
356
340
  static bool _Nuitka_Generator_check_throw(PyThreadState *tstate,
@@ -375,11 +359,9 @@ static int Nuitka_PyGen_gen_close_iter(PyThreadState *tstate, PyObject *yf);
375
359
  // spell-checker: ignore classderef,getattribute,precall
376
360
  const uint8_t Nuitka_PyOpcode_Deopt[256] = {
377
361
  #if PYTHON_VERSION >= 0x3c0
378
- [ASYNC_GEN_WRAP] = ASYNC_GEN_WRAP,
379
362
  [BEFORE_ASYNC_WITH] = BEFORE_ASYNC_WITH,
380
363
  [BEFORE_WITH] = BEFORE_WITH,
381
364
  [BINARY_OP] = BINARY_OP,
382
- [BINARY_OP_ADAPTIVE] = BINARY_OP,
383
365
  [BINARY_OP_ADD_FLOAT] = BINARY_OP,
384
366
  [BINARY_OP_ADD_INT] = BINARY_OP,
385
367
  [BINARY_OP_ADD_UNICODE] = BINARY_OP,
@@ -390,7 +372,6 @@ const uint8_t Nuitka_PyOpcode_Deopt[256] = {
390
372
  [BINARY_OP_SUBTRACT_INT] = BINARY_OP,
391
373
  [BINARY_SLICE] = BINARY_SLICE,
392
374
  [BINARY_SUBSCR] = BINARY_SUBSCR,
393
- [BINARY_SUBSCR_ADAPTIVE] = BINARY_SUBSCR,
394
375
  [BINARY_SUBSCR_DICT] = BINARY_SUBSCR,
395
376
  [BINARY_SUBSCR_GETITEM] = BINARY_SUBSCR,
396
377
  [BINARY_SUBSCR_LIST_INT] = BINARY_SUBSCR,
@@ -404,11 +385,12 @@ const uint8_t Nuitka_PyOpcode_Deopt[256] = {
404
385
  [BUILD_TUPLE] = BUILD_TUPLE,
405
386
  [CACHE] = CACHE,
406
387
  [CALL] = CALL,
407
- [CALL_ADAPTIVE] = CALL,
408
388
  [CALL_BOUND_METHOD_EXACT_ARGS] = CALL,
409
389
  [CALL_BUILTIN_CLASS] = CALL,
410
390
  [CALL_BUILTIN_FAST_WITH_KEYWORDS] = CALL,
411
391
  [CALL_FUNCTION_EX] = CALL_FUNCTION_EX,
392
+ [CALL_INTRINSIC_1] = CALL_INTRINSIC_1,
393
+ [CALL_INTRINSIC_2] = CALL_INTRINSIC_2,
412
394
  [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL,
413
395
  [CALL_NO_KW_BUILTIN_FAST] = CALL,
414
396
  [CALL_NO_KW_BUILTIN_O] = CALL,
@@ -427,10 +409,9 @@ const uint8_t Nuitka_PyOpcode_Deopt[256] = {
427
409
  [CHECK_EXC_MATCH] = CHECK_EXC_MATCH,
428
410
  [CLEANUP_THROW] = CLEANUP_THROW,
429
411
  [COMPARE_OP] = COMPARE_OP,
430
- [COMPARE_OP_ADAPTIVE] = COMPARE_OP,
431
- [COMPARE_OP_FLOAT_JUMP] = COMPARE_OP,
432
- [COMPARE_OP_INT_JUMP] = COMPARE_OP,
433
- [COMPARE_OP_STR_JUMP] = COMPARE_OP,
412
+ [COMPARE_OP_FLOAT] = COMPARE_OP,
413
+ [COMPARE_OP_INT] = COMPARE_OP,
414
+ [COMPARE_OP_STR] = COMPARE_OP,
434
415
  [CONTAINS_OP] = CONTAINS_OP,
435
416
  [COPY] = COPY,
436
417
  [COPY_FREE_VARS] = COPY_FREE_VARS,
@@ -443,13 +424,15 @@ const uint8_t Nuitka_PyOpcode_Deopt[256] = {
443
424
  [DICT_MERGE] = DICT_MERGE,
444
425
  [DICT_UPDATE] = DICT_UPDATE,
445
426
  [END_ASYNC_FOR] = END_ASYNC_FOR,
427
+ [END_FOR] = END_FOR,
428
+ [END_SEND] = END_SEND,
446
429
  [EXTENDED_ARG] = EXTENDED_ARG,
447
- [EXTENDED_ARG_QUICK] = EXTENDED_ARG,
448
430
  [FORMAT_VALUE] = FORMAT_VALUE,
449
431
  [FOR_ITER] = FOR_ITER,
450
- [FOR_ITER_ADAPTIVE] = FOR_ITER,
432
+ [FOR_ITER_GEN] = FOR_ITER,
451
433
  [FOR_ITER_LIST] = FOR_ITER,
452
434
  [FOR_ITER_RANGE] = FOR_ITER,
435
+ [FOR_ITER_TUPLE] = FOR_ITER,
453
436
  [GET_AITER] = GET_AITER,
454
437
  [GET_ANEXT] = GET_ANEXT,
455
438
  [GET_AWAITABLE] = GET_AWAITABLE,
@@ -458,47 +441,64 @@ const uint8_t Nuitka_PyOpcode_Deopt[256] = {
458
441
  [GET_YIELD_FROM_ITER] = GET_YIELD_FROM_ITER,
459
442
  [IMPORT_FROM] = IMPORT_FROM,
460
443
  [IMPORT_NAME] = IMPORT_NAME,
461
- [IMPORT_STAR] = IMPORT_STAR,
444
+ [INSTRUMENTED_CALL] = INSTRUMENTED_CALL,
445
+ [INSTRUMENTED_CALL_FUNCTION_EX] = INSTRUMENTED_CALL_FUNCTION_EX,
446
+ [INSTRUMENTED_END_FOR] = INSTRUMENTED_END_FOR,
447
+ [INSTRUMENTED_END_SEND] = INSTRUMENTED_END_SEND,
448
+ [INSTRUMENTED_FOR_ITER] = INSTRUMENTED_FOR_ITER,
449
+ [INSTRUMENTED_INSTRUCTION] = INSTRUMENTED_INSTRUCTION,
450
+ [INSTRUMENTED_JUMP_BACKWARD] = INSTRUMENTED_JUMP_BACKWARD,
451
+ [INSTRUMENTED_JUMP_FORWARD] = INSTRUMENTED_JUMP_FORWARD,
452
+ [INSTRUMENTED_LINE] = INSTRUMENTED_LINE,
453
+ [INSTRUMENTED_LOAD_SUPER_ATTR] = INSTRUMENTED_LOAD_SUPER_ATTR,
454
+ [INSTRUMENTED_POP_JUMP_IF_FALSE] = INSTRUMENTED_POP_JUMP_IF_FALSE,
455
+ [INSTRUMENTED_POP_JUMP_IF_NONE] = INSTRUMENTED_POP_JUMP_IF_NONE,
456
+ [INSTRUMENTED_POP_JUMP_IF_NOT_NONE] = INSTRUMENTED_POP_JUMP_IF_NOT_NONE,
457
+ [INSTRUMENTED_POP_JUMP_IF_TRUE] = INSTRUMENTED_POP_JUMP_IF_TRUE,
458
+ [INSTRUMENTED_RESUME] = INSTRUMENTED_RESUME,
459
+ [INSTRUMENTED_RETURN_CONST] = INSTRUMENTED_RETURN_CONST,
460
+ [INSTRUMENTED_RETURN_VALUE] = INSTRUMENTED_RETURN_VALUE,
461
+ [INSTRUMENTED_YIELD_VALUE] = INSTRUMENTED_YIELD_VALUE,
462
+ [INTERPRETER_EXIT] = INTERPRETER_EXIT,
462
463
  [IS_OP] = IS_OP,
463
464
  [JUMP_BACKWARD] = JUMP_BACKWARD,
464
465
  [JUMP_BACKWARD_NO_INTERRUPT] = JUMP_BACKWARD_NO_INTERRUPT,
465
- [JUMP_BACKWARD_QUICK] = JUMP_BACKWARD,
466
466
  [JUMP_FORWARD] = JUMP_FORWARD,
467
- [JUMP_IF_FALSE_OR_POP] = JUMP_IF_FALSE_OR_POP,
468
- [JUMP_IF_TRUE_OR_POP] = JUMP_IF_TRUE_OR_POP,
469
467
  [KW_NAMES] = KW_NAMES,
470
468
  [LIST_APPEND] = LIST_APPEND,
471
469
  [LIST_EXTEND] = LIST_EXTEND,
472
- [LIST_TO_TUPLE] = LIST_TO_TUPLE,
473
470
  [LOAD_ASSERTION_ERROR] = LOAD_ASSERTION_ERROR,
474
471
  [LOAD_ATTR] = LOAD_ATTR,
475
- [LOAD_ATTR_ADAPTIVE] = LOAD_ATTR,
476
472
  [LOAD_ATTR_CLASS] = LOAD_ATTR,
477
473
  [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = LOAD_ATTR,
478
474
  [LOAD_ATTR_INSTANCE_VALUE] = LOAD_ATTR,
479
475
  [LOAD_ATTR_METHOD_LAZY_DICT] = LOAD_ATTR,
480
476
  [LOAD_ATTR_METHOD_NO_DICT] = LOAD_ATTR,
481
- [LOAD_ATTR_METHOD_WITH_DICT] = LOAD_ATTR,
482
477
  [LOAD_ATTR_METHOD_WITH_VALUES] = LOAD_ATTR,
483
478
  [LOAD_ATTR_MODULE] = LOAD_ATTR,
484
479
  [LOAD_ATTR_PROPERTY] = LOAD_ATTR,
485
480
  [LOAD_ATTR_SLOT] = LOAD_ATTR,
486
481
  [LOAD_ATTR_WITH_HINT] = LOAD_ATTR,
487
482
  [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS,
488
- [LOAD_CLASSDEREF] = LOAD_CLASSDEREF,
489
483
  [LOAD_CLOSURE] = LOAD_CLOSURE,
490
484
  [LOAD_CONST] = LOAD_CONST,
491
485
  [LOAD_CONST__LOAD_FAST] = LOAD_CONST,
492
486
  [LOAD_DEREF] = LOAD_DEREF,
493
487
  [LOAD_FAST] = LOAD_FAST,
488
+ [LOAD_FAST_AND_CLEAR] = LOAD_FAST_AND_CLEAR,
494
489
  [LOAD_FAST_CHECK] = LOAD_FAST_CHECK,
495
490
  [LOAD_FAST__LOAD_CONST] = LOAD_FAST,
496
491
  [LOAD_FAST__LOAD_FAST] = LOAD_FAST,
492
+ [LOAD_FROM_DICT_OR_DEREF] = LOAD_FROM_DICT_OR_DEREF,
493
+ [LOAD_FROM_DICT_OR_GLOBALS] = LOAD_FROM_DICT_OR_GLOBALS,
497
494
  [LOAD_GLOBAL] = LOAD_GLOBAL,
498
- [LOAD_GLOBAL_ADAPTIVE] = LOAD_GLOBAL,
499
495
  [LOAD_GLOBAL_BUILTIN] = LOAD_GLOBAL,
500
496
  [LOAD_GLOBAL_MODULE] = LOAD_GLOBAL,
497
+ [LOAD_LOCALS] = LOAD_LOCALS,
501
498
  [LOAD_NAME] = LOAD_NAME,
499
+ [LOAD_SUPER_ATTR] = LOAD_SUPER_ATTR,
500
+ [LOAD_SUPER_ATTR_ATTR] = LOAD_SUPER_ATTR,
501
+ [LOAD_SUPER_ATTR_METHOD] = LOAD_SUPER_ATTR,
502
502
  [MAKE_CELL] = MAKE_CELL,
503
503
  [MAKE_FUNCTION] = MAKE_FUNCTION,
504
504
  [MAP_ADD] = MAP_ADD,
@@ -513,22 +513,21 @@ const uint8_t Nuitka_PyOpcode_Deopt[256] = {
513
513
  [POP_JUMP_IF_NOT_NONE] = POP_JUMP_IF_NOT_NONE,
514
514
  [POP_JUMP_IF_TRUE] = POP_JUMP_IF_TRUE,
515
515
  [POP_TOP] = POP_TOP,
516
- [PREP_RERAISE_STAR] = PREP_RERAISE_STAR,
517
- [PRINT_EXPR] = PRINT_EXPR,
518
516
  [PUSH_EXC_INFO] = PUSH_EXC_INFO,
519
517
  [PUSH_NULL] = PUSH_NULL,
520
518
  [RAISE_VARARGS] = RAISE_VARARGS,
521
519
  [RERAISE] = RERAISE,
520
+ [RESERVED] = RESERVED,
522
521
  [RESUME] = RESUME,
523
- [RESUME_QUICK] = RESUME,
522
+ [RETURN_CONST] = RETURN_CONST,
524
523
  [RETURN_GENERATOR] = RETURN_GENERATOR,
525
524
  [RETURN_VALUE] = RETURN_VALUE,
526
525
  [SEND] = SEND,
526
+ [SEND_GEN] = SEND,
527
527
  [SETUP_ANNOTATIONS] = SETUP_ANNOTATIONS,
528
528
  [SET_ADD] = SET_ADD,
529
529
  [SET_UPDATE] = SET_UPDATE,
530
530
  [STORE_ATTR] = STORE_ATTR,
531
- [STORE_ATTR_ADAPTIVE] = STORE_ATTR,
532
531
  [STORE_ATTR_INSTANCE_VALUE] = STORE_ATTR,
533
532
  [STORE_ATTR_SLOT] = STORE_ATTR,
534
533
  [STORE_ATTR_WITH_HINT] = STORE_ATTR,
@@ -540,17 +539,14 @@ const uint8_t Nuitka_PyOpcode_Deopt[256] = {
540
539
  [STORE_NAME] = STORE_NAME,
541
540
  [STORE_SLICE] = STORE_SLICE,
542
541
  [STORE_SUBSCR] = STORE_SUBSCR,
543
- [STORE_SUBSCR_ADAPTIVE] = STORE_SUBSCR,
544
542
  [STORE_SUBSCR_DICT] = STORE_SUBSCR,
545
543
  [STORE_SUBSCR_LIST_INT] = STORE_SUBSCR,
546
544
  [SWAP] = SWAP,
547
545
  [UNARY_INVERT] = UNARY_INVERT,
548
546
  [UNARY_NEGATIVE] = UNARY_NEGATIVE,
549
547
  [UNARY_NOT] = UNARY_NOT,
550
- [UNARY_POSITIVE] = UNARY_POSITIVE,
551
548
  [UNPACK_EX] = UNPACK_EX,
552
549
  [UNPACK_SEQUENCE] = UNPACK_SEQUENCE,
553
- [UNPACK_SEQUENCE_ADAPTIVE] = UNPACK_SEQUENCE,
554
550
  [UNPACK_SEQUENCE_LIST] = UNPACK_SEQUENCE,
555
551
  [UNPACK_SEQUENCE_TUPLE] = UNPACK_SEQUENCE,
556
552
  [UNPACK_SEQUENCE_TWO_TUPLE] = UNPACK_SEQUENCE,
@@ -765,6 +761,7 @@ PyObject *Nuitka_PyGen_yf(PyGenObject *gen) {
765
761
  return yf;
766
762
  }
767
763
 
764
+ #if PYTHON_VERSION < 0x3c0
768
765
  // Because it is not exported, we need to duplicate this.
769
766
  static PyFrameObject *_Nuitka_PyFrame_New_NoTrack(PyCodeObject *code) {
770
767
  int slots = code->co_nlocalsplus + code->co_stacksize;
@@ -833,7 +830,6 @@ static inline PyFrameObject *_Nuitka_PyFrame_GetFrameObject(PyThreadState *tstat
833
830
  }
834
831
 
835
832
  // Also not exported, taking over a frame object.
836
-
837
833
  static void _Nuitka_take_ownership(PyThreadState *tstate, PyFrameObject *f, _PyInterpreterFrame *frame) {
838
834
  assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
839
835
  assert(frame->owner != FRAME_CLEARED);
@@ -902,9 +898,17 @@ static void _Nuitka_PyFrame_Clear(PyThreadState *tstate, _PyInterpreterFrame *fr
902
898
  #else
903
899
  Py_DECREF(frame->f_funcobj);
904
900
  #endif
905
- Py_DECREF(frame->f_code);
901
+
902
+ #if PYTHON_VERSION < 0x3d0
903
+ Py_XDECREF(frame->f_code);
904
+ #else
905
+ Py_XDECREF(frame->f_executable);
906
+ #endif
906
907
  }
908
+ #endif
907
909
 
910
+ // Needs to be similar to "gen_send_ex2" implementation in CPython. This is the low
911
+ // end of an uncompiled generator receiving a value.
908
912
  static PySendResult Nuitka_PyGen_gen_send_ex2(PyThreadState *tstate, PyGenObject *gen, PyObject *arg,
909
913
  PyObject **presult, int exc, int closing) {
910
914
  _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
@@ -942,7 +946,7 @@ static PySendResult Nuitka_PyGen_gen_send_ex2(PyThreadState *tstate, PyGenObject
942
946
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "cannot reuse already awaited coroutine");
943
947
  } else if (arg && !exc) {
944
948
  *presult = Py_None;
945
- Py_INCREF(*presult);
949
+ Py_INCREF_IMMORTAL(*presult);
946
950
  return PYGEN_RETURN;
947
951
  }
948
952
  return PYGEN_ERROR;
@@ -955,9 +959,13 @@ static PySendResult Nuitka_PyGen_gen_send_ex2(PyThreadState *tstate, PyGenObject
955
959
  Py_INCREF(result);
956
960
  _PyFrame_StackPush(frame, result);
957
961
 
958
- frame->previous = tstate->cframe->current_frame;
962
+ #if PYTHON_VERSION < 0x3c0
963
+ frame->previous = CURRENT_TSTATE_INTERPRETER_FRAME(tstate);
964
+ #endif
965
+
966
+ _PyErr_StackItem *prev_exc_info = tstate->exc_info;
967
+ gen->gi_exc_state.previous_item = prev_exc_info;
959
968
 
960
- gen->gi_exc_state.previous_item = tstate->exc_info;
961
969
  tstate->exc_info = &gen->gi_exc_state;
962
970
 
963
971
  if (exc) {
@@ -967,15 +975,21 @@ static PySendResult Nuitka_PyGen_gen_send_ex2(PyThreadState *tstate, PyGenObject
967
975
 
968
976
  gen->gi_frame_state = FRAME_EXECUTING;
969
977
  result = _PyEval_EvalFrame(tstate, frame, exc);
978
+ #if PYTHON_VERSION < 0x3c0
970
979
  if (gen->gi_frame_state == FRAME_EXECUTING) {
971
980
  gen->gi_frame_state = FRAME_COMPLETED;
972
981
  }
973
982
  tstate->exc_info = gen->gi_exc_state.previous_item;
974
983
  gen->gi_exc_state.previous_item = NULL;
975
984
 
976
- assert(tstate->cframe->current_frame == frame->previous);
985
+ assert(CURRENT_TSTATE_INTERPRETER_FRAME(tstate) == frame->previous);
977
986
  frame->previous = NULL;
978
-
987
+ #else
988
+ assert(tstate->exc_info == prev_exc_info);
989
+ assert(gen->gi_exc_state.previous_item == NULL);
990
+ assert(gen->gi_frame_state != FRAME_EXECUTING);
991
+ assert(frame->previous == NULL);
992
+ #endif
979
993
  if (result != NULL) {
980
994
  if (gen->gi_frame_state == FRAME_SUSPENDED) {
981
995
  *presult = result;
@@ -985,9 +999,12 @@ static PySendResult Nuitka_PyGen_gen_send_ex2(PyThreadState *tstate, PyGenObject
985
999
  assert(result == Py_None || !PyAsyncGen_CheckExact(gen));
986
1000
 
987
1001
  if (result == Py_None && !PyAsyncGen_CheckExact(gen) && !arg) {
1002
+ // TODO: Have Py_CLEAR_IMMORTAL maybe
1003
+
988
1004
  Py_CLEAR(result);
989
1005
  }
990
1006
  } else {
1007
+ #if PYTHON_VERSION < 0x3c0
991
1008
  if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
992
1009
  const char *msg = "generator raised StopIteration";
993
1010
  if (PyCoro_CheckExact(gen)) {
@@ -1000,12 +1017,20 @@ static PySendResult Nuitka_PyGen_gen_send_ex2(PyThreadState *tstate, PyGenObject
1000
1017
  const char *msg = "async generator raised StopAsyncIteration";
1001
1018
  _PyErr_FormatFromCause(PyExc_RuntimeError, "%s", msg);
1002
1019
  }
1020
+ #else
1021
+ assert(!PyErr_ExceptionMatches(PyExc_StopIteration));
1022
+ assert(!PyAsyncGen_CheckExact(gen) || !PyErr_ExceptionMatches(PyExc_StopAsyncIteration));
1023
+
1024
+ #endif
1003
1025
  }
1004
1026
 
1005
1027
  _PyErr_ClearExcState(&gen->gi_exc_state);
1006
1028
 
1007
1029
  gen->gi_frame_state = FRAME_CLEARED;
1030
+
1031
+ #if PYTHON_VERSION < 0x3c0
1008
1032
  _Nuitka_PyFrame_Clear(tstate, frame);
1033
+ #endif
1009
1034
 
1010
1035
  *presult = result;
1011
1036
  return result ? PYGEN_RETURN : PYGEN_ERROR;
@@ -1022,7 +1047,7 @@ static PyObject *Nuitka_PyGen_gen_send_ex(PyThreadState *tstate, PyGenObject *ge
1022
1047
  } else if (result == Py_None) {
1023
1048
  SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1024
1049
  } else {
1025
- _PyGen_SetStopIterationValue(result);
1050
+ Nuitka_SetStopIterationValue(tstate, result);
1026
1051
  }
1027
1052
 
1028
1053
  Py_DECREF(result);
@@ -1052,8 +1077,7 @@ static PyObject *Nuitka_UncompiledGenerator_throw(PyThreadState *tstate, PyGenOb
1052
1077
  if (yf != NULL) {
1053
1078
  _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
1054
1079
 
1055
- if (close_on_genexit &&
1056
- EXCEPTION_MATCH_BOOL_SINGLE(tstate, exception_state->exception_type, PyExc_GeneratorExit)) {
1080
+ if (close_on_genexit && EXCEPTION_STATE_MATCH_BOOL_SINGLE(tstate, exception_state, PyExc_GeneratorExit)) {
1057
1081
  PyFrameState state = (PyFrameState)gen->gi_frame_state;
1058
1082
  gen->gi_frame_state = FRAME_EXECUTING;
1059
1083
 
@@ -1078,16 +1102,16 @@ static PyObject *Nuitka_UncompiledGenerator_throw(PyThreadState *tstate, PyGenOb
1078
1102
  PyObject *ret;
1079
1103
 
1080
1104
  if (PyGen_CheckExact(yf) || PyCoro_CheckExact(yf)) {
1081
- _PyInterpreterFrame *prev = tstate->cframe->current_frame;
1105
+ _PyInterpreterFrame *prev = CURRENT_TSTATE_INTERPRETER_FRAME(tstate);
1082
1106
  frame->previous = prev;
1083
- tstate->cframe->current_frame = frame;
1107
+ CURRENT_TSTATE_INTERPRETER_FRAME(tstate) = frame;
1084
1108
  PyFrameState state = (PyFrameState)gen->gi_frame_state;
1085
1109
  gen->gi_frame_state = FRAME_EXECUTING;
1086
1110
 
1087
1111
  // Handing exception ownership to "Nuitka_UncompiledGenerator_throw".
1088
1112
  ret = Nuitka_UncompiledGenerator_throw(tstate, (PyGenObject *)yf, close_on_genexit, exception_state);
1089
1113
  gen->gi_frame_state = state;
1090
- tstate->cframe->current_frame = prev;
1114
+ CURRENT_TSTATE_INTERPRETER_FRAME(tstate) = prev;
1091
1115
  frame->previous = NULL;
1092
1116
  } else {
1093
1117
  #if 0
@@ -1125,6 +1149,7 @@ static PyObject *Nuitka_UncompiledGenerator_throw(PyThreadState *tstate, PyGenOb
1125
1149
  Py_DECREF(yf);
1126
1150
 
1127
1151
  if (ret == NULL) {
1152
+ #if PYTHON_VERSION < 0x3c0
1128
1153
  PyObject *val;
1129
1154
  assert(gen->gi_frame_state < FRAME_CLEARED);
1130
1155
  ret = _PyFrame_StackPop((_PyInterpreterFrame *)gen->gi_iframe);
@@ -1137,7 +1162,9 @@ static PyObject *Nuitka_UncompiledGenerator_throw(PyThreadState *tstate, PyGenOb
1137
1162
  if (_PyGen_FetchStopIterationValue(&val) == 0) {
1138
1163
  ret = Nuitka_PyGen_gen_send_ex(tstate, gen, val, 0, 0);
1139
1164
  Py_DECREF(val);
1140
- } else {
1165
+ } else
1166
+ #endif
1167
+ {
1141
1168
  ret = Nuitka_PyGen_gen_send_ex(tstate, gen, Py_None, 1, 0);
1142
1169
  }
1143
1170
  }
@@ -1146,43 +1173,11 @@ static PyObject *Nuitka_UncompiledGenerator_throw(PyThreadState *tstate, PyGenOb
1146
1173
  }
1147
1174
 
1148
1175
  throw_here:
1149
- if (exception_state->exception_tb == (PyTracebackObject *)Py_None) {
1150
- exception_state->exception_tb = NULL;
1151
- Py_DECREF(exception_state->exception_tb);
1152
- } else if (exception_state->exception_tb != NULL && !PyTraceBack_Check(exception_state->exception_tb)) {
1153
- SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "throw() third argument must be a traceback object");
1154
- goto failed_throw;
1155
- }
1156
-
1157
1176
  tstate = _PyThreadState_GET();
1158
1177
 
1159
- if (PyExceptionClass_Check(exception_state->exception_type)) {
1160
- Nuitka_Err_NormalizeException(tstate, &exception_state->exception_type, &exception_state->exception_value,
1161
- &exception_state->exception_tb);
1162
- } else if (PyExceptionInstance_Check(exception_state->exception_type)) {
1163
- if (exception_state->exception_value && exception_state->exception_value != Py_None) {
1164
- SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
1165
- "instance exception may not have a separate value");
1166
- goto failed_throw;
1167
- } else {
1168
- // Normalize manually here via APIs
1169
- Py_XDECREF(exception_state->exception_value);
1170
- exception_state->exception_value = exception_state->exception_type;
1171
- exception_state->exception_type = PyExceptionInstance_Class(exception_state->exception_type);
1172
- Py_INCREF(exception_state->exception_type);
1173
-
1174
- if (exception_state->exception_tb == NULL) {
1175
- // Can remain NULL if no traceback is available.
1176
- exception_state->exception_tb = GET_EXCEPTION_TRACEBACK(exception_state->exception_value);
1177
- Py_XINCREF(exception_state->exception_tb);
1178
- }
1179
- }
1180
- } else {
1181
- // Raisable
1182
- SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
1183
- "exceptions must be classes or instances deriving from BaseException, not %s",
1184
- exception_state->exception_type);
1185
- goto failed_throw;
1178
+ if (unlikely(_Nuitka_Generator_check_throw(tstate, exception_state) == false)) {
1179
+ // Exception was released by _Nuitka_Generator_check_throw already.
1180
+ return NULL;
1186
1181
  }
1187
1182
 
1188
1183
  RESTORE_ERROR_OCCURRED_STATE(tstate, exception_state);
@@ -1360,6 +1355,7 @@ static PyObject *Nuitka_PyGen_gen_send_ex(PyThreadState *tstate, PyGenObject *ge
1360
1355
  Nuitka_SetStopIterationValue(tstate, result);
1361
1356
  }
1362
1357
 
1358
+ // TODO: Add Py_CLEAR_IMMORTAL maybe
1363
1359
  Py_CLEAR(result);
1364
1360
  }
1365
1361
  #if PYTHON_VERSION >= 0x350
@@ -1427,6 +1423,7 @@ static PyObject *Nuitka_PyGen_gen_send_ex(PyThreadState *tstate, PyGenObject *ge
1427
1423
  }
1428
1424
  assert(result == Py_None || !PyAsyncGen_CheckExact(gen));
1429
1425
  if (result == Py_None && !PyAsyncGen_CheckExact(gen) && !arg) {
1426
+ // TODO: Add Py_CLEAR_IMMORTAL maybe
1430
1427
  Py_CLEAR(result);
1431
1428
  }
1432
1429
  } else {
@@ -1709,7 +1706,7 @@ static PyObject *Nuitka_PyGen_gen_close(PyThreadState *tstate, PyGenObject *gen,
1709
1706
  if (PyErr_ExceptionMatches(PyExc_StopIteration) || PyErr_ExceptionMatches(PyExc_GeneratorExit)) {
1710
1707
  CLEAR_ERROR_OCCURRED(tstate);
1711
1708
 
1712
- Py_INCREF(Py_None);
1709
+ Py_INCREF_IMMORTAL(Py_None);
1713
1710
  return Py_None;
1714
1711
  }
1715
1712
  return NULL;
@@ -44,21 +44,19 @@ static PyMemberDef Nuitka_Method_members[] = {
44
44
  {NULL}};
45
45
 
46
46
  static PyObject *Nuitka_Method_reduce(struct Nuitka_MethodObject *method) {
47
- #if PYTHON_VERSION < 0x300
48
47
  PyThreadState *tstate = PyThreadState_GET();
49
48
 
49
+ #if PYTHON_VERSION < 0x300
50
50
  // spell-checker: ignore instancemethod
51
51
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "can't pickle instancemethod objects");
52
52
  return NULL;
53
53
  #elif PYTHON_VERSION < 0x340
54
- PyThreadState *tstate = PyThreadState_GET();
55
-
56
54
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "can't pickle method objects");
57
55
  return NULL;
58
56
  #else
59
- PyObject *result = MAKE_TUPLE_EMPTY(2);
57
+ PyObject *result = MAKE_TUPLE_EMPTY(tstate, 2);
60
58
  PyTuple_SET_ITEM0(result, 0, LOOKUP_BUILTIN(const_str_plain_getattr));
61
- PyObject *arg_tuple = MAKE_TUPLE2(method->m_object, method->m_function->m_name);
59
+ PyObject *arg_tuple = MAKE_TUPLE2(tstate, method->m_object, method->m_function->m_name);
62
60
  PyTuple_SET_ITEM(result, 1, arg_tuple);
63
61
 
64
62
  CHECK_OBJECT_DEEP(result);
@@ -91,13 +89,13 @@ static PyObject *Nuitka_Method_reduce_ex(struct Nuitka_MethodObject *method, PyO
91
89
  return NULL;
92
90
  }
93
91
 
94
- PyObject *result = MAKE_TUPLE_EMPTY(5);
92
+ PyObject *result = MAKE_TUPLE_EMPTY(tstate, 5);
95
93
  PyTuple_SET_ITEM(result, 0, newobj_func);
96
- PyObject *type_tuple = MAKE_TUPLE1((PyObject *)&Nuitka_Method_Type);
94
+ PyObject *type_tuple = MAKE_TUPLE1(tstate, (PyObject *)&Nuitka_Method_Type);
97
95
  PyTuple_SET_ITEM(result, 1, type_tuple);
98
- PyTuple_SET_ITEM0(result, 2, Py_None);
99
- PyTuple_SET_ITEM0(result, 3, Py_None);
100
- PyTuple_SET_ITEM0(result, 4, Py_None);
96
+ PyTuple_SET_ITEM_IMMORTAL(result, 2, Py_None);
97
+ PyTuple_SET_ITEM_IMMORTAL(result, 3, Py_None);
98
+ PyTuple_SET_ITEM_IMMORTAL(result, 4, Py_None);
101
99
 
102
100
  CHECK_OBJECT_DEEP(result);
103
101
 
@@ -323,13 +321,13 @@ static PyObject *Nuitka_Method_tp_repr(struct Nuitka_MethodObject *method) {
323
321
  #endif
324
322
 
325
323
  #if PYTHON_VERSION < 0x350
326
- PyObject *result = Nuitka_String_FromFormat(
327
- "<bound compiled_method %s.%s of %s>", GET_CLASS_NAME(method->m_class),
328
- Nuitka_String_AsString(method->m_function->m_name), Nuitka_String_AsString_Unchecked(object_repr));
324
+ PyObject *result =
325
+ Nuitka_String_FromFormat("<bound compiled_method %s.%s of %s>", GET_CLASS_NAME(method->m_class),
326
+ Nuitka_String_AsString_Unchecked(method->m_function->m_name),
327
+ Nuitka_String_AsString_Unchecked(object_repr));
329
328
  #else
330
- PyObject *result = PyUnicode_FromFormat("<bound compiled_method %s of %s>",
331
- Nuitka_String_AsString(method->m_function->m_qualname),
332
- Nuitka_String_AsString_Unchecked(object_repr));
329
+ PyObject *result =
330
+ PyUnicode_FromFormat("<bound compiled_method %U of %U>", method->m_function->m_qualname, object_repr);
333
331
  #endif
334
332
 
335
333
  Py_DECREF(object_repr);
@@ -399,7 +397,7 @@ static PyObject *Nuitka_Method_tp_richcompare(struct Nuitka_MethodObject *a, str
399
397
  result = BOOL_FROM(!b_res);
400
398
  }
401
399
 
402
- Py_INCREF(result);
400
+ Py_INCREF_IMMORTAL(result);
403
401
  return result;
404
402
  }
405
403