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
@@ -82,6 +82,7 @@ def getConstantDefaultPopulation():
82
82
  "staticmethod",
83
83
  "classmethod",
84
84
  "keys",
85
+ "get",
85
86
  # Arguments of __import__ built-in used in helper code.
86
87
  "name",
87
88
  "globals",
@@ -182,6 +183,10 @@ def getConstantDefaultPopulation():
182
183
  # Patching the types module.
183
184
  result.append("types")
184
185
 
186
+ # Converting module names
187
+ result.append("ascii")
188
+ result.append("punycode")
189
+
185
190
  if not Options.shallMakeModule():
186
191
  result.append("__main__")
187
192
 
@@ -62,7 +62,7 @@ def generateBuiltinLocalsCode(to_name, expression, emit, context):
62
62
  # TODO: Creation is not needed for classes.
63
63
  emit(
64
64
  """\
65
- if (%(locals_dict)s == NULL) %(locals_dict)s = MAKE_DICT_EMPTY();
65
+ if (%(locals_dict)s == NULL) %(locals_dict)s = MAKE_DICT_EMPTY(tstate);
66
66
  %(to_name)s = %(locals_dict)s;
67
67
  Py_INCREF(%(to_name)s);"""
68
68
  % {"to_name": value_name, "locals_dict": locals_declaration}
@@ -71,7 +71,7 @@ Py_INCREF(%(to_name)s);"""
71
71
 
72
72
  initial = False
73
73
  else:
74
- emit("%s = MAKE_DICT_EMPTY();" % (to_name,))
74
+ emit("%s = MAKE_DICT_EMPTY(tstate);" % (to_name,))
75
75
 
76
76
  context.addCleanupTempName(value_name)
77
77
 
@@ -54,7 +54,7 @@ def generateListCreationCode(to_name, expression, emit, context):
54
54
 
55
55
  helper_code = generateElementCode(elements[0])
56
56
 
57
- emit("%s = MAKE_LIST_EMPTY(%d);" % (result_name, len(elements)))
57
+ emit("%s = MAKE_LIST_EMPTY(tstate, %d);" % (result_name, len(elements)))
58
58
 
59
59
  needs_exception_exit = any(
60
60
  element.mayRaiseException(BaseException) for element in elements[1:]
@@ -187,7 +187,7 @@ def generateListOperationCopyCode(to_name, expression, emit, context):
187
187
  with withObjectCodeTemporaryAssignment(
188
188
  to_name, "list_copy_result", expression, emit, context
189
189
  ) as result_name:
190
- emit("%s = LIST_COPY(%s);" % (result_name, list_arg_name))
190
+ emit("%s = LIST_COPY(tstate, %s);" % (result_name, list_arg_name))
191
191
 
192
192
  getErrorExitCode(
193
193
  check_name=result_name,
@@ -34,7 +34,7 @@ def generateSetLocalsDictCode(statement, emit, context):
34
34
 
35
35
  emit(
36
36
  """\
37
- %(locals_dict)s = MAKE_DICT_EMPTY();"""
37
+ %(locals_dict)s = MAKE_DICT_EMPTY(tstate);"""
38
38
  % {"locals_dict": locals_declaration}
39
39
  )
40
40
 
@@ -116,6 +116,23 @@ def getModuleCode(
116
116
  module.getRuntimePackageValue() if is_dunder_main else ""
117
117
  )
118
118
 
119
+ if str is bytes:
120
+ module_dll_entry_point = "init" + module_identifier
121
+ module_def_size = -1
122
+ else:
123
+ try:
124
+ module_dll_entry_point = module_name.encode("ascii")
125
+ module_dll_entry_point_prefix = "PyInit_"
126
+ module_def_size = -1
127
+ except UnicodeEncodeError:
128
+ module_dll_entry_point = module_name.encode("punycode")
129
+ module_dll_entry_point_prefix = "PyInitU_"
130
+ module_def_size = 0
131
+
132
+ module_dll_entry_point = (
133
+ module_dll_entry_point_prefix + module_dll_entry_point.decode("ascii")
134
+ )
135
+
119
136
  return template % {
120
137
  "module_name_cstr": encodePythonStringToC(
121
138
  module_name.asString().encode("utf8")
@@ -138,6 +155,8 @@ def getModuleCode(
138
155
  "module_code_objects_init": indented(module_code_objects_init, 1),
139
156
  "constants_count": context.getConstantsCount(),
140
157
  "module_const_blob_name": module_const_blob_name,
158
+ "module_dll_entry_point": module_dll_entry_point,
159
+ "module_def_size": module_def_size,
141
160
  }
142
161
 
143
162
 
@@ -878,6 +878,20 @@ def generateOsPathDirnameCallCode(to_name, expression, emit, context):
878
878
  )
879
879
 
880
880
 
881
+ def generateOsPathNormpathCallCode(to_name, expression, emit, context):
882
+ generateCAPIObjectCode(
883
+ to_name=to_name,
884
+ capi="OS_PATH_NORMPATH",
885
+ tstate=True,
886
+ arg_desc=(("path_arg", expression.subnode_path),),
887
+ may_raise=expression.mayRaiseException(BaseException),
888
+ conversion_check=decideConversionCheckNeeded(to_name, expression),
889
+ source_ref=expression.getCompatibleSourceReference(),
890
+ emit=emit,
891
+ context=context,
892
+ )
893
+
894
+
881
895
  def generateOsPathAbspathCallCode(to_name, expression, emit, context):
882
896
  generateCAPIObjectCode(
883
897
  to_name=to_name,
@@ -259,7 +259,7 @@ def generateBuiltinSlice3Code(to_name, expression, emit, context):
259
259
  to_name, "slice_obj_value", expression, emit, context
260
260
  ) as result_name:
261
261
  emit(
262
- "%s = MAKE_SLICE_OBJECT3(%s, %s, %s);"
262
+ "%s = MAKE_SLICE_OBJECT3(tstate, %s, %s, %s);"
263
263
  % (
264
264
  result_name,
265
265
  lower_name,
@@ -288,7 +288,7 @@ def generateBuiltinSlice2Code(to_name, expression, emit, context):
288
288
  to_name, "slice_obj_value", expression, emit, context
289
289
  ) as result_name:
290
290
  emit(
291
- "%s = MAKE_SLICE_OBJECT2(%s, %s);"
291
+ "%s = MAKE_SLICE_OBJECT2(tstate, %s, %s);"
292
292
  % (
293
293
  result_name,
294
294
  lower_name,
@@ -316,7 +316,7 @@ def generateBuiltinSlice1Code(to_name, expression, emit, context):
316
316
  to_name, "slice_obj_value", expression, emit, context
317
317
  ) as result_name:
318
318
  emit(
319
- "%s = MAKE_SLICE_OBJECT1(%s);"
319
+ "%s = MAKE_SLICE_OBJECT1(tstate, %s);"
320
320
  % (
321
321
  result_name,
322
322
  upper_name,
@@ -136,7 +136,7 @@ def generateSubscriptLookupCode(to_name, expression, emit, context):
136
136
  )
137
137
 
138
138
 
139
- def generateSubscriptCheckCode(to_name, expression, emit, context):
139
+ def generateMatchSubscriptCheckCode(to_name, expression, emit, context):
140
140
  subscribed = expression.subnode_expression
141
141
  subscript = expression.subnode_subscript
142
142
 
@@ -148,20 +148,12 @@ def generateSubscriptCheckCode(to_name, expression, emit, context):
148
148
  expression=subscript, emit=emit, context=context
149
149
  )
150
150
 
151
- subscript_constant, integer_subscript = decideIntegerSubscript(subscript)
152
-
153
151
  res_name = context.getBoolResName()
154
152
 
155
- if integer_subscript:
156
- emit(
157
- "%s = HAS_SUBSCRIPT_CONST(tstate, %s, %s, %s);"
158
- % (res_name, subscribed_name, subscript_name, subscript_constant)
159
- )
160
- else:
161
- emit(
162
- "%s = HAS_SUBSCRIPT(tstate, %s, %s);"
163
- % (res_name, subscribed_name, subscript_name)
164
- )
153
+ emit(
154
+ "%s = MATCH_MAPPING_KEY(tstate, %s, %s);"
155
+ % (res_name, subscribed_name, subscript_name)
156
+ )
165
157
 
166
158
  getReleaseCodes((subscript_name, subscribed_name), emit, context)
167
159
 
@@ -67,7 +67,7 @@ def getTupleCreationCode(to_name, elements, emit, context):
67
67
  helper_code = generateElementCode(elements[0])
68
68
 
69
69
  # TODO: Consider more compact tuple creation helpers
70
- emit("%s = MAKE_TUPLE_EMPTY(%d);" % (to_name, len(elements)))
70
+ emit("%s = MAKE_TUPLE_EMPTY(tstate, %d);" % (to_name, len(elements)))
71
71
 
72
72
  needs_exception_exit = any(
73
73
  element.mayRaiseException(BaseException) for element in elements[1:]
@@ -181,12 +181,12 @@ class CPythonPyObjectPtrBase(CTypeBase):
181
181
  )
182
182
  ref_count = 1
183
183
  else:
184
- code = "DICT_COPY(%s)" % context.getConstantCode(
184
+ code = "DICT_COPY(tstate, %s)" % context.getConstantCode(
185
185
  constant, deep_check=False
186
186
  )
187
187
  ref_count = 1
188
188
  else:
189
- code = "MAKE_DICT_EMPTY()"
189
+ code = "MAKE_DICT_EMPTY(tstate)"
190
190
  ref_count = 1
191
191
  elif type(constant) is set:
192
192
  if not may_escape:
@@ -222,12 +222,12 @@ class CPythonPyObjectPtrBase(CTypeBase):
222
222
  if constant_size > 1 and all(
223
223
  constant[i] is constant[0] for i in xrange(1, len(constant))
224
224
  ):
225
- code = "MAKE_LIST_REPEATED(%s, %s)" % (
225
+ code = "MAKE_LIST_REPEATED(tstate, %s, %s)" % (
226
226
  constant_size,
227
227
  context.getConstantCode(constant[0], deep_check=False),
228
228
  )
229
229
  elif constant_size < make_list_constant_direct_threshold:
230
- code = "MAKE_LIST%d(%s)" % (
230
+ code = "MAKE_LIST%d(tstate, %s)" % (
231
231
  constant_size,
232
232
  ",".join(
233
233
  context.getConstantCode(constant[i], deep_check=False)
@@ -235,19 +235,19 @@ class CPythonPyObjectPtrBase(CTypeBase):
235
235
  ),
236
236
  )
237
237
  elif constant_size < make_list_constant_hinted_threshold:
238
- code = "MAKE_LIST%d(%s)" % (
238
+ code = "MAKE_LIST%d(tstate, %s)" % (
239
239
  constant_size,
240
240
  context.getConstantCode(constant, deep_check=False),
241
241
  )
242
242
  else:
243
- code = "LIST_COPY(%s)" % context.getConstantCode(
243
+ code = "LIST_COPY(tstate, %s)" % context.getConstantCode(
244
244
  constant, deep_check=False
245
245
  )
246
246
  ref_count = 1
247
247
  else:
248
248
  # TODO: For the zero elements list, maybe have a dedicated function, which
249
249
  # avoids a bit of tests, not sure we want LTO do this.
250
- code = "MAKE_LIST_EMPTY(0)"
250
+ code = "MAKE_LIST_EMPTY(tstate, 0)"
251
251
  ref_count = 1
252
252
  elif type(constant) is tuple:
253
253
  needs_deep = False
@@ -17,7 +17,7 @@ PyObject *global_constants[%(global_constants_count)d];
17
17
  // Sentinel PyObject to be used for all our call iterator endings. It will
18
18
  // become a PyCObject pointing to NULL. It's address is unique, and that's
19
19
  // enough for us to use it as sentinel value.
20
- PyObject *_sentinel_value = NULL;
20
+ PyObject *Nuitka_sentinel_value = NULL;
21
21
 
22
22
  PyObject *Nuitka_dunder_compiled_value = NULL;
23
23
 
@@ -243,14 +243,16 @@ void checkGlobalConstants(void) {
243
243
  #endif
244
244
 
245
245
  void createGlobalConstants(PyThreadState *tstate) {
246
- if (_sentinel_value == NULL) {
246
+ if (Nuitka_sentinel_value == NULL) {
247
247
  #if PYTHON_VERSION < 0x300
248
- _sentinel_value = PyCObject_FromVoidPtr(NULL, NULL);
248
+ Nuitka_sentinel_value = PyCObject_FromVoidPtr(NULL, NULL);
249
249
  #else
250
250
  // The NULL value is not allowed for a capsule, so use something else.
251
- _sentinel_value = PyCapsule_New((void *)27, "sentinel", NULL);
251
+ Nuitka_sentinel_value = PyCapsule_New((void *)27, "sentinel", NULL);
252
252
  #endif
253
- assert(_sentinel_value);
253
+ assert(Nuitka_sentinel_value);
254
+
255
+ Py_SET_REFCNT_IMMORTAL(Nuitka_sentinel_value);
254
256
 
255
257
  _createGlobalConstants(tstate);
256
258
  }
@@ -124,7 +124,9 @@ void copyFrozenModulesTo(struct _frozen *destination) {
124
124
  #if PYTHON_VERSION >= 0x3b0
125
125
  destination->is_package = current->size < 0;
126
126
  destination->size = Py_ABS(destination->size);
127
+ #if PYTHON_VERSION < 0x3d0
127
128
  destination->get_code = NULL;
129
+ #endif
128
130
  #endif
129
131
  if (destination->name == NULL) break;
130
132
 
@@ -128,9 +128,9 @@ static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObj
128
128
  return NULL;
129
129
  }
130
130
 
131
- if (Nuitka_Function_Check(func) == false) {
132
- PyThreadState *tstate = PyThreadState_GET();
131
+ PyThreadState *tstate = PyThreadState_GET();
133
132
 
133
+ if (Nuitka_Function_Check(func) == false) {
134
134
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "not a compiled function");
135
135
  return NULL;
136
136
  }
@@ -140,7 +140,6 @@ static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObj
140
140
  int offset = Nuitka_Function_GetFunctionCodeIndex(function, function_table_%(module_identifier)s);
141
141
 
142
142
  if (unlikely(offset == -1)) {
143
- PyThreadState *tstate = PyThreadState_GET();
144
143
  #if 0
145
144
  PRINT_STRING("Looking for:");
146
145
  PRINT_ITEM(func);
@@ -150,7 +149,7 @@ static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObj
150
149
  return NULL;
151
150
  }
152
151
 
153
- PyObject *code_object_desc = MAKE_TUPLE_EMPTY(6);
152
+ PyObject *code_object_desc = MAKE_TUPLE_EMPTY(tstate, 6);
154
153
  PyTuple_SET_ITEM0(code_object_desc, 0, function->m_code_object->co_filename);
155
154
  PyTuple_SET_ITEM0(code_object_desc, 1, function->m_code_object->co_name);
156
155
  PyTuple_SET_ITEM(code_object_desc, 2, PyLong_FromLong(function->m_code_object->co_firstlineno));
@@ -161,14 +160,14 @@ static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObj
161
160
  CHECK_OBJECT_DEEP(code_object_desc);
162
161
 
163
162
 
164
- PyObject *result = MAKE_TUPLE_EMPTY(8);
163
+ PyObject *result = MAKE_TUPLE_EMPTY(tstate, 8);
165
164
  PyTuple_SET_ITEM(result, 0, PyLong_FromLong(offset));
166
165
  PyTuple_SET_ITEM(result, 1, code_object_desc);
167
166
  PyTuple_SET_ITEM0(result, 2, function->m_defaults);
168
167
  #if PYTHON_VERSION >= 0x300
169
168
  PyTuple_SET_ITEM0(result, 3, function->m_kwdefaults ? function->m_kwdefaults : Py_None);
170
169
  #else
171
- PyTuple_SET_ITEM0(result, 3, Py_None);
170
+ PyTuple_SET_ITEM_IMMORTAL(result, 3, Py_None);
172
171
  #endif
173
172
  PyTuple_SET_ITEM0(result, 4, function->m_doc != NULL ? function->m_doc : Py_None);
174
173
 
@@ -176,13 +175,13 @@ static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObj
176
175
  CHECK_OBJECT(function->m_constant_return_value);
177
176
  PyTuple_SET_ITEM0(result, 5, function->m_constant_return_value);
178
177
  } else {
179
- PyTuple_SET_ITEM0(result, 5, Py_None);
178
+ PyTuple_SET_ITEM_IMMORTAL(result, 5, Py_None);
180
179
  }
181
180
 
182
181
  #if PYTHON_VERSION >= 0x300
183
182
  PyTuple_SET_ITEM0(result, 6, function->m_qualname);
184
183
  #else
185
- PyTuple_SET_ITEM0(result, 6, Py_None);
184
+ PyTuple_SET_ITEM_IMMORTAL(result, 6, Py_None);
186
185
  #endif
187
186
 
188
187
  PyObject *closure = PyObject_GetAttr(
@@ -277,7 +276,9 @@ PyObject *modulecode_%(module_identifier)s(PyThreadState *tstate, PyObject *modu
277
276
  // In case of an extension module loaded into a process, we need to call
278
277
  // initialization here because that's the first and potentially only time
279
278
  // we are going called.
280
-
279
+ #if PYTHON_VERSION > 0x350 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_ALLOCATORS)
280
+ initNuitkaAllocators();
281
+ #endif
281
282
  // Initialize the constant values used.
282
283
  _initBuiltinModule();
283
284
  createGlobalConstants(tstate);
@@ -506,15 +507,6 @@ template_module_external_entry_point = r"""
506
507
  #define NUITKA_MODULE_INIT_FUNCTION PyMODINIT_FUNC
507
508
  #endif
508
509
 
509
- /* The name of the entry point for DLLs changed between CPython versions, and
510
- * this is here to hide that.
511
- */
512
- #if PYTHON_VERSION < 0x300
513
- #define MOD_INIT_DECL(name) NUITKA_MODULE_INIT_FUNCTION init##name(void)
514
- #else
515
- #define MOD_INIT_DECL(name) NUITKA_MODULE_INIT_FUNCTION PyInit_##name(void)
516
- #endif
517
-
518
510
  static PyObject *orig_dunder_file_value;
519
511
 
520
512
  #if PYTHON_VERSION >= 0x300
@@ -548,20 +540,15 @@ static struct PyModuleDef mdef_%(module_identifier)s = {
548
540
  PyModuleDef_HEAD_INIT,
549
541
  NULL, /* m_name, filled later */
550
542
  NULL, /* m_doc */
551
- -1, /* m_size */
543
+ %(module_def_size)s, /* m_size */
552
544
  NULL, /* m_methods */
553
- NULL, /* m_reload */
545
+ NULL, /* m_slots */
554
546
  NULL, /* m_traverse */
555
547
  NULL, /* m_clear */
556
548
  NULL, /* m_free */
557
549
  };
558
550
  #endif
559
551
 
560
- /* The exported interface to CPython. On import of the module, this function
561
- * gets called. It has to have an exact function name, in cases it's a shared
562
- * library export. This is hidden behind the MOD_INIT_DECL macro.
563
- */
564
-
565
552
  // Actual name might be different when loaded as a package.
566
553
  static char const *module_full_name = %(module_name_cstr)s;
567
554
 
@@ -577,38 +564,18 @@ static void onModuleFileValueRelease(void *v) {
577
564
  }
578
565
  #endif
579
566
 
580
- MOD_INIT_DECL(%(module_identifier)s) {
581
- if (_Py_PackageContext != NULL) {
582
- module_full_name = _Py_PackageContext;
583
- }
584
-
585
- #if PYTHON_VERSION < 0x300
586
- PyObject *module = Py_InitModule4(
587
- module_full_name, // Module Name
588
- NULL, // No methods initially, all are added
589
- // dynamically in actual module code only.
590
- NULL, // No "__doc__" is initially set, as it could
591
- // not contain NUL this way, added early in
592
- // actual code.
593
- NULL, // No self for modules, we don't use it.
594
- PYTHON_API_VERSION
595
- );
596
- #else
597
- mdef_%(module_identifier)s.m_name = module_full_name;
598
- PyObject *module = PyModule_Create(&mdef_%(module_identifier)s);
599
- CHECK_OBJECT(module);
567
+ /* The exported interface to CPython. On import of the module, this function
568
+ * gets called. It has to have an exact function name, in cases it's a shared
569
+ * library export.
570
+ */
600
571
 
601
- {
602
- NUITKA_MAY_BE_UNUSED bool res = Nuitka_SetModuleString(module_full_name, module);
603
- assert(res != false);
604
- }
605
- #endif
606
572
 
573
+ static PyObject *%(module_dll_entry_point)s_phase2(PyObject *module) {
607
574
  PyThreadState *tstate = PyThreadState_GET();
608
575
 
609
- #if PYTHON_VERSION < 0x300
610
- modulecode_%(module_identifier)s(tstate, module, NULL);
576
+ PyObject *result = modulecode_%(module_identifier)s(tstate, module, NULL);
611
577
 
578
+ #if PYTHON_VERSION < 0x300
612
579
  // Our "__file__" value will not be respected by CPython and one
613
580
  // way we can avoid it, is by having a capsule type, that when
614
581
  // it gets released, we are called and repair the value.
@@ -625,8 +592,6 @@ MOD_INIT_DECL(%(module_identifier)s) {
625
592
  );
626
593
  }
627
594
  #else
628
- PyObject *result = modulecode_%(module_identifier)s(tstate, module, NULL);
629
-
630
595
  if (result != NULL) {
631
596
  // Make sure we undo the change of the "__file__" attribute during importing. We do not
632
597
  // know how to achieve it for Python2 though. TODO: Find something for Python2 too.
@@ -635,8 +600,69 @@ MOD_INIT_DECL(%(module_identifier)s) {
635
600
 
636
601
  orig_dunder_file_value = DICT_GET_ITEM_WITH_HASH_ERROR1(tstate, (PyObject *)moduledict_%(module_identifier)s, const_str_plain___file__);
637
602
  }
603
+ #endif
638
604
 
639
605
  return result;
606
+ }
607
+
608
+ #if %(module_def_size)s >= 0
609
+ static int %(module_dll_entry_point)s_slot(PyObject *module) {
610
+ PyObject *result = %(module_dll_entry_point)s_phase2(module);
611
+
612
+ if (result == NULL) {
613
+ return 1;
614
+ } else {
615
+ return 0;
616
+ }
617
+ }
618
+ #endif
619
+
620
+ NUITKA_MODULE_INIT_FUNCTION (%(module_dll_entry_point)s)(void) {
621
+ if (_Py_PackageContext != NULL) {
622
+ if (strcmp(module_full_name, _Py_PackageContext) != 0) {
623
+ module_full_name = strdup(_Py_PackageContext);
624
+ }
625
+ }
626
+
627
+ #if PYTHON_VERSION < 0x300
628
+ PyObject *module = Py_InitModule4(
629
+ module_full_name, // Module Name
630
+ NULL, // No methods initially, all are added
631
+ // dynamically in actual module code only.
632
+ NULL, // No "__doc__" is initially set, as it could
633
+ // not contain NUL this way, added early in
634
+ // actual code.
635
+ NULL, // No self for modules, we don't use it.
636
+ PYTHON_API_VERSION
637
+ );
638
+ #else
639
+ mdef_%(module_identifier)s.m_name = module_full_name;
640
+
641
+ #if %(module_def_size)s == -1
642
+ PyObject *module = PyModule_Create(&mdef_%(module_identifier)s);
643
+ CHECK_OBJECT(module);
644
+
645
+ {
646
+ NUITKA_MAY_BE_UNUSED bool res = Nuitka_SetModuleString(module_full_name, module);
647
+ assert(res != false);
648
+ }
649
+
650
+ #endif
651
+ #endif
652
+
653
+ #if %(module_def_size)s >= 0
654
+ static PyModuleDef_Slot _module_slots[] = {
655
+ {Py_mod_exec, %(module_dll_entry_point)s_slot},
656
+ {0, NULL}
657
+ };
658
+
659
+ mdef_%(module_identifier)s.m_slots = _module_slots;
660
+
661
+ return PyModuleDef_Init(&mdef_%(module_identifier)s);
662
+ #elif PYTHON_VERSION >= 0x300
663
+ return %(module_dll_entry_point)s_phase2(module);
664
+ #else
665
+ %(module_dll_entry_point)s_phase2(module);
640
666
  #endif
641
667
  }
642
668
  """
@@ -93,7 +93,7 @@ PyObject *CALL_FUNCTION_WITH_POSARGS{{args_count}}_KWSPLIT(PyThreadState *tstate
93
93
  {% if args_count == 0 %}
94
94
  PyObject *pos_args = const_tuple_empty;
95
95
  {% elif not has_tuple_arg or not has_dict_values %}
96
- PyObject *pos_args = MAKE_TUPLE(args, {{args_count}});
96
+ PyObject *pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
97
97
  {% endif %}
98
98
 
99
99
  PyObject *named_args = _PyDict_NewPresized(nkwargs);
@@ -156,6 +156,56 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
156
156
  }
157
157
  #if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
158
158
  } else if (PyCFunction_CheckExact(called)) {
159
+ #if PYTHON_VERSION >= 0x380
160
+ #ifdef _NUITKA_FULL_COMPAT
161
+ if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
162
+ return NULL;
163
+ }
164
+ #endif
165
+
166
+ int flags = PyCFunction_GET_FLAGS(called);
167
+
168
+ PyObject *result;
169
+
170
+ if (!(flags & METH_VARARGS)) {
171
+ vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
172
+
173
+ assert(func != NULL);
174
+ {% if args_count == 0 %}
175
+ result = func(called, NULL, 0, NULL);
176
+ {% else %}
177
+ result = func(called, args, {{args_count}}, NULL);
178
+ {% endif %}
179
+
180
+ CHECK_OBJECT_X(result);
181
+ } else {
182
+ PyCFunction method = PyCFunction_GET_FUNCTION(called);
183
+ PyObject *self = PyCFunction_GET_SELF(called);
184
+
185
+ {% if not has_tuple_arg and args_count != 0 %}
186
+ PyObject *pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
187
+ {% elif not has_tuple_arg %}
188
+ PyObject *pos_args = const_tuple_empty;
189
+ {% endif %}
190
+
191
+ if (flags & METH_KEYWORDS) {
192
+ result = (*(PyCFunctionWithKeywords)(void(*)(void))method)(self, pos_args, NULL);
193
+ } else {
194
+ result = (*method)(self, pos_args);
195
+ }
196
+
197
+ {% if not has_tuple_arg and args_count != 0 %}
198
+ Py_DECREF(pos_args);
199
+ {% endif %}
200
+ }
201
+
202
+ #ifdef _NUITKA_FULL_COMPAT
203
+ Py_LeaveRecursiveCall();
204
+ #endif
205
+ CHECK_OBJECT_X(result);
206
+
207
+ return Nuitka_CheckFunctionResult(tstate, called, result);
208
+ #else
159
209
  // Try to be fast about wrapping the arguments.
160
210
  int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
161
211
 
@@ -230,7 +280,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
230
280
 
231
281
  #if PYTHON_VERSION < 0x360
232
282
  {% if not has_tuple_arg and args_count != 0 %}
233
- PyObject *pos_args = MAKE_TUPLE(args, {{args_count}});
283
+ PyObject *pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
234
284
  {% elif not has_tuple_arg %}
235
285
  PyObject *pos_args = const_tuple_empty;
236
286
  {% endif %}
@@ -246,7 +296,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
246
296
  #else
247
297
  if (flags == (METH_VARARGS|METH_KEYWORDS)) {
248
298
  {% if not has_tuple_arg and args_count != 0 %}
249
- PyObject *pos_args = MAKE_TUPLE(args, {{args_count}});
299
+ PyObject *pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
250
300
  {% elif not has_tuple_arg %}
251
301
  PyObject *pos_args = const_tuple_empty;
252
302
  {% endif %}
@@ -263,7 +313,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
263
313
  {% endif %}
264
314
  #else
265
315
  {% if not has_tuple_arg and args_count != 0 %}
266
- PyObject *pos_args = MAKE_TUPLE(args, {{args_count}});
316
+ PyObject *pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
267
317
  {% elif not has_tuple_arg %}
268
318
  PyObject *pos_args = const_tuple_empty;
269
319
  {% endif %}
@@ -274,7 +324,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
274
324
  #endif
275
325
  } else {
276
326
  {% if not has_tuple_arg and args_count != 0 %}
277
- PyObject *pos_args = MAKE_TUPLE(args, {{args_count}});
327
+ PyObject *pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
278
328
  {% elif not has_tuple_arg %}
279
329
  PyObject *pos_args = const_tuple_empty;
280
330
  {% endif %}
@@ -294,7 +344,8 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
294
344
  return Nuitka_CheckFunctionResult(tstate, called, result);
295
345
  }
296
346
  #endif
297
- #if !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
347
+ #endif
348
+ #if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
298
349
  } else if (PyFunction_Check(called)) {
299
350
  #if PYTHON_VERSION < 0x3b0
300
351
  {% if args_count == 0 %}
@@ -356,7 +407,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
356
407
  CHECK_OBJECT(obj);
357
408
  } else {
358
409
  {% if not has_tuple_arg and args_count != 0 %}
359
- pos_args = MAKE_TUPLE(args, {{args_count}});
410
+ pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
360
411
  {% endif %}
361
412
  obj = called_type->tp_new(called_type, pos_args, NULL);
362
413
  {# TODO: obj = _Py_CheckFunctionResult(obj) for Python3 in debug mode #}
@@ -460,7 +511,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
460
511
  } else {
461
512
  {% if not has_tuple_arg and args_count != 0 %}
462
513
  if (pos_args == NULL) {
463
- pos_args = MAKE_TUPLE(args, {{args_count}});
514
+ pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
464
515
  }
465
516
  {% endif %}
466
517
 
@@ -595,7 +646,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
595
646
  PyObject *result = CALL_FUNCTION(tstate, called, const_tuple_empty, NULL);
596
647
  {% else %}
597
648
  {% if not has_tuple_arg %}
598
- PyObject *pos_args = MAKE_TUPLE(args, {{args_count}});
649
+ PyObject *pos_args = MAKE_TUPLE(tstate, args, {{args_count}});
599
650
  {% endif %}
600
651
 
601
652
  PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);