Nuitka-winsvc 2.2.3__cp311-cp311-win_amd64.whl → 2.3__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/RECORD +198 -197
  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 +104 -44
  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 +11 -5
  18. nuitka/build/SconsInterface.py +22 -6
  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 +35 -2
  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 +131 -131
  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 +78 -54
  129. nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +1 -1
  130. nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +8 -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/Onefile.py +0 -1
  157. nuitka/freezer/Standalone.py +3 -1
  158. nuitka/importing/ImportCache.py +3 -2
  159. nuitka/importing/Importing.py +16 -3
  160. nuitka/importing/StandardLibrary.py +4 -0
  161. nuitka/nodes/ChildrenHavingMixins.py +2 -0
  162. nuitka/nodes/ExpressionBasesGenerated.py +4 -0
  163. nuitka/nodes/HardImportNodesGenerated.py +83 -0
  164. nuitka/nodes/ModuleNodes.py +10 -2
  165. nuitka/nodes/OsSysNodes.py +16 -0
  166. nuitka/nodes/SubscriptNodes.py +3 -3
  167. nuitka/plugins/PluginBase.py +2 -0
  168. nuitka/plugins/standard/DataFilesPlugin.py +22 -1
  169. nuitka/plugins/standard/DillPlugin/DillPlugin.c +3 -3
  170. nuitka/plugins/standard/OptionsNannyPlugin.py +9 -41
  171. nuitka/plugins/standard/PkgResourcesPlugin.py +8 -2
  172. nuitka/plugins/standard/PySidePyQtPlugin.py +3 -0
  173. nuitka/plugins/standard/standard.nuitka-package.config.yml +18 -12
  174. nuitka/plugins/standard/stdlib2.nuitka-package.config.yml +2 -2
  175. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +2 -2
  176. nuitka/specs/HardImportSpecs.py +3 -0
  177. nuitka/specs/ParameterSpecs.py +26 -15
  178. nuitka/tools/general/find_module/FindModuleCode.py +3 -2
  179. nuitka/tools/specialize/CTypeDescriptions.py +11 -9
  180. nuitka/tools/testing/Common.py +12 -5
  181. nuitka/tools/testing/SearchModes.py +5 -1
  182. nuitka/tools/watch/GitHub.py +1 -7
  183. nuitka/tree/Building.py +9 -6
  184. nuitka/tree/ReformulationMatchStatements.py +39 -3
  185. nuitka/tree/TreeHelpers.py +8 -0
  186. nuitka/utils/CStrings.py +7 -0
  187. nuitka/utils/Execution.py +10 -1
  188. nuitka/utils/FileOperations.py +21 -13
  189. nuitka/utils/Importing.py +24 -0
  190. nuitka/utils/ReExecute.py +7 -3
  191. nuitka/utils/SharedLibraries.py +17 -0
  192. nuitka/utils/Yaml.py +9 -1
  193. {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.data}/scripts/nuitka-run.bat +0 -0
  194. {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.data}/scripts/nuitka.bat +0 -0
  195. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/LICENSE.txt +0 -0
  196. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/WHEEL +0 -0
  197. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/entry_points.txt +0 -0
  198. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/top_level.txt +0 -0
@@ -39,7 +39,13 @@ from nuitka.Tracing import (
39
39
  setQuiet,
40
40
  )
41
41
  from nuitka.utils.Execution import check_output
42
- from nuitka.utils.FileOperations import getExternalUsePath
42
+ from nuitka.utils.FileOperations import (
43
+ changeFilenameExtension,
44
+ deleteFile,
45
+ getExternalUsePath,
46
+ getFilenameExtension,
47
+ isFilesystemEncodable,
48
+ )
43
49
  from nuitka.utils.Json import loadJsonFromFilename
44
50
  from nuitka.utils.Utils import (
45
51
  isDebianBasedLinux,
@@ -104,18 +110,12 @@ source_dir = getArgumentRequired("source_dir")
104
110
  nuitka_src = getArgumentRequired("nuitka_src")
105
111
  static_src = os.path.join(source_dir, "static")
106
112
 
107
- # The name of executable or extension module that we produce.
108
- result_base_path = getArgumentRequired("result_name")
109
-
110
- # The name of executable that we produce (in executable mode).
111
- result_exe = getArgumentDefaulted("result_exe", None)
113
+ # The name of executable that we are supposed to produce.
114
+ result_exe = getArgumentRequired("result_exe")
112
115
 
113
116
  # Name of the main program (in executable mode, typically __main__ but can be in a package too.)
114
117
  main_module_name = getArgumentDefaulted("main_module_name", "__main__")
115
118
 
116
- # The suffix for an extension module (in module mode).
117
- module_suffix = getArgumentDefaulted("module_suffix", None)
118
-
119
119
  # Full names shall be used, no remapping for cacheable filenames.
120
120
  full_names = getArgumentBool("full_names", False)
121
121
 
@@ -167,8 +167,8 @@ lto_mode = getArgumentDefaulted("lto_mode", "auto")
167
167
  # PGO mode: Use profile guided optimization of C compiler if available.
168
168
  pgo_mode = getArgumentDefaulted("pgo_mode", "no")
169
169
 
170
- # Windows subsystem mode: Disable console for windows builds.
171
- disable_console = getArgumentBool("disable_console", False)
170
+ # Console mode specified
171
+ console_mode = getArgumentDefaulted("console_mode", "attach")
172
172
 
173
173
  # Windows might be running a Python whose DLL we have to use.
174
174
  uninstalled_python = getArgumentBool("uninstalled_python", False)
@@ -354,7 +354,7 @@ env.the_cc_name = os.path.normcase(os.path.basename(env.the_compiler))
354
354
  env.standalone_mode = standalone_mode
355
355
  env.debug_mode = debug_mode
356
356
  env.unstripped_mode = unstripped_mode
357
- env.disable_console = disable_console
357
+ env.console_mode = console_mode
358
358
  env.source_dir = source_dir
359
359
  env.nuitka_src = nuitka_src
360
360
  env.low_memory = low_memory
@@ -470,6 +470,8 @@ if env.debug_mode:
470
470
  "-Werror",
471
471
  ]
472
472
  )
473
+ else:
474
+ env.Append(CCFLAGS=["-Wno-unused-but-set-variable"])
473
475
 
474
476
  env.Append(
475
477
  CCFLAGS=[
@@ -504,6 +506,9 @@ if env.debug_mode:
504
506
  if python_version >= (3, 4):
505
507
  env.Append(CCFLAGS=["/wd4512", "/wd4510", "/wd4610"])
506
508
 
509
+ if python_version >= (3, 13):
510
+ env.Append(CCFLAGS=["/wd4324"])
511
+
507
512
  # We use null arrays in our structure Python declarations, which C11 does
508
513
  # not really allow, but should work.
509
514
  env.Append(CCFLAGS=["/wd4200"])
@@ -637,6 +642,9 @@ not satisfied!"""
637
642
  % ("debug" if python_debug else "development", candidates)
638
643
  )
639
644
 
645
+ if python_version >= (3, 13):
646
+ yield os.path.join(candidate, "internal", "mimalloc")
647
+
640
648
  if env.self_compiled_python_uninstalled:
641
649
  yield python_prefix_external
642
650
 
@@ -908,9 +916,32 @@ def discoverSourceFiles():
908
916
 
909
917
  source_files = discoverSourceFiles()
910
918
 
919
+ # Remove the target file to avoid cases where it falsely doesn't get rebuild
920
+ # and then lingers from previous builds,
921
+ deleteFile(result_exe, must_exist=False)
922
+
923
+ # Workaround for MinGW64 not supporting unicode result paths for "-o" basename.
924
+ if os.name == "nt" and not isFilesystemEncodable(result_exe):
925
+ result_exe = os.path.join(
926
+ os.path.dirname(result_exe),
927
+ "_nuitka_temp.pyd" if module_mode else "_nuitka_temp.exe",
928
+ )
929
+
930
+ deleteFile(result_exe, must_exist=False)
931
+
911
932
  if module_mode:
912
- # For Python modules, the standard shared library extension is not what
913
- # gets used. spell-checker: ignore SHLIBSUFFIX
933
+ # For Python modules, the standard shared library extension is not what gets
934
+ # used. spell-checker: ignore SHLIBSUFFIX
935
+ module_suffix = getFilenameExtension(result_exe)
936
+ result_base_path = changeFilenameExtension(result_exe, "")
937
+
938
+ extra_suffix = getFilenameExtension(result_base_path)
939
+ if extra_suffix != "":
940
+ module_suffix = extra_suffix + module_suffix
941
+ result_base_path = changeFilenameExtension(result_base_path, "")
942
+
943
+ assert getFilenameExtension(result_base_path) == "", result_base_path
944
+
914
945
  env["SHLIBSUFFIX"] = module_suffix
915
946
 
916
947
  target = env.SharedLibrary(
@@ -922,10 +953,6 @@ else:
922
953
  # Use compiler/linker flags provided via environment variables
923
954
  importEnvironmentVariableSettings(env)
924
955
 
925
- # Remove the target file to avoid cases where it falsely doesn't get rebuild
926
- # and then lingers from previous builds,
927
- if os.path.exists(target[0].abspath):
928
- os.unlink(target[0].abspath)
929
956
 
930
957
  if job_count:
931
958
  scons_details_logger.info("Told to run compilation on %d CPUs." % job_count)
@@ -1059,7 +1086,7 @@ if env.msvc_mode and not disable_ccache:
1059
1086
  source_dir=source_dir,
1060
1087
  )
1061
1088
 
1062
- writeSconsReport(env)
1089
+ writeSconsReport(env=env, target=target)
1063
1090
 
1064
1091
  setSconsProgressBarTotal(name=env.progressbar_name, total=len(source_files))
1065
1092
 
@@ -87,8 +87,8 @@ experimental = getArgumentList("experimental", "")
87
87
  # good with the compiler in question.
88
88
  lto_mode = getArgumentDefaulted("lto_mode", "auto")
89
89
 
90
- # Windows subsystem mode: Disable console for windows builds.
91
- disable_console = getArgumentBool("disable_console", False)
90
+ # Console mode specified
91
+ console_mode = getArgumentDefaulted("console_mode", "attach")
92
92
 
93
93
  # Unstripped mode: Do not remove debug symbols.
94
94
  unstripped_mode = getArgumentBool("unstripped_mode", False)
@@ -207,7 +207,7 @@ env.the_compiler = env["CC"] or env["CXX"]
207
207
  env.the_cc_name = os.path.normcase(os.path.basename(env.the_compiler))
208
208
  env.debug_mode = debug_mode
209
209
  env.unstripped_mode = unstripped_mode
210
- env.disable_console = disable_console
210
+ env.console_mode = console_mode
211
211
  env.nuitka_src = nuitka_src
212
212
  env.low_memory = False
213
213
  env.macos_min_version = macos_min_version
@@ -126,8 +126,8 @@ trace_mode = getArgumentBool("trace_mode", False)
126
126
  # good with the compiler in question.
127
127
  lto_mode = getArgumentDefaulted("lto_mode", "auto")
128
128
 
129
- # Windows subsystem mode: Disable console for windows builds.
130
- disable_console = getArgumentBool("disable_console", False)
129
+ # Console mode specified
130
+ console_mode = getArgumentDefaulted("console_mode", "attach")
131
131
 
132
132
  # Unstripped mode: Do not remove debug symbols.
133
133
  unstripped_mode = getArgumentBool("unstripped_mode", False)
@@ -265,7 +265,7 @@ env.the_cc_name = os.path.normcase(os.path.basename(env.the_compiler))
265
265
  env.standalone_mode = True # We are only used in this case.
266
266
  env.debug_mode = debug_mode
267
267
  env.unstripped_mode = unstripped_mode
268
- env.disable_console = disable_console
268
+ env.console_mode = console_mode
269
269
  env.source_dir = source_dir
270
270
  env.nuitka_src = nuitka_src
271
271
  env.low_memory = False # Never a concern in this case.
@@ -537,7 +537,7 @@ if env.gcc_mode:
537
537
  env=env,
538
538
  )
539
539
 
540
- writeSconsReport(env)
540
+ writeSconsReport(env=env, target=target)
541
541
 
542
542
  setSconsProgressBarTotal(name="Onefile", total=len(source_files))
543
543
 
@@ -143,8 +143,9 @@ def enableCcache(
143
143
 
144
144
  if inject_ccache:
145
145
  # The ccache needs absolute path, otherwise it will not work.
146
- ccache_logfile = os.path.abspath(
147
- os.path.join(source_dir, "ccache-%d.txt" % os.getpid())
146
+ ccache_logfile = getExternalUsePath(
147
+ os.path.abspath(os.path.join(source_dir, "ccache-%d.txt" % os.getpid())),
148
+ only_dirname=True,
148
149
  )
149
150
 
150
151
  setEnvironmentVariable(env, "CCACHE_LOGFILE", ccache_logfile)
@@ -637,7 +637,7 @@ def setupCCompiler(env, lto_mode, pgo_mode, job_count, onefile_compile):
637
637
  # Don't export anything by default, this should create smaller executables.
638
638
  env.Append(CCFLAGS=["-fvisibility=hidden", "-fvisibility-inlines-hidden"])
639
639
 
640
- if env.debug_mode:
640
+ if env.debug_mode and "allow-c-warnings" not in env.experimental_flags:
641
641
  env.Append(CCFLAGS=["-Wunused-but-set-variable"])
642
642
 
643
643
  # Support for macOS standalone to run on older OS versions.
@@ -780,12 +780,18 @@ def setupCCompiler(env, lto_mode, pgo_mode, job_count, onefile_compile):
780
780
  if not env.clang_mode:
781
781
  env.Append(LINKFLAGS=["-Wl,--enable-auto-import"])
782
782
 
783
- if env.disable_console:
783
+ # Even if console is forced, for Win32 it means to specify Windows
784
+ # subsystem, we can still attach or create.
785
+ if env.console_mode != "force":
786
+ if env.mingw_mode:
784
787
  env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
785
-
786
- if env.mingw_mode or env.msvc_mode:
787
- if env.disable_console:
788
788
  env.Append(CPPDEFINES=["_NUITKA_WINMAIN_ENTRY_POINT"])
789
+ elif env.msvc_mode:
790
+ env.Append(LINKFLAGS=["/SUBSYSTEM:windows"])
791
+ env.Append(CPPDEFINES=["_NUITKA_WINMAIN_ENTRY_POINT"])
792
+
793
+ if env.console_mode == "attach" and os.name == "nt":
794
+ env.Append(CPPDEFINES=["_NUITKA_ATTACH_CONSOLE_WINDOW"])
789
795
 
790
796
  # Avoid dependency on MinGW libraries, spell-checker: ignore libgcc
791
797
  if env.mingw_mode and not env.clang_mode:
@@ -37,6 +37,7 @@ from nuitka.utils.Execution import (
37
37
  withEnvironmentVarsOverridden,
38
38
  )
39
39
  from nuitka.utils.FileOperations import (
40
+ areSamePaths,
40
41
  changeFilenameExtension,
41
42
  deleteFile,
42
43
  getDirectoryRealPath,
@@ -46,6 +47,7 @@ from nuitka.utils.FileOperations import (
46
47
  listDir,
47
48
  makePath,
48
49
  putTextFileContents,
50
+ renameFile,
49
51
  withDirectoryChange,
50
52
  )
51
53
  from nuitka.utils.InstalledPythons import findInstalledPython
@@ -58,7 +60,7 @@ from nuitka.utils.Utils import (
58
60
  )
59
61
 
60
62
  from .SconsCaching import checkCachingSuccess
61
- from .SconsUtils import flushSconsReports
63
+ from .SconsUtils import flushSconsReports, getSconsReportValue
62
64
 
63
65
 
64
66
  def getSconsDataPath():
@@ -336,10 +338,9 @@ def runScons(options, env_values, scons_filename):
336
338
  options = copy.deepcopy(options)
337
339
  source_dir = options["source_dir"]
338
340
  options["source_dir"] = "."
339
- options["result_name"] = getExternalUsePath(
340
- options["result_name"], only_dirname=True
341
- )
342
341
  options["nuitka_src"] = getExternalUsePath(options["nuitka_src"])
342
+
343
+ orig_result_exe = options.get("result_exe")
343
344
  if "result_exe" in options:
344
345
  options["result_exe"] = getExternalUsePath(
345
346
  options["result_exe"], only_dirname=True
@@ -370,6 +371,7 @@ def runScons(options, env_values, scons_filename):
370
371
  source_dir=source_dir, scons_command=scons_command
371
372
  )
372
373
 
374
+ source_dir = getExternalUsePath(source_dir)
373
375
  try:
374
376
  result = subprocess.call(scons_command, shell=False, cwd=source_dir)
375
377
  except KeyboardInterrupt:
@@ -380,6 +382,20 @@ def runScons(options, env_values, scons_filename):
380
382
  flushSconsReports()
381
383
 
382
384
  if "source_dir" in options and result == 0:
385
+ if "result_exe" in options:
386
+ scons_created_exe = getSconsReportValue(
387
+ source_dir or options["source_dir"], "TARGET"
388
+ )
389
+
390
+ if not os.path.exists(scons_created_exe):
391
+ Tracing.scons_logger.sysexit(
392
+ "Error, scons failed to create the expected file %r. "
393
+ % scons_created_exe
394
+ )
395
+
396
+ if not areSamePaths(options["result_exe"], scons_created_exe):
397
+ renameFile(scons_created_exe, orig_result_exe)
398
+
383
399
  checkCachingSuccess(source_dir or options["source_dir"])
384
400
 
385
401
  return result == 0
@@ -475,8 +491,8 @@ def setCommonSconsOptions(options):
475
491
  if Options.shallDisableCCacheUsage():
476
492
  options["disable_ccache"] = asBoolStr(True)
477
493
 
478
- if Options.shallDisableConsoleWindow() and Options.mayDisableConsoleWindow():
479
- options["disable_console"] = asBoolStr(True)
494
+ if isWin32Windows() and Options.getWindowsConsoleMode() != "attach":
495
+ options["console_mode"] = Options.getWindowsConsoleMode()
480
496
 
481
497
  if Options.getLtoMode() != "auto":
482
498
  options["lto_mode"] = Options.getLtoMode()
@@ -18,7 +18,9 @@ from nuitka.containers.OrderedDicts import OrderedDict
18
18
  from nuitka.Tracing import scons_details_logger, scons_logger
19
19
  from nuitka.utils.Execution import executeProcess
20
20
  from nuitka.utils.FileOperations import (
21
+ changeFilenameExtension,
21
22
  getFileContentByLine,
23
+ getFilenameExtension,
22
24
  getWindowsShortPathName,
23
25
  hasFilenameExtension,
24
26
  isFilesystemEncodable,
@@ -359,7 +361,7 @@ def addToPATH(env, dirname, prefix):
359
361
  setEnvironmentVariable(env, "PATH", os.pathsep.join(path_value))
360
362
 
361
363
 
362
- def writeSconsReport(env):
364
+ def writeSconsReport(env, target):
363
365
  with openTextFile(
364
366
  _getSconsReportFilename(env.source_dir), "w", encoding="utf8"
365
367
  ) as report_file:
@@ -390,6 +392,7 @@ def writeSconsReport(env):
390
392
  print("clangcl_mode=%s" % env.clangcl_mode, file=report_file)
391
393
 
392
394
  print("PATH=%s" % os.environ["PATH"], file=report_file)
395
+ print("TARGET=%s" % target[0].abspath, file=report_file)
393
396
 
394
397
 
395
398
  def reportSconsUnexpectedOutput(env, cmdline, stdout, stderr):
@@ -624,6 +627,11 @@ def scanSourceDir(env, dirname, plugins):
624
627
  if isWin32Windows() and not isFilesystemEncodable(filename_base):
625
628
  target_filename = getWindowsShortPathName(target_filename)
626
629
 
630
+ # Avoid ".C" suffixes, that MinGW64 wouldn't recognize.
631
+ target_filename = changeFilenameExtension(
632
+ target_filename, getFilenameExtension(target_filename).lower()
633
+ )
634
+
627
635
  # We pretend to use C++ if no C11 compiler is present.
628
636
  if env.c11_mode:
629
637
  yield target_filename
@@ -13,6 +13,39 @@
13
13
  #define _PyObject_GC_IS_TRACKED(obj) (1)
14
14
  #endif
15
15
 
16
+ // The full API is available for Python 3.5 only
17
+ #if PYTHON_VERSION >= 0x350 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_ALLOCATORS)
18
+ extern void *(*python_obj_malloc)(void *ctx, size_t size);
19
+ extern void *(*python_mem_malloc)(void *ctx, size_t size);
20
+ extern void *(*python_mem_calloc)(void *ctx, size_t nelem, size_t elsize);
21
+
22
+ #if defined(Py_DEBUG)
23
+ extern void *python_obj_ctx;
24
+ extern void *python_mem_ctx;
25
+ #else
26
+ #define python_obj_ctx (NULL)
27
+ #define python_mem_ctx (NULL)
28
+ #endif
29
+
30
+ extern void initNuitkaAllocators(void);
31
+
32
+ // Our version of "PyObject_Malloc".
33
+ NUITKA_MAY_BE_UNUSED static void *NuitkaObject_Malloc(size_t size) { return python_obj_malloc(python_obj_ctx, size); }
34
+
35
+ // Our version of "PyMem_Malloc".
36
+ NUITKA_MAY_BE_UNUSED static void *NuitkaMem_Malloc(size_t size) { return python_mem_malloc(python_mem_ctx, size); }
37
+
38
+ // Our version of "PyMem_Calloc".
39
+ NUITKA_MAY_BE_UNUSED static void *NuitkaMem_Calloc(size_t nelem, size_t elsize) {
40
+ return python_mem_calloc(python_mem_ctx, nelem, elsize);
41
+ }
42
+
43
+ #else
44
+ #define NuitkaObject_Malloc(size) PyObject_MALLOC(size)
45
+ #define NuitkaMem_Malloc(size) PyMem_MALLOC(size)
46
+ #define NuitkaMem_Calloc(elem, elsize) PyMem_CALLOC(elem, elsize)
47
+ #endif
48
+
16
49
  #if PYTHON_VERSION >= 0x380 && PYTHON_VERSION < 0x3c0
17
50
  // Need to make Py_DECREF a macro again that doesn't call an API
18
51
  static inline void _Nuitka_Py_DECREF(PyObject *ob) {
@@ -71,6 +104,18 @@ static inline void _Nuitka_Py_XDECREF(PyObject *ob) {
71
104
 
72
105
  #endif
73
106
 
107
+ // For Python3.12, avoid reference management if value is known to be immortal.
108
+ #if PYTHON_VERSION < 0x3c0
109
+ #define Py_INCREF_IMMORTAL(value) Py_INCREF(value)
110
+ #define Py_DECREF_IMMORTAL(value) Py_DECREF(value)
111
+ #elif defined(__NUITKA_NO_ASSERT__)
112
+ #define Py_INCREF_IMMORTAL(value)
113
+ #define Py_DECREF_IMMORTAL(value)
114
+ #else
115
+ #define Py_INCREF_IMMORTAL(value) assert(Py_REFCNT(value) == _Py_IMMORTAL_REFCNT)
116
+ #define Py_DECREF_IMMORTAL(value) assert(Py_REFCNT(value) == _Py_IMMORTAL_REFCNT)
117
+ #endif
118
+
74
119
  // Macro introduced with Python3.9 or higher, make it generally available.
75
120
  #ifndef Py_SET_TYPE
76
121
  static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type) { ob->ob_type = type; }
@@ -116,7 +161,7 @@ static PyObject *Nuitka_PyType_AllocNoTrackVar(PyTypeObject *type, Py_ssize_t ni
116
161
  const size_t pre_size = Nuitka_PyType_PreHeaderSize(type);
117
162
  assert(pre_size == sizeof(PyGC_Head));
118
163
 
119
- char *alloc = (char *)PyObject_Malloc(size + pre_size);
164
+ char *alloc = (char *)NuitkaObject_Malloc(size + pre_size);
120
165
  assert(alloc);
121
166
  PyObject *obj = (PyObject *)(alloc + pre_size);
122
167
 
@@ -151,7 +196,7 @@ static PyObject *Nuitka_PyType_AllocNoTrack(PyTypeObject *type) {
151
196
  // TODO: This ought to be static for all our types, so remove it as a call.
152
197
  const size_t pre_size = Nuitka_PyType_PreHeaderSize(type);
153
198
 
154
- char *alloc = (char *)PyObject_Malloc(_PyObject_SIZE(type) + pre_size);
199
+ char *alloc = (char *)NuitkaObject_Malloc(_PyObject_SIZE(type) + pre_size);
155
200
  assert(alloc);
156
201
  PyObject *obj = (PyObject *)(alloc + pre_size);
157
202
 
@@ -229,6 +274,17 @@ NUITKA_MAY_BE_UNUSED static void *Nuitka_GC_New(PyTypeObject *type) {
229
274
  return op;
230
275
  }
231
276
 
277
+ static bool inline Nuitka_GC_IS_TRACKED_X(PyObject *object) {
278
+ return object == NULL || _PyObject_GC_IS_TRACKED(object);
279
+ }
280
+
281
+ // To allow us marking some of our own values as immortal.
282
+ #if PYTHON_VERSION >= 0x3c0
283
+ static void inline Py_SET_REFCNT_IMMORTAL(PyObject *object) { object->ob_refcnt = _Py_IMMORTAL_REFCNT; }
284
+ #else
285
+ #define Py_SET_REFCNT_IMMORTAL(object)
286
+ #endif
287
+
232
288
  #endif
233
289
 
234
290
  // Part of "Nuitka", an optimizing Python compiler that is compatible and
@@ -90,11 +90,27 @@ NUITKA_MAY_BE_UNUSED static inline bool isFakeCodeObject(PyCodeObject *code) {
90
90
 
91
91
  extern PyTypeObject Nuitka_Frame_Type;
92
92
 
93
- static inline bool Nuitka_Frame_Check(PyObject *object) {
93
+ static inline bool Nuitka_Frame_CheckExact(PyObject *object) {
94
94
  CHECK_OBJECT(object);
95
95
  return Py_TYPE(object) == &Nuitka_Frame_Type;
96
96
  }
97
97
 
98
+ static inline bool Nuitka_Frame_Check(PyObject *object) {
99
+ assert(object);
100
+
101
+ if (!_PyObject_GC_IS_TRACKED(object)) {
102
+ return false;
103
+ }
104
+
105
+ CHECK_OBJECT(object);
106
+
107
+ if (Nuitka_Frame_CheckExact(object)) {
108
+ return true;
109
+ }
110
+
111
+ return strcmp(Py_TYPE(object)->tp_name, "compiled_frame") == 0;
112
+ }
113
+
98
114
  struct Nuitka_FrameObject {
99
115
  PyFrameObject m_frame;
100
116
 
@@ -154,10 +170,20 @@ extern int count_hit_frame_cache_instances;
154
170
  extern void dumpFrameStack(void);
155
171
  #endif
156
172
 
173
+ #if PYTHON_VERSION >= 0x3b0
174
+ inline static PyCodeObject *Nuitka_InterpreterFrame_GetCodeObject(_PyInterpreterFrame *frame) {
175
+ #if PYTHON_VERSION < 0x3d0
176
+ return frame->f_code;
177
+ #else
178
+ return (PyCodeObject *)frame->f_executable;
179
+ #endif
180
+ }
181
+ #endif
182
+
157
183
  inline static PyCodeObject *Nuitka_Frame_GetCodeObject(PyFrameObject *frame) {
158
184
  #if PYTHON_VERSION >= 0x3b0
159
185
  assert(frame->f_frame);
160
- return frame->f_frame->f_code;
186
+ return Nuitka_InterpreterFrame_GetCodeObject(frame->f_frame);
161
187
  #else
162
188
  return frame->f_code;
163
189
  #endif
@@ -168,6 +194,7 @@ inline static void assertPythonFrameObject(PyFrameObject *frame_object) {
168
194
  // TODO: Need to do this manually, as this is making frame caching code
169
195
  // vulnerable to mistakes, but so far the compiled frame type is private
170
196
  // assert(PyObject_IsInstance((PyObject *)frame_object, (PyObject *)&PyFrame_Type));
197
+ CHECK_OBJECT(frame_object);
171
198
 
172
199
  CHECK_CODE_OBJECT(Nuitka_Frame_GetCodeObject(frame_object));
173
200
  }
@@ -256,14 +283,23 @@ static inline bool Nuitka_Frame_IsExecuting(struct Nuitka_FrameObject *frame) {
256
283
  #endif
257
284
 
258
285
  #if PYTHON_VERSION >= 0x3b0
286
+
287
+ #if PYTHON_VERSION < 0x3d0
288
+ #define CURRENT_TSTATE_INTERPRETER_FRAME(tstate) tstate->cframe->current_frame
289
+ #else
290
+ #define CURRENT_TSTATE_INTERPRETER_FRAME(tstate) tstate->current_frame
291
+ #endif
292
+
259
293
  NUITKA_MAY_BE_UNUSED inline static void pushFrameStackInterpreterFrame(PyThreadState *tstate,
260
294
  _PyInterpreterFrame *interpreter_frame) {
261
- _PyInterpreterFrame *old = tstate->cframe->current_frame;
295
+ _PyInterpreterFrame *old = CURRENT_TSTATE_INTERPRETER_FRAME(tstate);
262
296
  interpreter_frame->previous = old;
263
- tstate->cframe->current_frame = interpreter_frame;
297
+ CURRENT_TSTATE_INTERPRETER_FRAME(tstate) = interpreter_frame;
264
298
 
265
- if (old != NULL && interpreter_frame->frame_obj) {
299
+ if (old != NULL && !_PyFrame_IsIncomplete(old) && interpreter_frame->frame_obj) {
266
300
  interpreter_frame->frame_obj->f_back = old->frame_obj;
301
+ CHECK_OBJECT_X(old->frame_obj);
302
+
267
303
  Py_XINCREF(old->frame_obj);
268
304
  }
269
305
  }
@@ -281,7 +317,7 @@ NUITKA_MAY_BE_UNUSED inline static void pushFrameStackPythonFrame(PyThreadState
281
317
 
282
318
  if (old) {
283
319
  assertPythonFrameObject(old);
284
- CHECK_CODE_OBJECT(old->f_code);
320
+ CHECK_CODE_OBJECT(Nuitka_Frame_GetCodeObject(old));
285
321
  }
286
322
 
287
323
  // No recursion with identical frames allowed, assert against it.
@@ -292,7 +328,6 @@ NUITKA_MAY_BE_UNUSED inline static void pushFrameStackPythonFrame(PyThreadState
292
328
 
293
329
  // Transfer ownership of old frame.
294
330
  if (old != NULL) {
295
-
296
331
  frame_object->f_back = old;
297
332
  }
298
333
 
@@ -336,13 +371,13 @@ NUITKA_MAY_BE_UNUSED inline static void popFrameStack(PyThreadState *tstate) {
336
371
  Nuitka_Frame_MarkAsNotExecuting(frame_object);
337
372
  Py_DECREF(frame_object);
338
373
  #else
339
- assert(tstate->cframe);
340
- assert(tstate->cframe->current_frame);
374
+ assert(CURRENT_TSTATE_INTERPRETER_FRAME(tstate));
341
375
 
342
- struct Nuitka_FrameObject *frame_object = (struct Nuitka_FrameObject *)tstate->cframe->current_frame->frame_obj;
376
+ struct Nuitka_FrameObject *frame_object =
377
+ (struct Nuitka_FrameObject *)CURRENT_TSTATE_INTERPRETER_FRAME(tstate)->frame_obj;
343
378
  CHECK_OBJECT(frame_object);
344
379
 
345
- tstate->cframe->current_frame = tstate->cframe->current_frame->previous;
380
+ CURRENT_TSTATE_INTERPRETER_FRAME(tstate) = CURRENT_TSTATE_INTERPRETER_FRAME(tstate)->previous;
346
381
 
347
382
  Nuitka_Frame_MarkAsNotExecuting(frame_object);
348
383
 
@@ -389,7 +424,7 @@ NUITKA_MAY_BE_UNUSED static PyCodeObject *Nuitka_GetFrameCodeObject(struct Nuitk
389
424
  #if PYTHON_VERSION < 0x3b0
390
425
  return nuitka_frame->m_frame.f_code;
391
426
  #else
392
- return nuitka_frame->m_interpreter_frame.f_code;
427
+ return Nuitka_InterpreterFrame_GetCodeObject(&nuitka_frame->m_interpreter_frame);
393
428
  #endif
394
429
  }
395
430
 
@@ -415,7 +450,7 @@ NUITKA_MAY_BE_UNUSED static Nuitka_ThreadStateFrameType *_Nuitka_GetThreadStateF
415
450
  #if PYTHON_VERSION < 0x3b0
416
451
  return tstate->frame;
417
452
  #else
418
- return tstate->cframe->current_frame;
453
+ return CURRENT_TSTATE_INTERPRETER_FRAME(tstate);
419
454
  #endif
420
455
  }
421
456
 
@@ -71,6 +71,10 @@ struct Nuitka_FunctionObject {
71
71
  PyObject *m_qualname;
72
72
  #endif
73
73
 
74
+ #if PYTHON_VERSION >= 0x3c0
75
+ PyObject *m_type_params;
76
+ #endif
77
+
74
78
  // Constant return value to use.
75
79
  PyObject *m_constant_return_value;
76
80
 
@@ -91,6 +91,8 @@ extern PyObject **global_constants;
91
91
  #define const_str_plain_open global_constants[30]
92
92
  // 'keys'
93
93
  #define const_str_plain_keys global_constants[30]
94
+ // 'get'
95
+ #define const_str_plain_get global_constants[30]
94
96
  // 'as_file'
95
97
  #define const_str_plain_as_file global_constants[30]
96
98
  // 'register'
@@ -115,6 +117,10 @@ extern PyObject **global_constants;
115
117
  #define const_str_plain_classmethod global_constants[36]
116
118
  // 'name'
117
119
  #define const_str_plain_name global_constants[37]
120
+ // 'ascii'
121
+ #define const_str_plain_ascii global_constants[37]
122
+ // 'punycode'
123
+ #define const_str_plain_punycode global_constants[37]
118
124
  // 'globals'
119
125
  #define const_str_plain_globals global_constants[38]
120
126
  // 'locals'
@@ -82,9 +82,9 @@ NUITKA_MAY_BE_UNUSED static int EXCEPTION_GROUP_MATCH(PyThreadState *tstate, PyO
82
82
  // TODO: Avoid this from happening, we should not call it then.
83
83
  if (exc_value == Py_None) {
84
84
  *match = Py_None;
85
- Py_INCREF(*match);
85
+ Py_INCREF_IMMORTAL(*match);
86
86
  *rest = Py_None;
87
- Py_INCREF(*rest);
87
+ Py_INCREF_IMMORTAL(*rest);
88
88
 
89
89
  return 0;
90
90
  }
@@ -100,7 +100,7 @@ NUITKA_MAY_BE_UNUSED static int EXCEPTION_GROUP_MATCH(PyThreadState *tstate, PyO
100
100
  Py_INCREF(*match);
101
101
  } else {
102
102
  // Old style plain exception, put it into an exception group.
103
- PyObject *exception_tuple = MAKE_TUPLE1_0(exc_value);
103
+ PyObject *exception_tuple = MAKE_TUPLE1_0(tstate, exc_value);
104
104
  PyObject *wrapped = _PyExc_CreateExceptionGroup("", exception_tuple);
105
105
  Py_DECREF(exception_tuple);
106
106
 
@@ -112,7 +112,7 @@ NUITKA_MAY_BE_UNUSED static int EXCEPTION_GROUP_MATCH(PyThreadState *tstate, PyO
112
112
  }
113
113
 
114
114
  *rest = Py_None;
115
- Py_INCREF(*rest);
115
+ Py_INCREF_IMMORTAL(*rest);
116
116
 
117
117
  return 0;
118
118
  }
@@ -142,10 +142,10 @@ NUITKA_MAY_BE_UNUSED static int EXCEPTION_GROUP_MATCH(PyThreadState *tstate, PyO
142
142
  }
143
143
 
144
144
  *match = Py_None;
145
- Py_INCREF(*match);
145
+ Py_INCREF_IMMORTAL(*match);
146
146
 
147
147
  *rest = Py_None;
148
- Py_INCREF(*rest);
148
+ Py_INCREF_IMMORTAL(*rest);
149
149
 
150
150
  return 0;
151
151
  }
@@ -535,7 +535,7 @@ NUITKA_MAY_BE_UNUSED static inline void PRESERVE_FRAME_EXCEPTION(PyThreadState *
535
535
  PRINT_STRING("PRESERVE_FRAME_EXCEPTION: no exception to preserve\n");
536
536
  #endif
537
537
  frame->f_exc_type = Py_None;
538
- Py_INCREF(frame->f_exc_type);
538
+ Py_INCREF_IMMORTAL(frame->f_exc_type);
539
539
  frame->f_exc_value = NULL;
540
540
  frame->f_exc_traceback = NULL;
541
541
  }
@@ -751,7 +751,7 @@ extern void FORMAT_UNBOUND_CLOSURE_ERROR(PyObject **exception_type, PyObject **e
751
751
  PyObject *variable_name);
752
752
 
753
753
  #if PYTHON_VERSION >= 0x3c0
754
- NUITKA_MAY_BE_UNUSED static PyObject *MAKE_TUPLE1(PyObject *element1);
754
+ NUITKA_MAY_BE_UNUSED static PyObject *MAKE_TUPLE1(PyThreadState *tstate, PyObject *element1);
755
755
 
756
756
  NUITKA_MAY_BE_UNUSED static PyObject *MAKE_EXCEPTION_FROM_TYPE_ARG0(PyThreadState *tstate, PyObject *type,
757
757
  PyObject *arg) {
@@ -769,7 +769,7 @@ NUITKA_MAY_BE_UNUSED static PyObject *MAKE_EXCEPTION_FROM_TYPE_ARG0(PyThreadStat
769
769
  assert(arg != NULL);
770
770
 
771
771
  if (!PyTuple_Check(arg)) {
772
- self->args = MAKE_TUPLE1(arg);
772
+ self->args = MAKE_TUPLE1(tstate, arg);
773
773
  } else {
774
774
  self->args = Py_NewRef(arg);
775
775
  }