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
@@ -42,7 +42,7 @@ Py_INCREF({{context_identifier}}->m_frame);
42
42
  assert(Py_REFCNT({{context_identifier}}->m_frame) == 2); // Frame stack
43
43
  {% endif %}
44
44
 
45
- {% if is_python34_or_later %}
45
+ {% if is_python3 %}
46
46
  Nuitka_SetFrameGenerator({{context_identifier}}->m_frame, (PyObject *){{context_identifier}});
47
47
  {% endif %}
48
48
 
@@ -117,10 +117,15 @@ template_frame_guard_normal_exception_handler = """\
117
117
  RESTORE_FRAME_EXCEPTION(tstate, {{frame_identifier}});
118
118
  {% endif %}
119
119
 
120
- if ({{exception_tb}} == NULL) {
121
- {{exception_tb}} = {{tb_making_code}};
122
- } else if ({{exception_tb}}->tb_frame != &{{frame_identifier}}->m_frame) {
123
- {{exception_tb}} = ADD_TRACEBACK({{exception_tb}}, {{frame_identifier}}, {{exception_lineno}});
120
+ {
121
+ PyTracebackObject *exception_tb = GET_EXCEPTION_STATE_TRACEBACK(&{{exception_state_name}});
122
+ if (exception_tb == NULL) {
123
+ exception_tb = {{tb_making_code}};
124
+ SET_EXCEPTION_STATE_TRACEBACK(&{{exception_state_name}}, exception_tb);
125
+ } else if (exception_tb->tb_frame != &{{frame_identifier}}->m_frame) {
126
+ exception_tb = ADD_TRACEBACK(exception_tb, {{frame_identifier}}, {{exception_lineno}});
127
+ SET_EXCEPTION_STATE_TRACEBACK(&{{exception_state_name}}, exception_tb);
128
+ }
124
129
  }
125
130
 
126
131
  {% if attach_locals_code %}
@@ -174,11 +179,14 @@ template_frame_guard_generator_exception_handler = """\
174
179
  %(frame_exception_exit)s:;
175
180
 
176
181
  // If it's not an exit exception, consider and create a traceback for it.
177
- if (!EXCEPTION_MATCH_GENERATOR(tstate, %(exception_type)s)) {
178
- if (%(exception_tb)s == NULL) {
179
- %(exception_tb)s = %(tb_making)s;
180
- } else if (%(exception_tb)s->tb_frame != &%(frame_identifier)s->m_frame) {
181
- %(exception_tb)s = ADD_TRACEBACK(%(exception_tb)s, %(frame_identifier)s, %(exception_lineno)s);
182
+ if (!EXCEPTION_STATE_MATCH_GENERATOR(tstate, &%(exception_state_name)s)) {
183
+ PyTracebackObject *exception_tb = GET_EXCEPTION_STATE_TRACEBACK(&%(exception_state_name)s);
184
+ if (exception_tb == NULL) {
185
+ exception_tb = %(tb_making)s;
186
+ SET_EXCEPTION_STATE_TRACEBACK(&%(exception_state_name)s, exception_tb);
187
+ } else if ((%(exception_lineno)s != 0) && (exception_tb->tb_frame != &%(frame_identifier)s->m_frame)) {
188
+ exception_tb = ADD_TRACEBACK(exception_tb, %(frame_identifier)s, %(exception_lineno)s);
189
+ SET_EXCEPTION_STATE_TRACEBACK(&%(exception_state_name)s, exception_tb);
182
190
  }
183
191
 
184
192
  %(attach_locals)s
@@ -63,8 +63,8 @@ static PyObject *impl_%(function_identifier)s(PyThreadState *tstate, %(parameter
63
63
  template_function_exception_exit = """\
64
64
  function_exception_exit:
65
65
  %(function_cleanup)s
66
- assert(%(exception_type)s);
67
- RESTORE_ERROR_OCCURRED(tstate, %(exception_type)s, %(exception_value)s, %(exception_tb)s);
66
+ CHECK_EXCEPTION_STATE(&%(exception_state_name)s);
67
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &%(exception_state_name)s);
68
68
 
69
69
  return NULL;
70
70
  """
@@ -84,8 +84,8 @@ template_generator_exception_exit = """\
84
84
 
85
85
  function_exception_exit:
86
86
  %(function_cleanup)s
87
- assert(%(exception_type)s);
88
- RESTORE_ERROR_OCCURRED(tstate, %(exception_type)s, %(exception_value)s, %(exception_tb)s);
87
+ CHECK_EXCEPTION_STATE(&%(exception_state_name)s);
88
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &%(exception_state_name)s);
89
89
 
90
90
  return NULL;
91
91
  """
@@ -5,40 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
- template_iterator_check = """\
9
- // Check if iterator has left-over elements.
10
- CHECK_OBJECT(%(iterator_name)s); assert(HAS_ITERNEXT(%(iterator_name)s));
11
-
12
- %(attempt_name)s = (*Py_TYPE(%(iterator_name)s)->tp_iternext)(%(iterator_name)s);
13
-
14
- if (likely(%(attempt_name)s == NULL)) {
15
- PyObject *error = GET_ERROR_OCCURRED(tstate);
16
-
17
- if (error != NULL) {
18
- if (EXCEPTION_MATCH_BOOL_SINGLE(tstate, error, PyExc_StopIteration)) {
19
- CLEAR_ERROR_OCCURRED(tstate);
20
- } else {
21
- FETCH_ERROR_OCCURRED(tstate, &%(exception_type)s, &%(exception_value)s, &%(exception_tb)s);
22
- %(release_temps_1)s
23
- %(var_description_code_1)s
24
- %(line_number_code_1)s
25
- goto %(exception_exit)s;
26
- }
27
- }
28
- } else {
29
- Py_DECREF(%(attempt_name)s);
30
-
31
- %(exception_type)s = PyExc_ValueError;
32
- Py_INCREF(PyExc_ValueError);
33
- %(exception_value)s = %(too_many_values_error)s;
34
- Py_INCREF(%(exception_value)s);
35
- %(exception_tb)s = NULL;
36
- %(release_temps_2)s
37
- %(var_description_code_2)s
38
- %(line_number_code_2)s
39
- goto %(exception_exit)s;
40
- }"""
41
-
42
8
  template_loop_break_next = """\
43
9
  if (%(to_name)s == NULL) {
44
10
  if (CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED(tstate)) {
@@ -46,7 +12,7 @@ if (%(to_name)s == NULL) {
46
12
  goto %(break_target)s;
47
13
  } else {
48
14
  %(release_temps)s
49
- FETCH_ERROR_OCCURRED(tstate, &%(exception_type)s, &%(exception_value)s, &%(exception_tb)s);
15
+ FETCH_ERROR_OCCURRED_STATE(tstate, &%(exception_state_name)s);
50
16
  %(var_description_code)s
51
17
  %(line_number_code)s
52
18
  goto %(exception_target)s;
@@ -90,6 +90,36 @@ void checkModuleConstants_%(module_identifier)s(PyThreadState *tstate) {
90
90
  }
91
91
  #endif
92
92
 
93
+ // Helper to preserving module variables for Python3.11+
94
+ #if %(module_variable_accessors_count)d
95
+ #if PYTHON_VERSION >= 0x3c0
96
+ NUITKA_MAY_BE_UNUSED static uint32_t _Nuitka_PyDictKeys_GetVersionForCurrentState(PyInterpreterState *interp, PyDictKeysObject *dk)
97
+ {
98
+ if (dk->dk_version != 0) {
99
+ return dk->dk_version;
100
+ }
101
+ uint32_t result = interp->dict_state.next_keys_version++;
102
+ dk->dk_version = result;
103
+ return result;
104
+ }
105
+ #elif PYTHON_VERSION >= 0x3b0
106
+ static uint32_t _Nuitka_next_dict_keys_version = 2;
107
+
108
+ NUITKA_MAY_BE_UNUSED static uint32_t _Nuitka_PyDictKeys_GetVersionForCurrentState(PyDictKeysObject *dk)
109
+ {
110
+ if (dk->dk_version != 0) {
111
+ return dk->dk_version;
112
+ }
113
+ uint32_t result = _Nuitka_next_dict_keys_version++;
114
+ dk->dk_version = result;
115
+ return result;
116
+ }
117
+ #endif
118
+ #endif
119
+
120
+ // Accessors to module variables.
121
+ %(module_variable_accessors)s
122
+
93
123
  // The module code objects.
94
124
  %(module_code_objects_decl)s
95
125
 
@@ -152,7 +182,7 @@ static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObj
152
182
  PyObject *code_object_desc = Nuitka_Function_ExtractCodeObjectDescription(tstate, function);
153
183
 
154
184
  PyObject *result = MAKE_TUPLE_EMPTY(tstate, 8);
155
- PyTuple_SET_ITEM(result, 0, PyLong_FromLong(offset));
185
+ PyTuple_SET_ITEM(result, 0, Nuitka_PyLong_FromLong(offset));
156
186
  PyTuple_SET_ITEM(result, 1, code_object_desc);
157
187
  PyTuple_SET_ITEM0(result, 2, function->m_defaults);
158
188
  #if PYTHON_VERSION >= 0x300
@@ -425,7 +455,7 @@ PyObject *modulecode_%(module_identifier)s(PyThreadState *tstate, PyObject *modu
425
455
 
426
456
  UPDATE_STRING_DICT0(moduledict_%(module_identifier)s, (Nuitka_StringObject *)const_str_plain___loader__, Nuitka_Loader_New(loader_entry));
427
457
 
428
- #if PYTHON_VERSION >= 0x340
458
+ #if PYTHON_VERSION >= 0x300
429
459
  // Set the "__spec__" value
430
460
 
431
461
  #if %(is_dunder_main)s
@@ -535,7 +565,7 @@ static int Nuitka_TopLevelModule_tp_setattro(PyObject *module, PyObject *name, P
535
565
  }
536
566
 
537
567
  // Prevent "__spec__" update as well.
538
- #if PYTHON_VERSION >= 0x340
568
+ #if PYTHON_VERSION >= 0x300
539
569
  if (PyUnicode_Check(name) && PyUnicode_Compare(name, const_str_plain___spec__) == 0) {
540
570
  return 0;
541
571
  }
@@ -690,7 +720,7 @@ template_module_exception_exit = """\
690
720
  #endif
691
721
  PGO_onModuleExit("%(module_identifier)s", false);
692
722
 
693
- RESTORE_ERROR_OCCURRED(tstate, exception_type, exception_value, exception_tb);
723
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &exception_state);
694
724
  return NULL;
695
725
  }"""
696
726
 
@@ -290,6 +290,79 @@ if (%(test_code)s) {
290
290
  }
291
291
  """
292
292
 
293
+ template_module_variable_accessor_function = """\
294
+ static PyObject *%(accessor_function_name)s(PyThreadState *tstate) {
295
+ #if %(caching)s
296
+ PyObject *result;
297
+
298
+ #if PYTHON_VERSION < 0x3b0
299
+ static uint64_t dict_version = 0;
300
+ static PyObject *cache_value = NULL;
301
+
302
+ if (moduledict_%(module_identifier)s->ma_version_tag == dict_version) {
303
+ CHECK_OBJECT_X(cache_value);
304
+ result = cache_value;
305
+ } else {
306
+ dict_version = moduledict_%(module_identifier)s->ma_version_tag;
307
+
308
+ result = GET_STRING_DICT_VALUE(moduledict_%(module_identifier)s, (Nuitka_StringObject *)%(var_name)s);
309
+ cache_value = result;
310
+ }
311
+ #else
312
+ static uint32_t dict_keys_version = 0xFFFFFFFF;
313
+ static Py_ssize_t cache_dk_index = 0;
314
+
315
+ PyDictKeysObject *dk = moduledict_%(module_identifier)s->ma_keys;
316
+ assert(DK_IS_UNICODE(dk));
317
+
318
+ #if PYTHON_VERSION >= 0x3c0
319
+ uint32_t current_dk_version = _Nuitka_PyDictKeys_GetVersionForCurrentState(tstate->interp, dk);
320
+ #else
321
+ uint32_t current_dk_version = _Nuitka_PyDictKeys_GetVersionForCurrentState(dk);
322
+ #endif
323
+
324
+ if (current_dk_version != dict_keys_version) {
325
+ dict_keys_version = current_dk_version;
326
+ Py_hash_t hash = ((Nuitka_StringObject *)%(var_name)s)->_base._base.hash;
327
+ assert(hash != -1);
328
+
329
+ cache_dk_index = Nuitka_Py_unicodekeys_lookup_unicode(dk, %(var_name)s, hash);
330
+ }
331
+
332
+ if (cache_dk_index >= 0) {
333
+ assert(dk->dk_kind != DICT_KEYS_SPLIT);
334
+
335
+ PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(dk);
336
+
337
+ result = entries[cache_dk_index].me_value;
338
+
339
+ if (unlikely(result == NULL)) {
340
+ Py_hash_t hash = ((Nuitka_StringObject *)%(var_name)s)->_base._base.hash;
341
+ assert(hash != -1);
342
+
343
+ cache_dk_index = Nuitka_Py_unicodekeys_lookup_unicode(dk, %(var_name)s, hash);
344
+
345
+ if (cache_dk_index >= 0) {
346
+ result = entries[cache_dk_index].me_value;
347
+ }
348
+ }
349
+ } else {
350
+ result = NULL;
351
+ }
352
+ #endif
353
+
354
+ #else
355
+ PyObject *result = GET_STRING_DICT_VALUE(moduledict_%(module_identifier)s, (Nuitka_StringObject *)%(var_name)s);
356
+ #endif
357
+
358
+ if (unlikely(result == NULL)) {
359
+ result = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)%(var_name)s);
360
+ }
361
+
362
+ return result;
363
+ }
364
+ """
365
+
293
366
  from . import TemplateDebugWrapper # isort:skip
294
367
 
295
368
  TemplateDebugWrapper.checkDebug(globals())
@@ -4,11 +4,11 @@
4
4
  {% if not has_dict_values %}
5
5
  PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args, PyObject *kw_names) {
6
6
  {% elif args_count == 0 and has_dict_values %}
7
- PyObject *CALL_FUNCTION_WITH_NO_ARGS_KWSPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *kw_values, PyObject *kw_names) {
7
+ PyObject *CALL_FUNCTION_WITH_NO_ARGS_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *kw_values, PyObject *kw_names) {
8
8
  {% elif not has_tuple_arg %}
9
- PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}_KWSPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args, PyObject *const *kw_values, PyObject *kw_names) {
9
+ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args, PyObject *const *kw_values, PyObject *kw_names) {
10
10
  {% else %}
11
- PyObject *CALL_FUNCTION_WITH_POSARGS{{args_count}}_KWSPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args, PyObject *const *kw_values, PyObject *kw_names) {
11
+ PyObject *CALL_FUNCTION_WITH_POS_ARGS{{args_count}}_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args, PyObject *const *kw_values, PyObject *kw_names) {
12
12
  assert(PyTuple_CheckExact(pos_args));
13
13
  PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
14
14
  {% endif %}
@@ -8,7 +8,7 @@ PyObject *CALL_FUNCTION_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called,
8
8
  PyObject *const *args = &arg; // For easier code compatibility.
9
9
  {% else %}
10
10
  {% if has_tuple_arg %}
11
- PyObject *CALL_FUNCTION_WITH_POSARGS{{args_count}}(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
11
+ PyObject *CALL_FUNCTION_WITH_POS_ARGS{{args_count}}(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
12
12
  assert(PyTuple_CheckExact(pos_args));
13
13
  assert(PyTuple_GET_SIZE(pos_args) == {{args_count}});
14
14
  PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
@@ -484,7 +484,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
484
484
  result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, {{args_count}});
485
485
  } else {
486
486
  {% if has_tuple_arg %}
487
- result = CALL_FUNCTION_WITH_POSARGS{{args_count}}(tstate, init_method, pos_args);
487
+ result = CALL_FUNCTION_WITH_POS_ARGS{{args_count}}(tstate, init_method, pos_args);
488
488
  {% else %}
489
489
  result = CALL_FUNCTION_WITH_ARGS{{args_count}}(tstate, init_method, args);
490
490
  {% endif %}
@@ -595,7 +595,7 @@ PyObject *CALL_FUNCTION_WITH_ARGS{{args_count}}(PyThreadState *tstate, PyObject
595
595
  result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, {{args_count}});
596
596
  } else {
597
597
  {% if has_tuple_arg %}
598
- result = CALL_FUNCTION_WITH_POSARGS{{args_count}}(tstate, init_method, pos_args);
598
+ result = CALL_FUNCTION_WITH_POS_ARGS{{args_count}}(tstate, init_method, pos_args);
599
599
  {% else %}
600
600
  result = CALL_FUNCTION_WITH_ARGS{{args_count}}(tstate, init_method, args);
601
601
  {% endif %}
@@ -36,7 +36,6 @@ else
36
36
  }
37
37
  #else
38
38
  /* Python 3 */
39
- #ifndef PY_NOGIL
40
39
  if (_PyDict_HasSplitTable(dict_mp)) {
41
40
  PyDictObject *result_mp = _Nuitka_AllocatePyDictObject(tstate);
42
41
  assert(result_mp != NULL);
@@ -102,7 +101,6 @@ else
102
101
 
103
102
  Nuitka_GC_Track(result_mp);
104
103
  } else
105
- #endif
106
104
  {# TODO: This should be working for before 3.6 as well, but posed riddles with
107
105
  crashes at release time. Need to check if the keys allocator is different
108
106
  in some API somehow, or non-split dictionaries which didn't exist then are
@@ -261,21 +259,6 @@ else
261
259
  }
262
260
  {% endmacro %}
263
261
 
264
- // Usable fraction of keys.
265
- #define DK_USABLE_FRACTION(n) (((n) << 1) / 3)
266
-
267
- #if PYTHON_VERSION < 0x3b0
268
- typedef PyObject * PyDictValues;
269
- #endif
270
-
271
- #if PYTHON_VERSION < 0x360
272
- #define DK_ENTRIES_SIZE(keys) (keys->dk_size)
273
- #elif PYTHON_VERSION < 0x3b0
274
- #define DK_ENTRIES_SIZE(keys) DK_USABLE_FRACTION(DK_SIZE(keys))
275
- #else
276
- #define DK_ENTRIES_SIZE(keys) (keys->dk_nentries)
277
- #endif
278
-
279
262
  // More than 2/3 of the keys are used, i.e. no space is wasted.
280
263
  #if PYTHON_VERSION < 0x360
281
264
  #define IS_COMPACT(dict_mp) (dict_mp->ma_used >= (dict_mp->ma_keys->dk_size * 2) / 3)
@@ -304,94 +287,6 @@ static inline PyDictValues *_Nuitka_PyDict_new_values(Py_ssize_t size) {
304
287
  #endif
305
288
  }
306
289
 
307
- #if PYTHON_VERSION >= 0x300
308
- static PyDictObject *_Nuitka_AllocatePyDictObject(PyThreadState *tstate) {
309
- PyDictObject *result_mp;
310
-
311
- #if NUITKA_DICT_HAS_FREELIST
312
- // This is the CPython name, spell-checker: ignore numfree
313
-
314
- #if PYTHON_VERSION < 0x3d0
315
- PyDictObject **items = tstate->interp->dict_state.free_list;
316
- int *numfree = &tstate->interp->dict_state.numfree;
317
- #else
318
- struct _Py_object_freelists *freelists = _Nuitka_object_freelists_GET(tstate);
319
- struct _Py_dict_freelist *state = &freelists->dicts;
320
- PyDictObject **items = state->items;
321
- int *numfree = &state->numfree;
322
- #endif
323
-
324
- if (*numfree) {
325
- (*numfree) -= 1;
326
- result_mp = items[*numfree];
327
-
328
- Nuitka_Py_NewReference((PyObject *)result_mp);
329
-
330
- assert(PyDict_CheckExact((PyObject *)result_mp));
331
- assert(result_mp != NULL);
332
- } else
333
- #endif
334
- {
335
- result_mp = (PyDictObject *)Nuitka_GC_New(&PyDict_Type);
336
- }
337
-
338
- return result_mp;
339
- }
340
- #endif
341
-
342
- #if PYTHON_VERSION >= 0x360
343
- static PyDictKeysObject *_Nuitka_AllocatePyDictKeysObject(PyThreadState *tstate, Py_ssize_t keys_size) {
344
- // CPython names, spell-checker: ignore numfree,dictkeys
345
- PyDictKeysObject *dk;
346
-
347
- // TODO: Cannot always use cached objects. Need to also consider
348
- // "log2_size == PyDict_LOG_MINSIZE && unicode" as a criterion,
349
- // seems it can only be used for the smallest keys type.
350
- #if NUITKA_DICT_HAS_FREELIST && 0
351
- #if PYTHON_VERSION < 0x3d0
352
- PyDictKeysObject **items = tstate->interp->dict_state.keys_free_list;
353
- int *numfree = &tstate->interp->dict_state.keys_numfree;
354
- #else
355
- struct _Py_object_freelists *freelists = _Nuitka_object_freelists_GET(tstate);
356
- struct _Py_dictkeys_freelist *state = &freelists->dictkeys;
357
- PyDictKeysObject **items = state->items;
358
- int *numfree = &state->numfree;
359
- #endif
360
-
361
- if (*numfree) {
362
- (*numfree) -= 1;
363
- dk = items[*numfree];
364
- } else
365
- #endif
366
- {
367
- dk = (PyDictKeysObject *)NuitkaObject_Malloc(keys_size);
368
- }
369
-
370
- return dk;
371
- }
372
- #endif
373
-
374
- #if PYTHON_VERSION >= 0x360 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_DICT_OPT)
375
- static Py_ssize_t _Nuitka_Py_PyDict_KeysSize(PyDictKeysObject *keys) {
376
- #if PYTHON_VERSION < 0x360
377
- return sizeof(PyDictKeysObject) + (DK_SIZE(keys)-1) * sizeof(PyDictKeyEntry);
378
- #elif PYTHON_VERSION < 0x370
379
- return (sizeof(PyDictKeysObject) -
380
- Py_MEMBER_SIZE(PyDictKeysObject, dk_indices) +
381
- DK_IXSIZE(keys) * DK_SIZE(keys) +
382
- DK_USABLE_FRACTION(DK_SIZE(keys)) * sizeof(PyDictKeyEntry));
383
- #elif PYTHON_VERSION < 0x3b0
384
- return (sizeof(PyDictKeysObject) + DK_IXSIZE(keys) * DK_SIZE(keys) +
385
- DK_USABLE_FRACTION(DK_SIZE(keys)) * sizeof(PyDictKeyEntry));
386
- #else
387
- size_t entry_size = keys->dk_kind == DICT_KEYS_GENERAL
388
- ? sizeof(PyDictKeyEntry) : sizeof(PyDictUnicodeEntry);
389
- return (sizeof(PyDictKeysObject)
390
- + ((size_t)1 << keys->dk_log2_index_bytes)
391
- + DK_USABLE_FRACTION(DK_SIZE(keys)) * entry_size);
392
- #endif
393
- }
394
- #endif
395
290
 
396
291
  PyObject *DICT_COPY(PyThreadState *tstate, PyObject *dict_value) {
397
292
  #if _NUITKA_EXPERIMENTAL_DISABLE_DICT_OPT
@@ -11,8 +11,7 @@
11
11
  #ifndef __NUITKA_NO_ASSERT__
12
12
  PyErr_PrintEx(0);
13
13
  #endif
14
- NUITKA_CANNOT_GET_HERE("failed hard import of '{{module_name}}'");
15
- abort();
14
+ NUITKA_ERROR_EXIT("Unexpected failure of hard import of '{{module_name}}'");
16
15
  {% else %}
17
16
  return NULL;
18
17
  {% endif %}
@@ -29,7 +29,7 @@
29
29
  }
30
30
  }
31
31
 
32
- Py_ssize_t {{operand}}_size = {{operand}}_is_negative == false ? {{operand}}_digit_count : -{{operand}}_digit_count;
32
+ NUITKA_MAY_BE_UNUSED Py_ssize_t {{operand}}_size = {{operand}}_is_negative == false ? {{operand}}_digit_count : -{{operand}}_digit_count;
33
33
  {% elif type_desc == c_digit_desc %}
34
34
  {# Nothing to do really, banking on C compiler to optimize repeated operations. #}
35
35
  {% else %}
@@ -0,0 +1,115 @@
1
+ {# Copyright 2024, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file #}
2
+
3
+ {% set props = {"exits": {}} %}
4
+ {% from 'HelperSlotsInt.c.j2' import int_core with context %}
5
+ {% set bool_mode = target and target.type_name in ("nuitka_bool", "nbool") %}
6
+ bool BINARY_OPERATION_{{op_code}}_{{target.getHelperCodeName()}}_{{left.getHelperCodeName()}}_{{right.getHelperCodeName()}}({{ target.getVariableDecl("result") }}, {{left.getVariableDecl("operand1")}}, {{right.getVariableDecl("operand2")}}) {
7
+ {{ left.getCheckValueCode("operand1") }}
8
+ {{ right.getCheckValueCode("operand2") }}
9
+
10
+ bool left_c_usable = {{left.getDualValidityCheckCode("C", "operand1")}};
11
+ bool right_c_usable = {{right.getDualValidityCheckCode("C", "operand2")}};
12
+
13
+ if (left_c_usable && right_c_usable) {
14
+ {% if target.isSimilarOrSameTypesAsOneOf(n_ilong_desc) %}
15
+ // Not every code path will make use of all possible results.
16
+ #ifdef _MSC_VER
17
+ #pragma warning(push)
18
+ #pragma warning(disable : 4101)
19
+ #endif
20
+ NUITKA_MAY_BE_UNUSED bool cbool_result;
21
+ NUITKA_MAY_BE_UNUSED PyObject *obj_result;
22
+ NUITKA_MAY_BE_UNUSED long clong_result;
23
+ NUITKA_MAY_BE_UNUSED double cfloat_result;
24
+ #ifdef _MSC_VER
25
+ #pragma warning(pop)
26
+ #endif
27
+
28
+ {{int_core(props, operator, nb_slot, bool_mode, left, right, result, "operand1", "operand2", "exit_result_ok", "exit_result_exception", "exit_result_ok_cbool", "exit_result_ok_clong", "exit_result_ok_cfloat", "exit_result_object", "exit_result_ok_left", "exit_result_ok_const_int_0", "exit_result_ok_const_int_neg_1", "exit_result_ok_const_float_0_0", "exit_result_ok_const_float_minus_0_0")}}
29
+
30
+ {% if props["fall_through_needed"] %}
31
+ {% if left.isDualType() %}
32
+ {{left.getDualTypeEnsurePythonObjectCode("operand1")}}
33
+ obj_result = BINARY_OPERATION_{{op_code}}_OBJECT_{{left.getDualType("Python").getHelperCodeName()}}_{{right.getDualType("C").getHelperCodeName()}}({{left.getDualTypeAccessCode("Python", "operand1")}}, {{right.getDualTypeAccessCode("C", "operand2")}});
34
+ {% else %}
35
+ {{right.getDualTypeEnsurePythonObjectCode("operand2")}}
36
+ obj_result = BINARY_OPERATION_{{op_code}}_OBJECT_{{left.getDualType("C").getHelperCodeName()}}_{{right.getDualType("Python").getHelperCodeName()}}({{left.getDualTypeAccessCode("C", "operand1")}}, {{right.getDualTypeAccessCode("Python", "operand2")}});
37
+ {% endif %}
38
+
39
+ if (unlikely(result == NULL)) {
40
+ return false;
41
+ }
42
+
43
+ {{ target.getAssignFromObjectExpressionCode("result", "obj_result") }}
44
+ return true;
45
+
46
+ {% else %}
47
+ {{ 0/0 }}
48
+ {% endif %}
49
+ {% endif %}
50
+
51
+ {% if "exit_result_ok_clong" in props["exits"] %}
52
+ exit_result_ok_clong:
53
+ {{target.getAssignFromLongExpressionCode("result", "clong_result")}}
54
+ return true;
55
+ {% endif %}
56
+
57
+ {% if left.isDualType() %}
58
+ } else if (left_c_usable == false && right_c_usable) {
59
+ PyObject *python_result = BINARY_OPERATION_{{op_code}}_OBJECT_{{left.getDualType("Python").getHelperCodeName()}}_{{right.getDualType("C").getHelperCodeName()}}({{left.getDualTypeAccessCode("Python", "operand1")}}, {{right.getDualTypeAccessCode("C", "operand2")}});
60
+
61
+ if (unlikely(python_result == NULL)) {
62
+ return false;
63
+ }
64
+
65
+ {{ target.getSetDualValueCode("Python", "result", "python_result") }}
66
+ return true;
67
+ {% endif %}
68
+ {% if right.isDualType() %}
69
+ } else if (left_c_usable && right_c_usable == false) {
70
+ {% if left.isCommutativeType() and right.isCommutativeType() and isCommutativeOperation(op_code) %}
71
+ PyObject *python_result = BINARY_OPERATION_{{op_code}}_OBJECT_{{right.getDualType("Python").getHelperCodeName()}}_{{left.getDualType("C").getHelperCodeName()}}({{right.getDualTypeAccessCode("Python", "operand2")}}, {{left.getDualTypeAccessCode("C", "operand1")}});
72
+ {% else %}
73
+ PyObject *python_result = BINARY_OPERATION_{{op_code}}_OBJECT_{{left.getDualType("C").getHelperCodeName()}}_{{right.getDualType("Python").getHelperCodeName()}}({{left.getDualTypeAccessCode("C", "operand1")}}, {{right.getDualTypeAccessCode("Python", "operand2")}});
74
+ {% endif %}
75
+
76
+ if (unlikely(python_result == NULL)) {
77
+ return false;
78
+ }
79
+
80
+ {{ target.getSetDualValueCode("Python", "result", "python_result") }}
81
+
82
+ return true;
83
+ {% endif %}
84
+ } else {
85
+ {% if left.isDualType() and right.isDualType() %}
86
+ PyObject *python_result = BINARY_OPERATION_{{op_code}}_OBJECT_{{left.getDualType("Python").getHelperCodeName()}}_{{right.getDualType("Python").getHelperCodeName()}}({{left.getDualTypeAccessCode("Python", "operand1")}}, {{right.getDualTypeAccessCode("Python", "operand1")}});
87
+
88
+ if (unlikely(python_result == NULL)) {
89
+ return false;
90
+ }
91
+
92
+ {{ target.getSetDualValueCode("Python", "result", "python_result") }}
93
+
94
+ return true;
95
+ {% else %}
96
+ NUITKA_CANNOT_GET_HERE("cannot happen with types {{left.getHelperCodeName()}} {{right.getHelperCodeName()}}");
97
+ return false;
98
+ {% endif %}
99
+ }
100
+ }
101
+
102
+ {# Part of "Nuitka", an optimizing Python compiler that is compatible and #}
103
+ {# integrates with CPython, but also works on its own. #}
104
+ {# #}
105
+ {# Licensed under the Apache License, Version 2.0 (the "License"); #}
106
+ {# you may not use this file except in compliance with the License. #}
107
+ {# You may obtain a copy of the License at #}
108
+ {# #}
109
+ {# http://www.apache.org/licenses/LICENSE-2.0 #}
110
+ {# #}
111
+ {# Unless required by applicable law or agreed to in writing, software #}
112
+ {# distributed under the License is distributed on an "AS IS" BASIS, #}
113
+ {# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #}
114
+ {# See the License for the specific language governing permissions and #}
115
+ {# limitations under the License. #}
@@ -9,7 +9,7 @@ static {{ target.getTypeDecl() }} COMPARE_{{op_code}}_{{target.getHelperCodeName
9
9
 
10
10
  // Same object has fast path for all operations.
11
11
  if (operand1 == operand2) {
12
- {% if operand in ("==", ">=", "<=") %}
12
+ {% if operator in ("==", ">=", "<=") %}
13
13
  bool r = true;
14
14
  {% else %}
15
15
  bool r = false;
@@ -24,10 +24,10 @@ static {{ target.getTypeDecl() }} COMPARE_{{op_code}}_{{target.getHelperCodeName
24
24
  Py_ssize_t len_a = Py_SIZE(operand1);
25
25
  Py_ssize_t len_b = Py_SIZE(operand2);
26
26
 
27
- {% if operand in ("==", "!=") %}
27
+ {% if operator in ("==", "!=") %}
28
28
  if (len_a != len_b) {
29
29
  {# Shortcut for equality/inequality, driven by length divergence. #}
30
- {% if operand == "==" %}
30
+ {% if operator == "==" %}
31
31
  bool r = false;
32
32
  {% else %}
33
33
  bool r = true;
@@ -39,7 +39,7 @@ static {{ target.getTypeDecl() }} COMPARE_{{op_code}}_{{target.getHelperCodeName
39
39
  return result;
40
40
  } else {
41
41
  if ((a->ob_sval[0] == b->ob_sval[0]) && (memcmp(a->ob_sval, b->ob_sval, len_a) == 0)) {
42
- {% if operand == "==" %}
42
+ {% if operator == "==" %}
43
43
  bool r = true;
44
44
  {% else %}
45
45
  bool r = false;
@@ -50,7 +50,7 @@ static {{ target.getTypeDecl() }} COMPARE_{{op_code}}_{{target.getHelperCodeName
50
50
  {{ target.getTakeReferenceStatement("result", immortal=True) }}
51
51
  return result;
52
52
  } else {
53
- {% if operand == "==" %}
53
+ {% if operator == "==" %}
54
54
  bool r = false;
55
55
  {% else %}
56
56
  bool r = true;
@@ -81,13 +81,13 @@ static {{ target.getTypeDecl() }} COMPARE_{{op_code}}_{{target.getHelperCodeName
81
81
  c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
82
82
  }
83
83
 
84
- {% if operand == "<" %}
84
+ {% if operator == "<" %}
85
85
  c = c < 0;
86
- {% elif operand == "<=" %}
86
+ {% elif operator == "<=" %}
87
87
  c = c <= 0;
88
- {% elif operand == ">" %}
88
+ {% elif operator == ">" %}
89
89
  c = c > 0;
90
- {% elif operand == ">=" %}
90
+ {% elif operator == ">=" %}
91
91
  c = c >= 0;
92
92
  {% endif %}
93
93