Nuitka-winsvc 2.4.8__cp311-cp311-win_amd64.whl → 2.5.1__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 (294) hide show
  1. {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/METADATA +2 -1
  2. {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/RECORD +294 -271
  3. {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/WHEEL +1 -1
  4. nuitka/Builtins.py +31 -0
  5. nuitka/HardImportRegistry.py +8 -0
  6. nuitka/MainControl.py +9 -4
  7. nuitka/OptionParsing.py +105 -52
  8. nuitka/Options.py +73 -16
  9. nuitka/OutputDirectories.py +7 -2
  10. nuitka/PostProcessing.py +69 -38
  11. nuitka/Progress.py +16 -1
  12. nuitka/PythonVersions.py +2 -1
  13. nuitka/Serialization.py +4 -2
  14. nuitka/Tracing.py +69 -1
  15. nuitka/Version.py +2 -2
  16. nuitka/build/Backend.scons +45 -5
  17. nuitka/build/CCompilerVersion.scons +6 -0
  18. nuitka/build/Onefile.scons +6 -0
  19. nuitka/build/SconsCaching.py +12 -2
  20. nuitka/build/SconsCompilerSettings.py +17 -6
  21. nuitka/build/SconsInterface.py +1 -0
  22. nuitka/build/SconsUtils.py +5 -0
  23. nuitka/build/include/nuitka/allocator.h +124 -1
  24. nuitka/build/include/nuitka/calling.h +6 -6
  25. nuitka/build/include/nuitka/compiled_asyncgen.h +10 -7
  26. nuitka/build/include/nuitka/compiled_frame.h +2 -1
  27. nuitka/build/include/nuitka/constants.h +6 -0
  28. nuitka/build/include/nuitka/debug_settings.h +60 -0
  29. nuitka/build/include/nuitka/exceptions.h +264 -121
  30. nuitka/build/include/nuitka/helper/attributes.h +0 -4
  31. nuitka/build/include/nuitka/helper/calling_generated.h +52 -52
  32. nuitka/build/include/nuitka/helper/comparisons_dual_eq.h +47 -0
  33. nuitka/build/include/nuitka/helper/comparisons_dual_ge.h +39 -0
  34. nuitka/build/include/nuitka/helper/comparisons_dual_gt.h +39 -0
  35. nuitka/build/include/nuitka/helper/comparisons_dual_le.h +47 -0
  36. nuitka/build/include/nuitka/helper/comparisons_dual_lt.h +47 -0
  37. nuitka/build/include/nuitka/helper/comparisons_dual_ne.h +39 -0
  38. nuitka/build/include/nuitka/helper/dictionaries.h +65 -29
  39. nuitka/build/include/nuitka/helper/ints.h +86 -37
  40. nuitka/build/include/nuitka/helper/iterators.h +82 -34
  41. nuitka/build/include/nuitka/helper/operations.h +3 -0
  42. nuitka/build/include/nuitka/helper/operations_binary_add.h +6 -0
  43. nuitka/build/include/nuitka/helper/operations_binary_dual_add.h +34 -0
  44. nuitka/build/include/nuitka/helper/operations_binary_sub.h +6 -0
  45. nuitka/build/include/nuitka/helper/operations_inplace_add.h +3 -0
  46. nuitka/build/include/nuitka/helper/operations_inplace_sub.h +3 -0
  47. nuitka/build/include/nuitka/helper/raising.h +47 -28
  48. nuitka/build/include/nuitka/helper/richcomparisons.h +7 -0
  49. nuitka/build/include/nuitka/helpers.h +12 -2
  50. nuitka/build/include/nuitka/prelude.h +35 -25
  51. nuitka/build/include/nuitka/printing.h +9 -7
  52. nuitka/build/include/nuitka/threading.h +15 -1
  53. nuitka/build/include/nuitka/type_aliases.h +3 -0
  54. nuitka/build/inline_copy/stubgen/astunparse.py +938 -0
  55. nuitka/build/inline_copy/stubgen/six.py +998 -0
  56. nuitka/build/inline_copy/stubgen/stubgen.py +307 -0
  57. nuitka/build/static_src/CompiledAsyncgenType.c +45 -39
  58. nuitka/build/static_src/CompiledCellType.c +6 -4
  59. nuitka/build/static_src/CompiledCodeHelpers.c +104 -40
  60. nuitka/build/static_src/CompiledCoroutineType.c +40 -30
  61. nuitka/build/static_src/CompiledFrameType.c +110 -79
  62. nuitka/build/static_src/CompiledFunctionType.c +173 -151
  63. nuitka/build/static_src/CompiledGeneratorType.c +51 -49
  64. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +424 -46
  65. nuitka/build/static_src/CompiledMethodType.c +10 -13
  66. nuitka/build/static_src/HelpersAllocator.c +270 -32
  67. nuitka/build/static_src/HelpersAttributes.c +0 -21
  68. nuitka/build/static_src/HelpersBuiltin.c +22 -13
  69. nuitka/build/static_src/HelpersCalling.c +7 -7
  70. nuitka/build/static_src/HelpersCallingGenerated.c +70 -70
  71. nuitka/build/static_src/HelpersComparisonDualEq.c +183 -0
  72. nuitka/build/static_src/HelpersComparisonDualGe.c +121 -0
  73. nuitka/build/static_src/HelpersComparisonDualGt.c +121 -0
  74. nuitka/build/static_src/HelpersComparisonDualLe.c +183 -0
  75. nuitka/build/static_src/HelpersComparisonDualLt.c +183 -0
  76. nuitka/build/static_src/HelpersComparisonDualNe.c +121 -0
  77. nuitka/build/static_src/HelpersComparisonEq.c +18 -4
  78. nuitka/build/static_src/HelpersComparisonEqUtils.c +1 -0
  79. nuitka/build/static_src/HelpersComparisonGe.c +18 -4
  80. nuitka/build/static_src/HelpersComparisonGt.c +18 -4
  81. nuitka/build/static_src/HelpersComparisonLe.c +18 -4
  82. nuitka/build/static_src/HelpersComparisonLt.c +18 -4
  83. nuitka/build/static_src/HelpersComparisonNe.c +18 -4
  84. nuitka/build/static_src/HelpersConsole.c +34 -8
  85. nuitka/build/static_src/HelpersConstantsBlob.c +10 -4
  86. nuitka/build/static_src/HelpersDictionaries.c +181 -34
  87. nuitka/build/static_src/HelpersDictionariesGenerated.c +0 -106
  88. nuitka/build/static_src/HelpersExceptions.c +24 -50
  89. nuitka/build/static_src/HelpersFiles.c +79 -5
  90. nuitka/build/static_src/HelpersImport.c +13 -9
  91. nuitka/build/static_src/HelpersImportHard.c +23 -46
  92. nuitka/build/static_src/HelpersLists.c +98 -9
  93. nuitka/build/static_src/HelpersMatching.c +1 -1
  94. nuitka/build/static_src/HelpersOperationBinaryAdd.c +224 -6
  95. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +3 -0
  96. nuitka/build/static_src/HelpersOperationBinaryBitand.c +5 -5
  97. nuitka/build/static_src/HelpersOperationBinaryBitor.c +5 -5
  98. nuitka/build/static_src/HelpersOperationBinaryBitxor.c +5 -5
  99. nuitka/build/static_src/HelpersOperationBinaryDivmod.c +8 -2
  100. nuitka/build/static_src/HelpersOperationBinaryDualAdd.c +172 -0
  101. nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +14 -8
  102. nuitka/build/static_src/HelpersOperationBinaryLshift.c +36 -36
  103. nuitka/build/static_src/HelpersOperationBinaryMatmult.c +1 -0
  104. nuitka/build/static_src/HelpersOperationBinaryMod.c +22 -10
  105. nuitka/build/static_src/HelpersOperationBinaryMult.c +17 -7
  106. nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +14 -8
  107. nuitka/build/static_src/HelpersOperationBinaryPow.c +24 -24
  108. nuitka/build/static_src/HelpersOperationBinaryRshift.c +4 -4
  109. nuitka/build/static_src/HelpersOperationBinarySub.c +229 -8
  110. nuitka/build/static_src/HelpersOperationBinaryTruediv.c +8 -2
  111. nuitka/build/static_src/HelpersOperationInplaceAdd.c +162 -10
  112. nuitka/build/static_src/HelpersOperationInplaceBitand.c +5 -5
  113. nuitka/build/static_src/HelpersOperationInplaceBitor.c +5 -5
  114. nuitka/build/static_src/HelpersOperationInplaceBitxor.c +5 -5
  115. nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +11 -6
  116. nuitka/build/static_src/HelpersOperationInplaceLshift.c +20 -20
  117. nuitka/build/static_src/HelpersOperationInplaceMatmult.c +1 -0
  118. nuitka/build/static_src/HelpersOperationInplaceMod.c +11 -6
  119. nuitka/build/static_src/HelpersOperationInplaceMult.c +11 -6
  120. nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +11 -6
  121. nuitka/build/static_src/HelpersOperationInplacePow.c +20 -20
  122. nuitka/build/static_src/HelpersOperationInplaceRshift.c +4 -4
  123. nuitka/build/static_src/HelpersOperationInplaceSub.c +163 -10
  124. nuitka/build/static_src/HelpersOperationInplaceTruediv.c +6 -1
  125. nuitka/build/static_src/HelpersProfiling.c +1 -1
  126. nuitka/build/static_src/HelpersRaising.c +255 -310
  127. nuitka/build/static_src/HelpersStrings.c +1 -1
  128. nuitka/build/static_src/HelpersTuples.c +1 -1
  129. nuitka/build/static_src/HelpersTypes.c +98 -2
  130. nuitka/build/static_src/MainProgram.c +117 -29
  131. nuitka/build/static_src/MetaPathBasedLoader.c +18 -19
  132. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +134 -11
  133. nuitka/build/static_src/OnefileBootstrap.c +6 -1
  134. nuitka/code_generation/AsyncgenCodes.py +2 -6
  135. nuitka/code_generation/BinaryOperationHelperDefinitions.py +269 -167
  136. nuitka/code_generation/BuiltinCodes.py +9 -1
  137. nuitka/code_generation/CallCodes.py +16 -16
  138. nuitka/code_generation/CodeGeneration.py +14 -2
  139. nuitka/code_generation/CodeHelperSelection.py +1 -1
  140. nuitka/code_generation/CodeHelpers.py +4 -1
  141. nuitka/code_generation/CodeObjectCodes.py +2 -2
  142. nuitka/code_generation/ComparisonCodes.py +13 -2
  143. nuitka/code_generation/ComparisonHelperDefinitions.py +23 -8
  144. nuitka/code_generation/Contexts.py +28 -16
  145. nuitka/code_generation/CoroutineCodes.py +2 -6
  146. nuitka/code_generation/DictCodes.py +3 -3
  147. nuitka/code_generation/ErrorCodes.py +34 -50
  148. nuitka/code_generation/ExceptionCodes.py +165 -96
  149. nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +25 -10
  150. nuitka/code_generation/FrameCodes.py +4 -11
  151. nuitka/code_generation/FunctionCodes.py +2 -6
  152. nuitka/code_generation/GeneratorCodes.py +2 -6
  153. nuitka/code_generation/GlobalConstants.py +8 -2
  154. nuitka/code_generation/GlobalsLocalsCodes.py +2 -2
  155. nuitka/code_generation/IteratorCodes.py +67 -54
  156. nuitka/code_generation/LineNumberCodes.py +1 -3
  157. nuitka/code_generation/ModuleCodes.py +28 -4
  158. nuitka/code_generation/OperationCodes.py +51 -20
  159. nuitka/code_generation/PackageResourceCodes.py +37 -0
  160. nuitka/code_generation/RaisingCodes.py +164 -90
  161. nuitka/code_generation/Reports.py +13 -5
  162. nuitka/code_generation/ReturnCodes.py +2 -16
  163. nuitka/code_generation/TryCodes.py +12 -24
  164. nuitka/code_generation/TypeAliasCodes.py +48 -0
  165. nuitka/code_generation/VariableCodes.py +99 -40
  166. nuitka/code_generation/VariableDeclarations.py +8 -8
  167. nuitka/code_generation/YieldCodes.py +1 -1
  168. nuitka/code_generation/c_types/CTypeBases.py +10 -2
  169. nuitka/code_generation/c_types/CTypeModuleDictVariables.py +3 -0
  170. nuitka/code_generation/c_types/CTypeNuitkaBooleans.py +3 -4
  171. nuitka/code_generation/c_types/CTypeNuitkaInts.py +70 -25
  172. nuitka/code_generation/c_types/CTypeNuitkaVoids.py +1 -1
  173. nuitka/code_generation/c_types/CTypePyObjectPointers.py +16 -6
  174. nuitka/code_generation/templates/CodeTemplatesAsyncgens.py +2 -2
  175. nuitka/code_generation/templates/CodeTemplatesConstants.py +11 -3
  176. nuitka/code_generation/templates/CodeTemplatesCoroutines.py +2 -2
  177. nuitka/code_generation/templates/CodeTemplatesExceptions.py +15 -16
  178. nuitka/code_generation/templates/CodeTemplatesFrames.py +18 -10
  179. nuitka/code_generation/templates/CodeTemplatesFunction.py +2 -2
  180. nuitka/code_generation/templates/CodeTemplatesGeneratorFunction.py +2 -2
  181. nuitka/code_generation/templates/CodeTemplatesIterators.py +1 -35
  182. nuitka/code_generation/templates/CodeTemplatesModules.py +34 -4
  183. nuitka/code_generation/templates/CodeTemplatesVariables.py +73 -0
  184. nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +3 -3
  185. nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +3 -3
  186. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +0 -105
  187. nuitka/code_generation/templates_c/HelperImportHard.c.j2 +1 -2
  188. nuitka/code_generation/templates_c/HelperLongTools.c.j2 +1 -1
  189. nuitka/code_generation/templates_c/HelperOperationBinaryDual.c.j2 +115 -0
  190. nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +9 -9
  191. nuitka/code_generation/templates_c/HelperOperationComparisonDual.c.j2 +86 -0
  192. nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +1 -1
  193. nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +1 -1
  194. nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +9 -9
  195. nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +7 -7
  196. nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +9 -9
  197. nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +7 -7
  198. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -4
  199. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +1 -1
  200. nuitka/code_generation/templates_c/HelperSlotsInt.c.j2 +31 -31
  201. nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +1 -1
  202. nuitka/containers/Namedtuples.py +6 -0
  203. nuitka/containers/OrderedSets.py +105 -5
  204. nuitka/distutils/Build.py +14 -0
  205. nuitka/distutils/DistutilCommands.py +50 -10
  206. nuitka/finalizations/Finalization.py +3 -3
  207. nuitka/finalizations/FinalizeMarkups.py +10 -14
  208. nuitka/freezer/DependsExe.py +13 -3
  209. nuitka/freezer/DllDependenciesMacOS.py +18 -1
  210. nuitka/freezer/DllDependenciesWin32.py +26 -12
  211. nuitka/freezer/ImportDetection.py +3 -0
  212. nuitka/freezer/IncludedDataFiles.py +31 -8
  213. nuitka/freezer/IncludedEntryPoints.py +3 -2
  214. nuitka/freezer/Standalone.py +76 -18
  215. nuitka/importing/Importing.py +33 -6
  216. nuitka/importing/Recursion.py +12 -1
  217. nuitka/importing/StandardLibrary.py +57 -59
  218. nuitka/nodes/AsyncgenNodes.py +3 -6
  219. nuitka/nodes/BuiltinIteratorNodes.py +1 -1
  220. nuitka/nodes/BuiltinRefNodes.py +14 -30
  221. nuitka/nodes/ChildrenHavingMixins.py +439 -46
  222. nuitka/nodes/ConditionalNodes.py +3 -2
  223. nuitka/nodes/CoroutineNodes.py +3 -6
  224. nuitka/nodes/ExceptionNodes.py +102 -26
  225. nuitka/nodes/ExpressionBasesGenerated.py +288 -4
  226. nuitka/nodes/FrameNodes.py +22 -11
  227. nuitka/nodes/FunctionNodes.py +3 -3
  228. nuitka/nodes/GeneratorNodes.py +3 -6
  229. nuitka/nodes/HardImportNodesGenerated.py +182 -0
  230. nuitka/nodes/ImportNodes.py +2 -2
  231. nuitka/nodes/NodeBases.py +28 -1
  232. nuitka/nodes/NodeMakingHelpers.py +71 -50
  233. nuitka/nodes/OperatorNodesUnary.py +128 -3
  234. nuitka/nodes/OsSysNodes.py +37 -6
  235. nuitka/nodes/OutlineNodes.py +2 -2
  236. nuitka/nodes/StatementBasesGenerated.py +0 -2
  237. nuitka/nodes/StatementNodes.py +8 -7
  238. nuitka/nodes/SubscriptNodes.py +1 -1
  239. nuitka/nodes/TypeNodes.py +28 -1
  240. nuitka/nodes/shapes/BuiltinTypeShapes.py +24 -7
  241. nuitka/nodes/shapes/ShapeMixins.py +17 -0
  242. nuitka/nodes/shapes/StandardShapes.py +53 -1
  243. nuitka/optimizations/BytecodeDemotion.py +2 -1
  244. nuitka/plugins/PluginBase.py +64 -22
  245. nuitka/plugins/Plugins.py +6 -3
  246. nuitka/plugins/standard/AntiBloatPlugin.py +23 -12
  247. nuitka/plugins/standard/ImplicitImports.py +1 -13
  248. nuitka/plugins/standard/KivyPlugin.py +3 -12
  249. nuitka/plugins/standard/MatplotlibPlugin.py +12 -1
  250. nuitka/plugins/standard/MultiprocessingPlugin.py +11 -20
  251. nuitka/plugins/standard/PlaywrightPlugin.py +184 -0
  252. nuitka/plugins/standard/PySidePyQtPlugin.py +8 -0
  253. nuitka/plugins/standard/TkinterPlugin.py +0 -56
  254. nuitka/plugins/standard/TransformersPlugin.py +70 -275
  255. nuitka/plugins/standard/standard.nuitka-package.config.yml +510 -28
  256. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +35 -2
  257. nuitka/reports/CompilationReportReader.py +12 -0
  258. nuitka/reports/Reports.py +11 -0
  259. nuitka/specs/BuiltinParameterSpecs.py +5 -1
  260. nuitka/specs/HardImportSpecs.py +7 -0
  261. nuitka/specs/ParameterSpecs.py +4 -4
  262. nuitka/tools/general/dll_report/__main__.py +10 -1
  263. nuitka/tools/onefile_compressor/OnefileCompressor.py +1 -1
  264. nuitka/tools/specialize/CTypeDescriptions.py +158 -9
  265. nuitka/tools/specialize/SpecializeC.py +218 -56
  266. nuitka/tools/testing/Common.py +70 -63
  267. nuitka/tools/testing/compare_with_cpython/__main__.py +3 -1
  268. nuitka/tools/testing/measure_construct_performance/__main__.py +1 -8
  269. nuitka/tools/testing/run_nuitka_tests/__main__.py +77 -11
  270. nuitka/tools/watch/AutoStage.py +1 -0
  271. nuitka/tree/Building.py +10 -37
  272. nuitka/tree/ComplexCallHelperFunctions.py +4 -0
  273. nuitka/tree/ReformulationAssertStatements.py +31 -14
  274. nuitka/tree/ReformulationAssignmentStatements.py +5 -1
  275. nuitka/tree/ReformulationClasses3.py +94 -19
  276. nuitka/tree/ReformulationDictionaryCreation.py +1 -0
  277. nuitka/tree/ReformulationFunctionStatements.py +1 -1
  278. nuitka/tree/ReformulationMatchStatements.py +3 -1
  279. nuitka/tree/ReformulationYieldExpressions.py +23 -5
  280. nuitka/utils/CommandLineOptions.py +27 -3
  281. nuitka/utils/Download.py +2 -2
  282. nuitka/utils/Execution.py +36 -31
  283. nuitka/utils/FileOperations.py +39 -54
  284. nuitka/utils/Importing.py +2 -14
  285. nuitka/utils/InlineCopies.py +52 -0
  286. nuitka/utils/InstalledPythons.py +9 -4
  287. nuitka/utils/Json.py +2 -2
  288. nuitka/utils/PackageResources.py +44 -0
  289. nuitka/utils/Utils.py +17 -0
  290. {Nuitka_winsvc-2.4.8.data → Nuitka_winsvc-2.5.1.data}/scripts/nuitka-run.cmd +0 -0
  291. {Nuitka_winsvc-2.4.8.data → Nuitka_winsvc-2.5.1.data}/scripts/nuitka.cmd +0 -0
  292. {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/LICENSE.txt +0 -0
  293. {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/entry_points.txt +0 -0
  294. {Nuitka_winsvc-2.4.8.dist-info → Nuitka_winsvc-2.5.1.dist-info}/top_level.txt +0 -0
@@ -15,7 +15,8 @@
15
15
  #include <structmember.h>
16
16
  #endif
17
17
 
18
- static PyObject *Nuitka_Method_get__doc__(struct Nuitka_MethodObject *method, void *closure) {
18
+ static PyObject *Nuitka_Method_get__doc__(PyObject *self, void *data) {
19
+ struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)self;
19
20
  PyObject *result = method->m_function->m_doc;
20
21
 
21
22
  if (result == NULL) {
@@ -26,8 +27,7 @@ static PyObject *Nuitka_Method_get__doc__(struct Nuitka_MethodObject *method, vo
26
27
  return result;
27
28
  }
28
29
 
29
- static PyGetSetDef Nuitka_Method_tp_getset[] = {{(char *)"__doc__", (getter)Nuitka_Method_get__doc__, NULL, NULL},
30
- {NULL}};
30
+ static PyGetSetDef Nuitka_Method_tp_getset[] = {{(char *)"__doc__", Nuitka_Method_get__doc__, NULL, NULL}, {NULL}};
31
31
 
32
32
  #define OFF(x) offsetof(struct Nuitka_MethodObject, x)
33
33
 
@@ -43,16 +43,13 @@ static PyMemberDef Nuitka_Method_members[] = {
43
43
  (char *)"the instance to which a method is bound; None for unbound method"},
44
44
  {NULL}};
45
45
 
46
- static PyObject *Nuitka_Method_reduce(struct Nuitka_MethodObject *method) {
46
+ static PyObject *Nuitka_Method_reduce(struct Nuitka_MethodObject *method, PyObject *unused) {
47
47
  PyThreadState *tstate = PyThreadState_GET();
48
48
 
49
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
- #elif PYTHON_VERSION < 0x340
54
- SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "can't pickle method objects");
55
- return NULL;
56
53
  #else
57
54
  PyObject *result = MAKE_TUPLE_EMPTY(tstate, 2);
58
55
  PyTuple_SET_ITEM0(result, 0, LOOKUP_BUILTIN(const_str_plain_getattr));
@@ -74,12 +71,9 @@ static PyObject *Nuitka_Method_reduce_ex(struct Nuitka_MethodObject *method, PyO
74
71
 
75
72
  // Python API, spell-checker: ignore copyreg,newobj
76
73
 
77
- #if PYTHON_VERSION < 0x340
78
74
  #if PYTHON_VERSION < 0x300
79
75
  PyObject *copy_reg = PyImport_ImportModule("copy_reg");
80
- #else
81
- PyObject *copy_reg = PyImport_ImportModule("copyreg");
82
- #endif
76
+
83
77
  CHECK_OBJECT(copy_reg);
84
78
  PyThreadState *tstate = PyThreadState_GET();
85
79
 
@@ -101,7 +95,7 @@ static PyObject *Nuitka_Method_reduce_ex(struct Nuitka_MethodObject *method, PyO
101
95
 
102
96
  return result;
103
97
  #else
104
- return Nuitka_Method_reduce(method);
98
+ return Nuitka_Method_reduce(method, NULL);
105
99
  #endif
106
100
  }
107
101
 
@@ -125,7 +119,10 @@ static PyObject *Nuitka_Method_deepcopy(struct Nuitka_MethodObject *method, PyOb
125
119
  return NULL;
126
120
  }
127
121
 
128
- return Nuitka_Method_New(method->m_function, object, method->m_class);
122
+ PyObject *result = Nuitka_Method_New(method->m_function, object, method->m_class);
123
+ // Nuitka_Method_New took a reference to the object.
124
+ Py_DECREF(object);
125
+ return result;
129
126
  }
130
127
 
131
128
  static PyMethodDef Nuitka_Method_methods[] = {
@@ -8,9 +8,18 @@
8
8
  #include "nuitka/prelude.h"
9
9
  #endif
10
10
 
11
+ // spell-checker: ignore PYMEM_DOMAIN,Nuitka_gc_decref,gcstate,uncollectable,sisnsn,QSBR,wrasgc
12
+ // spell-checker: ignore Nuitka_visit_decref,finalizers,wrcb,wrlist,_PyObject_GET_WEAKREFS_LISTPTR
13
+ // spell-checker: ignore objmalloc,qbsr,stoptheworld
14
+
11
15
  void *(*python_obj_malloc)(void *ctx, size_t size) = NULL;
12
16
  void *(*python_mem_malloc)(void *ctx, size_t size) = NULL;
13
17
  void *(*python_mem_calloc)(void *ctx, size_t nelem, size_t elsize) = NULL;
18
+ #ifndef Py_GIL_DISABLED
19
+ void *(*python_mem_realloc)(void *ctx, void *ptr, size_t new_size) = NULL;
20
+ #else
21
+ void (*python_mem_free)(void *ctx, void *ptr) = NULL;
22
+ #endif
14
23
 
15
24
  #if defined(Py_DEBUG)
16
25
  void *python_obj_ctx = NULL;
@@ -18,8 +27,6 @@ void *python_mem_ctx = NULL;
18
27
  #endif
19
28
 
20
29
  void initNuitkaAllocators(void) {
21
- // PyMem_SetupDebugHooks();
22
-
23
30
  PyMemAllocatorEx allocators;
24
31
 
25
32
  PyMem_GetAllocator(PYMEM_DOMAIN_OBJ, &allocators);
@@ -38,6 +45,11 @@ void initNuitkaAllocators(void) {
38
45
 
39
46
  python_mem_malloc = allocators.malloc;
40
47
  python_mem_calloc = allocators.calloc;
48
+ #ifndef Py_GIL_DISABLED
49
+ python_mem_realloc = allocators.realloc;
50
+ #else
51
+ python_mem_free = allocators.free;
52
+ #endif
41
53
  }
42
54
 
43
55
  #if PYTHON_VERSION >= 0x3b0
@@ -306,7 +318,7 @@ static void Nuitka_gc_list_move(PyGC_Head *node, PyGC_Head *list) {
306
318
  _PyGCHead_SET_NEXT(node, list);
307
319
  }
308
320
 
309
- static void Nuitka_move_legacy_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers) {
321
+ static void _Nuitka_move_legacy_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers) {
310
322
  PyGC_Head *next;
311
323
  for (PyGC_Head *gc = GC_NEXT(unreachable); gc != unreachable; gc = next) {
312
324
  PyObject *op = FROM_GC(gc);
@@ -322,11 +334,11 @@ static void Nuitka_move_legacy_finalizers(PyGC_Head *unreachable, PyGC_Head *fin
322
334
  }
323
335
  }
324
336
 
325
- static int Nuitka_visit_move(PyObject *op, PyGC_Head *tolist) {
337
+ static int _Nuitka_visit_move(PyObject *op, PyGC_Head *to_list) {
326
338
  if (_PyObject_IS_GC(op)) {
327
339
  PyGC_Head *gc = AS_GC(op);
328
340
  if (Nuitka_gc_is_collecting(gc)) {
329
- Nuitka_gc_list_move(gc, tolist);
341
+ Nuitka_gc_list_move(gc, to_list);
330
342
  Nuitka_gc_clear_collecting(gc);
331
343
  }
332
344
  }
@@ -338,7 +350,7 @@ static int Nuitka_visit_move(PyObject *op, PyGC_Head *tolist) {
338
350
  static void Nuitka_move_legacy_finalizer_reachable(PyGC_Head *finalizers) {
339
351
  for (PyGC_Head *gc = GC_NEXT(finalizers); gc != finalizers; gc = GC_NEXT(gc)) {
340
352
  traverseproc traverse = Py_TYPE(FROM_GC(gc))->tp_traverse;
341
- (void)traverse(FROM_GC(gc), (visitproc)Nuitka_visit_move, (void *)finalizers);
353
+ (void)traverse(FROM_GC(gc), (visitproc)_Nuitka_visit_move, (void *)finalizers);
342
354
  }
343
355
  }
344
356
 
@@ -350,15 +362,15 @@ static void Nuitka_finalize_garbage(PyThreadState *tstate, PyGC_Head *collectabl
350
362
 
351
363
  while (Nuitka_gc_list_is_empty(collectable) == false) {
352
364
  PyGC_Head *gc = GC_NEXT(collectable);
353
- PyObject *op = FROM_GC(gc);
365
+ PyObject *object = FROM_GC(gc);
354
366
  Nuitka_gc_list_move(gc, &seen);
355
367
 
356
- if (!_PyGCHead_FINALIZED(gc) && (finalize = Py_TYPE(op)->tp_finalize) != NULL) {
368
+ if (!_PyGCHead_FINALIZED(gc) && (finalize = Py_TYPE(object)->tp_finalize) != NULL) {
357
369
  _PyGCHead_SET_FINALIZED(gc);
358
- Py_INCREF(op);
359
- finalize(op);
370
+ Py_INCREF(object);
371
+ finalize(object);
360
372
  assert(!HAS_ERROR_OCCURRED(tstate));
361
- Py_DECREF(op);
373
+ Py_DECREF(object);
362
374
  }
363
375
  }
364
376
  Nuitka_gc_list_merge(&seen, collectable);
@@ -366,7 +378,7 @@ static void Nuitka_finalize_garbage(PyThreadState *tstate, PyGC_Head *collectabl
366
378
 
367
379
  static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable, PyGC_Head *old) {
368
380
  PyGC_Head *gc;
369
- PyObject *op;
381
+ PyObject *object;
370
382
  PyWeakReference *wr;
371
383
  PyGC_Head wrcb_to_call;
372
384
  PyGC_Head *next;
@@ -377,17 +389,17 @@ static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable,
377
389
  for (gc = GC_NEXT(unreachable); gc != unreachable; gc = next) {
378
390
  PyWeakReference **wrlist;
379
391
 
380
- op = FROM_GC(gc);
392
+ object = FROM_GC(gc);
381
393
  next = GC_NEXT(gc);
382
394
 
383
- if (PyWeakref_Check(op)) {
384
- _PyWeakref_ClearRef((PyWeakReference *)op);
395
+ if (PyWeakref_Check(object)) {
396
+ _PyWeakref_ClearRef((PyWeakReference *)object);
385
397
  }
386
398
 
387
- if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(op)))
399
+ if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(object)))
388
400
  continue;
389
401
 
390
- wrlist = (PyWeakReference **)_PyObject_GET_WEAKREFS_LISTPTR(op);
402
+ wrlist = (PyWeakReference **)_PyObject_GET_WEAKREFS_LISTPTR(object);
391
403
 
392
404
  for (wr = *wrlist; wr != NULL; wr = *wrlist) {
393
405
  PyGC_Head *wrasgc;
@@ -414,8 +426,8 @@ static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable,
414
426
  PyObject *callback;
415
427
 
416
428
  gc = (PyGC_Head *)wrcb_to_call._gc_next;
417
- op = FROM_GC(gc);
418
- wr = (PyWeakReference *)op;
429
+ object = FROM_GC(gc);
430
+ wr = (PyWeakReference *)object;
419
431
  callback = wr->wr_callback;
420
432
 
421
433
  temp = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, callback, (PyObject *)wr);
@@ -424,7 +436,7 @@ static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable,
424
436
  else
425
437
  Py_DECREF(temp);
426
438
 
427
- Py_DECREF(op);
439
+ Py_DECREF(object);
428
440
  if (wrcb_to_call._gc_next == (uintptr_t)gc) {
429
441
  Nuitka_gc_list_move(gc, old);
430
442
  } else {
@@ -466,19 +478,19 @@ static void Nuitka_delete_garbage(PyThreadState *tstate, GCState *gcstate, PyGC_
466
478
 
467
479
  while (Nuitka_gc_list_is_empty(collectable) == false) {
468
480
  PyGC_Head *gc = GC_NEXT(collectable);
469
- PyObject *op = FROM_GC(gc);
481
+ PyObject *object = FROM_GC(gc);
470
482
 
471
- _PyObject_ASSERT_WITH_MSG(op, Py_REFCNT(op) > 0, "refcount is too small");
483
+ _PyObject_ASSERT_WITH_MSG(object, Py_REFCNT(object) > 0, "refcount is too small");
472
484
 
473
485
  {
474
486
  inquiry clear;
475
- if ((clear = Py_TYPE(op)->tp_clear) != NULL) {
476
- Py_INCREF(op);
477
- (void)clear(op);
487
+ if ((clear = Py_TYPE(object)->tp_clear) != NULL) {
488
+ Py_INCREF(object);
489
+ (void)clear(object);
478
490
  if (HAS_ERROR_OCCURRED(tstate)) {
479
- _PyErr_WriteUnraisableMsg("in tp_clear of", (PyObject *)Py_TYPE(op));
491
+ _PyErr_WriteUnraisableMsg("in tp_clear of", (PyObject *)Py_TYPE(object));
480
492
  }
481
- Py_DECREF(op);
493
+ Py_DECREF(object);
482
494
  }
483
495
  }
484
496
  if (GC_NEXT(collectable) == gc) {
@@ -560,7 +572,7 @@ static Py_ssize_t Nuitka_gc_collect_main(PyThreadState *tstate, int generation,
560
572
 
561
573
  Nuitka_gc_list_init(&finalizers);
562
574
 
563
- Nuitka_move_legacy_finalizers(&unreachable, &finalizers);
575
+ _Nuitka_move_legacy_finalizers(&unreachable, &finalizers);
564
576
 
565
577
  Nuitka_move_legacy_finalizer_reachable(&finalizers);
566
578
 
@@ -673,11 +685,11 @@ void Nuitka_PyObject_GC_Link(PyObject *op) {
673
685
  gc->_gc_next = 0;
674
686
  gc->_gc_prev = 0;
675
687
 
676
- gcstate->young.count++;
677
- gcstate->heap_size++;
688
+ gcstate->generations[0].count++;
678
689
 
679
- if (gcstate->young.count > gcstate->young.threshold && gcstate->enabled && gcstate->young.threshold &&
680
- !_Py_atomic_load_int_relaxed(&gcstate->collecting) && !_PyErr_Occurred(tstate)) {
690
+ if (gcstate->generations[0].count > gcstate->generations[0].threshold && gcstate->enabled &&
691
+ gcstate->generations[0].threshold && !_Py_atomic_load_int_relaxed(&gcstate->collecting) &&
692
+ !_PyErr_Occurred(tstate)) {
681
693
  Nuitka_Py_ScheduleGC(tstate);
682
694
  }
683
695
  #endif
@@ -685,6 +697,232 @@ void Nuitka_PyObject_GC_Link(PyObject *op) {
685
697
 
686
698
  #endif
687
699
 
700
+ #ifdef Py_GIL_DISABLED
701
+
702
+ // Needs to align with CPython "objmalloc.c"
703
+ #define WORK_ITEMS_PER_CHUNK 254
704
+ struct _mem_work_item {
705
+ uintptr_t ptr; // lowest bit tagged 1 for objects freed with PyObject_Free
706
+ uint64_t qsbr_goal;
707
+ };
708
+
709
+ struct _mem_work_chunk {
710
+ struct llist_node node;
711
+
712
+ Py_ssize_t rd_idx; // index of next item to read
713
+ Py_ssize_t wr_idx; // index of next item to write
714
+ struct _mem_work_item array[WORK_ITEMS_PER_CHUNK];
715
+ };
716
+
717
+ // Aligns with CPython "qsbr.c"
718
+ #define QSBR_DEFERRED_LIMIT 10
719
+
720
+ static uint64_t Nuitka_qsbr_advance(struct _qsbr_shared *shared) {
721
+ return _Py_atomic_add_uint64(&shared->wr_seq, QSBR_INCR) + QSBR_INCR;
722
+ }
723
+
724
+ static uint64_t Nuitka_qsbr_deferred_advance(struct _qsbr_thread_state *qsbr) {
725
+ if (++qsbr->deferrals < QSBR_DEFERRED_LIMIT) {
726
+ return _Py_qsbr_shared_current(qsbr->shared) + QSBR_INCR;
727
+ }
728
+ qsbr->deferrals = 0;
729
+ return Nuitka_qsbr_advance(qsbr->shared);
730
+ }
731
+
732
+ static uint64_t _Nuitka_qsbr_poll_scan(struct _qsbr_shared *shared) {
733
+ _Py_atomic_fence_seq_cst();
734
+
735
+ uint64_t min_seq = _Py_atomic_load_uint64(&shared->wr_seq);
736
+ struct _qsbr_pad *array = shared->array;
737
+ for (Py_ssize_t i = 0, size = shared->size; i != size; i++) {
738
+ struct _qsbr_thread_state *qsbr = &array[i].qsbr;
739
+
740
+ uint64_t seq = _Py_atomic_load_uint64(&qsbr->seq);
741
+ if (seq != QSBR_OFFLINE && QSBR_LT(seq, min_seq)) {
742
+ min_seq = seq;
743
+ }
744
+ }
745
+
746
+ uint64_t rd_seq = _Py_atomic_load_uint64(&shared->rd_seq);
747
+ if (QSBR_LT(rd_seq, min_seq)) {
748
+ (void)_Py_atomic_compare_exchange_uint64(&shared->rd_seq, &rd_seq, min_seq);
749
+ rd_seq = min_seq;
750
+ }
751
+
752
+ return rd_seq;
753
+ }
754
+
755
+ static bool _Nuitka_qsbr_poll(struct _qsbr_thread_state *qsbr, uint64_t goal) {
756
+ assert(_Py_atomic_load_int_relaxed(&_PyThreadState_GET()->state) == _Py_THREAD_ATTACHED);
757
+
758
+ if (_Py_qbsr_goal_reached(qsbr, goal)) {
759
+ return true;
760
+ }
761
+
762
+ uint64_t rd_seq = _Nuitka_qsbr_poll_scan(qsbr->shared);
763
+ return QSBR_LEQ(goal, rd_seq);
764
+ }
765
+
766
+ static void _NuitkaMem_free_work_item(uintptr_t ptr) {
767
+ if (ptr & 0x01) {
768
+ PyObject_Free((char *)(ptr - 1));
769
+ } else {
770
+ NuitkaMem_Free((void *)ptr);
771
+ }
772
+ }
773
+
774
+ static struct _mem_work_chunk *work_queue_first(struct llist_node *head) {
775
+ return llist_data(head->next, struct _mem_work_chunk, node);
776
+ }
777
+
778
+ static void _Nuitka_process_queue(struct llist_node *head, struct _qsbr_thread_state *qsbr, bool keep_empty) {
779
+ while (!llist_empty(head)) {
780
+ struct _mem_work_chunk *buf = work_queue_first(head);
781
+
782
+ while (buf->rd_idx < buf->wr_idx) {
783
+ struct _mem_work_item *item = &buf->array[buf->rd_idx];
784
+ if (!_Nuitka_qsbr_poll(qsbr, item->qsbr_goal)) {
785
+ return;
786
+ }
787
+
788
+ _NuitkaMem_free_work_item(item->ptr);
789
+ buf->rd_idx++;
790
+ }
791
+
792
+ assert(buf->rd_idx == buf->wr_idx);
793
+
794
+ if (keep_empty && buf->node.next == head) {
795
+ // Keeping the last buffer as a free-list entry.
796
+ buf->rd_idx = buf->wr_idx = 0;
797
+ return;
798
+ }
799
+
800
+ llist_remove(&buf->node);
801
+ NuitkaMem_Free(buf);
802
+ }
803
+ }
804
+
805
+ struct mutex_entry {
806
+ // The time after which the unlocking thread should hand off lock ownership
807
+ // directly to the waiting thread. Written by the waiting thread.
808
+ PyTime_t time_to_be_fair;
809
+
810
+ // Set to 1 if the lock was handed off. Written by the unlocking thread.
811
+ int handed_off;
812
+ };
813
+
814
+ static const PyTime_t TIME_TO_BE_FAIR_NS = 1000 * 1000;
815
+ static const int MAX_SPIN_COUNT = 40;
816
+
817
+ static void _Nuitka_yield(void) {
818
+ #ifdef _WIN32
819
+ SwitchToThread();
820
+ #else
821
+ sched_yield();
822
+ #endif
823
+ }
824
+
825
+ PyLockStatus _NuitkaMutex_LockTimed(PyMutex *m) {
826
+ uint8_t v = _Py_atomic_load_uint8_relaxed(&m->_bits);
827
+ if ((v & _Py_LOCKED) == 0) {
828
+ if (_Py_atomic_compare_exchange_uint8(&m->_bits, &v, v | _Py_LOCKED)) {
829
+ return PY_LOCK_ACQUIRED;
830
+ }
831
+ } else {
832
+ return PY_LOCK_FAILURE;
833
+ }
834
+
835
+ Py_ssize_t spin_count = 0;
836
+
837
+ for (;;) {
838
+ if ((v & _Py_LOCKED) == 0) {
839
+ if (_Py_atomic_compare_exchange_uint8(&m->_bits, &v, v | _Py_LOCKED)) {
840
+ return PY_LOCK_ACQUIRED;
841
+ }
842
+ continue;
843
+ }
844
+
845
+ if (!(v & _Py_HAS_PARKED) && spin_count < MAX_SPIN_COUNT) {
846
+ // Spin for a bit.
847
+ _Nuitka_yield();
848
+
849
+ spin_count++;
850
+ continue;
851
+ }
852
+
853
+ return PY_LOCK_FAILURE;
854
+ }
855
+ }
856
+
857
+ static void _Nuitka_process_interp_queue(struct _Py_mem_interp_free_queue *queue, struct _qsbr_thread_state *qsbr) {
858
+ if (!_Py_atomic_load_int_relaxed(&queue->has_work)) {
859
+ return;
860
+ }
861
+
862
+ // Try to acquire the lock, but don't block if it's already held.
863
+ if (_NuitkaMutex_LockTimed(&queue->mutex) == PY_LOCK_ACQUIRED) {
864
+ _Nuitka_process_queue(&queue->head, qsbr, false);
865
+
866
+ int more_work = !llist_empty(&queue->head);
867
+ _Py_atomic_store_int_relaxed(&queue->has_work, more_work);
868
+
869
+ PyMutex_Unlock(&queue->mutex);
870
+ }
871
+ }
872
+
873
+ void _NuitkaMem_ProcessDelayed(PyThreadState *tstate) {
874
+ PyInterpreterState *interp = tstate->interp;
875
+ _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
876
+
877
+ // Release thread-local queue
878
+ _Nuitka_process_queue(&tstate_impl->mem_free_queue, tstate_impl->qsbr, true);
879
+
880
+ // Release interpreter queue
881
+ _Nuitka_process_interp_queue(&interp->mem_free_queue, tstate_impl->qsbr);
882
+ }
883
+
884
+ static void _NuitkaMem_FreeDelayed2(uintptr_t ptr) {
885
+ // Free immediately if possible.
886
+ if (_PyRuntime.stoptheworld.world_stopped) {
887
+ _NuitkaMem_free_work_item(ptr);
888
+ return;
889
+ }
890
+
891
+ // Allocate an entry for later processing.
892
+ _PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET();
893
+ struct llist_node *head = &tstate->mem_free_queue;
894
+
895
+ struct _mem_work_chunk *buf = NULL;
896
+ if (!llist_empty(head)) {
897
+ // Try to reuse the last buffer
898
+ buf = llist_data(head->prev, struct _mem_work_chunk, node);
899
+ if (buf->wr_idx == WORK_ITEMS_PER_CHUNK) {
900
+ // already full
901
+ buf = NULL;
902
+ }
903
+ }
904
+
905
+ if (buf == NULL) {
906
+ buf = NuitkaMem_Calloc(1, sizeof(*buf));
907
+ }
908
+
909
+ assert(buf != NULL && buf->wr_idx < WORK_ITEMS_PER_CHUNK);
910
+ uint64_t seq = Nuitka_qsbr_deferred_advance(tstate->qsbr);
911
+ buf->array[buf->wr_idx].ptr = ptr;
912
+ buf->array[buf->wr_idx].qsbr_goal = seq;
913
+ buf->wr_idx++;
914
+
915
+ if (buf->wr_idx == WORK_ITEMS_PER_CHUNK) {
916
+ _NuitkaMem_ProcessDelayed((PyThreadState *)tstate);
917
+ }
918
+ }
919
+
920
+ void NuitkaMem_FreeDelayed(void *ptr) {
921
+ assert(!((uintptr_t)ptr & 0x01));
922
+ _NuitkaMem_FreeDelayed2((uintptr_t)ptr);
923
+ }
924
+
925
+ #endif
688
926
  // Part of "Nuitka", an optimizing Python compiler that is compatible and
689
927
  // integrates with CPython, but also works on its own.
690
928
  //
@@ -1222,27 +1222,6 @@ PyObject *LOOKUP_MODULE_VALUE(PyDictObject *module_dict, PyObject *var_name) {
1222
1222
  return result;
1223
1223
  }
1224
1224
 
1225
- PyObject *GET_MODULE_VARIABLE_VALUE_FALLBACK(PyThreadState *tstate, PyObject *variable_name) {
1226
- PyObject *result = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)variable_name);
1227
-
1228
- if (unlikely(result == NULL)) {
1229
- SET_CURRENT_EXCEPTION_NAME_ERROR(tstate, variable_name);
1230
- }
1231
-
1232
- return result;
1233
- }
1234
-
1235
- #if PYTHON_VERSION < 0x340
1236
- PyObject *GET_MODULE_VARIABLE_VALUE_FALLBACK_IN_FUNCTION(PyThreadState *tstate, PyObject *variable_name) {
1237
- PyObject *result = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)variable_name);
1238
-
1239
- if (unlikely(result == NULL)) {
1240
- SET_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR(tstate, variable_name);
1241
- }
1242
-
1243
- return result;
1244
- }
1245
- #endif
1246
1225
  // Part of "Nuitka", an optimizing Python compiler that is compatible and
1247
1226
  // integrates with CPython, but also works on its own.
1248
1227
  //
@@ -16,10 +16,10 @@
16
16
  #endif
17
17
 
18
18
  PyObject *CALL_BUILTIN_KW_ARGS(PyThreadState *tstate, PyObject *callable, PyObject **args, char const **arg_names,
19
- int max_args) {
19
+ int max_args, int kw_only_args) {
20
20
  int i = 0;
21
21
 
22
- while (i < max_args) {
22
+ while (i < max_args - kw_only_args) {
23
23
  if (args[i] == NULL) {
24
24
  break;
25
25
  }
@@ -225,7 +225,7 @@ PyObject *BUILTIN_OPEN(PyThreadState *tstate, PyObject *file_name, PyObject *mod
225
225
 
226
226
  char const *arg_names[] = {"name", "mode", "buffering"};
227
227
 
228
- return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 3);
228
+ return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 3, 0);
229
229
  }
230
230
  #else
231
231
  PyObject *BUILTIN_OPEN(PyThreadState *tstate, PyObject *file_name, PyObject *mode, PyObject *buffering,
@@ -242,7 +242,7 @@ PyObject *BUILTIN_OPEN(PyThreadState *tstate, PyObject *file_name, PyObject *mod
242
242
 
243
243
  char const *arg_names[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener"};
244
244
 
245
- return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 8);
245
+ return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 8, 0);
246
246
  }
247
247
 
248
248
  #endif
@@ -315,7 +315,7 @@ PyObject *BUILTIN_BYTES3(PyThreadState *tstate, PyObject *value, PyObject *encod
315
315
 
316
316
  char const *arg_names[] = {"value", "encoding", "errors"};
317
317
 
318
- return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(bytes), args, arg_names, 3);
318
+ return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(bytes), args, arg_names, 3, 0);
319
319
  }
320
320
  #endif
321
321
 
@@ -422,6 +422,7 @@ PyObject *BUILTIN_HEX(PyThreadState *tstate, PyObject *value) {
422
422
 
423
423
  static void SET_HASH_NOT_IMPLEMENTED_ERROR(PyThreadState *tstate, PyObject *value) {
424
424
  // TODO: Use our own formatting code.
425
+ // spell-checker: ignore unhashable
425
426
 
426
427
  PyErr_Format(PyExc_TypeError, "unhashable type: '%s'", Py_TYPE(value)->tp_name);
427
428
  }
@@ -450,8 +451,9 @@ PyObject *BUILTIN_HASH(PyThreadState *tstate, PyObject *value) {
450
451
  }
451
452
 
452
453
  #if PYTHON_VERSION < 0x300
453
- return PyInt_FromLong(hash);
454
+ return Nuitka_PyInt_FromLong(hash);
454
455
  #else
456
+ // TODO: Have a dedicated helper of ours for this as well.
455
457
  return PyLong_FromSsize_t(hash);
456
458
  #endif
457
459
  }
@@ -459,7 +461,7 @@ PyObject *BUILTIN_HASH(PyThreadState *tstate, PyObject *value) {
459
461
  #if PYTHON_VERSION < 0x300
460
462
  if (likely(type->tp_compare == NULL && TP_RICHCOMPARE(type) == NULL)) {
461
463
  Py_hash_t hash = Nuitka_HashFromPointer(value);
462
- return PyInt_FromLong(hash);
464
+ return Nuitka_PyInt_FromLong(hash);
463
465
  }
464
466
  #endif
465
467
 
@@ -553,7 +555,7 @@ PyObject *BUILTIN_BYTEARRAY3(PyThreadState *tstate, PyObject *string, PyObject *
553
555
  * This comes in two flavors, with one or two arguments. The second one
554
556
  * creates a "calliterobject" that is private to CPython. We define it here
555
557
  * for ourselves. The one argument version is in headers for in-lining of
556
- * the code.
558
+ * the code. spell-checker: ignore calliterobject
557
559
  *
558
560
  **/
559
561
 
@@ -720,13 +722,18 @@ PyObject *BUILTIN_GETATTR(PyThreadState *tstate, PyObject *object, PyObject *att
720
722
  PyObject *result = PyObject_GetAttr(object, attribute);
721
723
 
722
724
  if (result == NULL) {
723
- if (default_value != NULL &&
724
- EXCEPTION_MATCH_BOOL_SINGLE(tstate, GET_ERROR_OCCURRED(tstate), PyExc_AttributeError)) {
725
- CLEAR_ERROR_OCCURRED(tstate);
725
+ if (default_value != NULL) {
726
+ if (HAS_ERROR_OCCURRED(tstate)) {
727
+ if (EXCEPTION_MATCH_BOOL_SINGLE(tstate, GET_ERROR_OCCURRED(tstate), PyExc_AttributeError)) {
728
+ CLEAR_ERROR_OCCURRED(tstate);
729
+ }
730
+ }
726
731
 
727
732
  Py_INCREF(default_value);
728
733
  return default_value;
729
734
  } else {
735
+ assert(HAS_ERROR_OCCURRED(tstate));
736
+
730
737
  return NULL;
731
738
  }
732
739
  } else {
@@ -750,7 +757,7 @@ PyObject *BUILTIN_SETATTR(PyObject *object, PyObject *attribute, PyObject *value
750
757
  }
751
758
 
752
759
  PyObject *BUILTIN_INT2(PyThreadState *tstate, PyObject *value, PyObject *base) {
753
- #if PYTHON_VERSION < 0x340
760
+ #if PYTHON_VERSION < 0x300
754
761
  long base_int = PyInt_AsLong(base);
755
762
  #else
756
763
  Py_ssize_t base_int = PyNumber_AsSsize_t(base, NULL);
@@ -759,7 +766,9 @@ PyObject *BUILTIN_INT2(PyThreadState *tstate, PyObject *value, PyObject *base) {
759
766
  if (unlikely(base_int == -1)) {
760
767
  PyObject *error = GET_ERROR_OCCURRED(tstate);
761
768
 
762
- if (likely(error)) {
769
+ if (likely(error != NULL)) {
770
+ assert(HAS_ERROR_OCCURRED(tstate));
771
+
763
772
  #if PYTHON_VERSION >= 0x300
764
773
  if (EXCEPTION_MATCH_BOOL_SINGLE(tstate, error, PyExc_OverflowError)) {
765
774
  PyErr_Format(PyExc_ValueError,
@@ -148,8 +148,8 @@ static PyObject *callPythonFunctionNoArgs(PyObject *func) {
148
148
 
149
149
  #endif
150
150
 
151
- PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name,
152
- PyObject *positional_args) {
151
+ PyObject *CALL_METHOD_WITH_POS_ARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name,
152
+ PyObject *positional_args) {
153
153
  CHECK_OBJECT(source);
154
154
  CHECK_OBJECT(attr_name);
155
155
  CHECK_OBJECT(positional_args);
@@ -170,7 +170,7 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
170
170
  // Note: The "called_object" was found without taking a reference,
171
171
  // so we need not release it in this branch.
172
172
  if (called_object != NULL) {
173
- return CALL_FUNCTION_WITH_POSARGS(tstate, called_object, positional_args);
173
+ return CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
174
174
  }
175
175
  // Then check the class dictionaries.
176
176
  called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
@@ -191,11 +191,11 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
191
191
  return NULL;
192
192
  }
193
193
 
194
- PyObject *result = CALL_FUNCTION_WITH_POSARGS(tstate, method, positional_args);
194
+ PyObject *result = CALL_FUNCTION_WITH_POS_ARGS(tstate, method, positional_args);
195
195
  Py_DECREF(method);
196
196
  return result;
197
197
  } else {
198
- return CALL_FUNCTION_WITH_POSARGS(tstate, called_object, positional_args);
198
+ return CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
199
199
  }
200
200
  } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
201
201
  PyErr_Format(PyExc_AttributeError, "%s instance has no attribute '%s'",
@@ -214,7 +214,7 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
214
214
  return NULL;
215
215
  }
216
216
 
217
- PyObject *result = CALL_FUNCTION_WITH_POSARGS(tstate, called_object, positional_args);
217
+ PyObject *result = CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
218
218
  Py_DECREF(called_object);
219
219
  return result;
220
220
  }
@@ -240,7 +240,7 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
240
240
  return NULL;
241
241
  }
242
242
 
243
- PyObject *result = CALL_FUNCTION_WITH_POSARGS(tstate, called_object, positional_args);
243
+ PyObject *result = CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
244
244
  Py_DECREF(called_object);
245
245
  return result;
246
246
  }