Nuitka-winsvc 2.4.11__cp311-cp311-win_amd64.whl → 2.5.6__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 (304) hide show
  1. {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/METADATA +56 -109
  2. {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/RECORD +304 -280
  3. {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.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 +108 -54
  8. nuitka/Options.py +69 -13
  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 +4 -0
  20. nuitka/build/SconsCompilerSettings.py +14 -3
  21. nuitka/build/SconsInterface.py +3 -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 +8 -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 +75 -31
  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/helper/tuples.h +12 -0
  50. nuitka/build/include/nuitka/helpers.h +12 -2
  51. nuitka/build/include/nuitka/prelude.h +36 -25
  52. nuitka/build/include/nuitka/printing.h +9 -7
  53. nuitka/build/include/nuitka/threading.h +15 -1
  54. nuitka/build/include/nuitka/type_aliases.h +3 -0
  55. nuitka/build/inline_copy/stubgen/astunparse.py +938 -0
  56. nuitka/build/inline_copy/stubgen/six.py +998 -0
  57. nuitka/build/inline_copy/stubgen/stubgen.py +307 -0
  58. nuitka/build/static_src/CompiledAsyncgenType.c +45 -39
  59. nuitka/build/static_src/CompiledCellType.c +6 -4
  60. nuitka/build/static_src/CompiledCodeHelpers.c +106 -40
  61. nuitka/build/static_src/CompiledCoroutineType.c +41 -31
  62. nuitka/build/static_src/CompiledFrameType.c +110 -79
  63. nuitka/build/static_src/CompiledFunctionType.c +173 -151
  64. nuitka/build/static_src/CompiledGeneratorType.c +51 -49
  65. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +433 -46
  66. nuitka/build/static_src/CompiledMethodType.c +6 -12
  67. nuitka/build/static_src/HelpersAllocator.c +266 -28
  68. nuitka/build/static_src/HelpersAttributes.c +0 -21
  69. nuitka/build/static_src/HelpersBuiltin.c +23 -14
  70. nuitka/build/static_src/HelpersCalling.c +7 -7
  71. nuitka/build/static_src/HelpersCallingGenerated.c +70 -70
  72. nuitka/build/static_src/HelpersComparisonDualEq.c +183 -0
  73. nuitka/build/static_src/HelpersComparisonDualGe.c +121 -0
  74. nuitka/build/static_src/HelpersComparisonDualGt.c +121 -0
  75. nuitka/build/static_src/HelpersComparisonDualLe.c +183 -0
  76. nuitka/build/static_src/HelpersComparisonDualLt.c +183 -0
  77. nuitka/build/static_src/HelpersComparisonDualNe.c +121 -0
  78. nuitka/build/static_src/HelpersComparisonEq.c +18 -4
  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 +4 -2
  86. nuitka/build/static_src/HelpersDeepcopy.c +1 -0
  87. nuitka/build/static_src/HelpersDictionaries.c +195 -36
  88. nuitka/build/static_src/HelpersDictionariesGenerated.c +12 -107
  89. nuitka/build/static_src/HelpersExceptions.c +24 -50
  90. nuitka/build/static_src/HelpersFiles.c +79 -5
  91. nuitka/build/static_src/HelpersImport.c +13 -9
  92. nuitka/build/static_src/HelpersImportHard.c +23 -46
  93. nuitka/build/static_src/HelpersLists.c +98 -9
  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 +2 -2
  129. nuitka/build/static_src/HelpersTypes.c +98 -2
  130. nuitka/build/static_src/MainProgram.c +132 -28
  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 +76 -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 +4 -106
  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 +5 -2
  209. nuitka/freezer/DllDependenciesMacOS.py +18 -1
  210. nuitka/freezer/DllDependenciesWin32.py +26 -12
  211. nuitka/freezer/ImportDetection.py +6 -0
  212. nuitka/freezer/IncludedDataFiles.py +37 -6
  213. nuitka/freezer/Onefile.py +1 -0
  214. nuitka/freezer/Standalone.py +72 -18
  215. nuitka/importing/Importing.py +33 -6
  216. nuitka/importing/Recursion.py +5 -2
  217. nuitka/importing/StandardLibrary.py +57 -59
  218. nuitka/nodes/AsyncgenNodes.py +3 -6
  219. nuitka/nodes/BuiltinIteratorNodes.py +2 -2
  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/DictionaryNodes.py +1 -1
  225. nuitka/nodes/ExceptionNodes.py +102 -26
  226. nuitka/nodes/ExpressionBasesGenerated.py +288 -4
  227. nuitka/nodes/FrameNodes.py +22 -11
  228. nuitka/nodes/FunctionNodes.py +3 -3
  229. nuitka/nodes/GeneratorNodes.py +3 -6
  230. nuitka/nodes/HardImportNodesGenerated.py +182 -0
  231. nuitka/nodes/ImportNodes.py +2 -2
  232. nuitka/nodes/NodeBases.py +28 -1
  233. nuitka/nodes/NodeMakingHelpers.py +71 -50
  234. nuitka/nodes/OperatorNodesUnary.py +128 -3
  235. nuitka/nodes/OsSysNodes.py +37 -6
  236. nuitka/nodes/OutlineNodes.py +2 -2
  237. nuitka/nodes/StatementBasesGenerated.py +0 -2
  238. nuitka/nodes/StatementNodes.py +8 -7
  239. nuitka/nodes/SubscriptNodes.py +1 -1
  240. nuitka/nodes/TypeNodes.py +28 -1
  241. nuitka/nodes/VariableAssignNodes.py +2 -1
  242. nuitka/nodes/shapes/BuiltinTypeShapes.py +24 -7
  243. nuitka/nodes/shapes/IteratorShapes.py +71 -0
  244. nuitka/nodes/shapes/ShapeMixins.py +18 -0
  245. nuitka/nodes/shapes/StandardShapes.py +47 -44
  246. nuitka/optimizations/BytecodeDemotion.py +2 -1
  247. nuitka/plugins/PluginBase.py +64 -22
  248. nuitka/plugins/Plugins.py +16 -3
  249. nuitka/plugins/standard/AntiBloatPlugin.py +23 -12
  250. nuitka/plugins/standard/DllFilesPlugin.py +78 -2
  251. nuitka/plugins/standard/ImplicitImports.py +5 -15
  252. nuitka/plugins/standard/KivyPlugin.py +3 -12
  253. nuitka/plugins/standard/MatplotlibPlugin.py +12 -1
  254. nuitka/plugins/standard/MultiprocessingPlugin.py +11 -20
  255. nuitka/plugins/standard/OptionsNannyPlugin.py +5 -4
  256. nuitka/plugins/standard/PlaywrightPlugin.py +184 -0
  257. nuitka/plugins/standard/PySidePyQtPlugin.py +8 -0
  258. nuitka/plugins/standard/TkinterPlugin.py +23 -3
  259. nuitka/plugins/standard/TransformersPlugin.py +70 -275
  260. nuitka/plugins/standard/standard.nuitka-package.config.yml +413 -30
  261. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +35 -2
  262. nuitka/reports/CompilationReportReader.py +12 -0
  263. nuitka/reports/Reports.py +11 -0
  264. nuitka/specs/BuiltinParameterSpecs.py +5 -1
  265. nuitka/specs/HardImportSpecs.py +7 -0
  266. nuitka/specs/ParameterSpecs.py +4 -4
  267. nuitka/tools/environments/Virtualenv.py +13 -5
  268. nuitka/tools/general/dll_report/__main__.py +10 -1
  269. nuitka/tools/onefile_compressor/OnefileCompressor.py +1 -1
  270. nuitka/tools/podman/__main__.py +4 -2
  271. nuitka/tools/specialize/CTypeDescriptions.py +158 -9
  272. nuitka/tools/specialize/SpecializeC.py +218 -56
  273. nuitka/tools/testing/Common.py +69 -62
  274. nuitka/tools/testing/compare_with_cpython/__main__.py +3 -1
  275. nuitka/tools/testing/measure_construct_performance/__main__.py +1 -8
  276. nuitka/tools/testing/run_nuitka_tests/__main__.py +77 -11
  277. nuitka/tools/watch/AutoStage.py +1 -0
  278. nuitka/tree/Building.py +10 -37
  279. nuitka/tree/ComplexCallHelperFunctions.py +4 -0
  280. nuitka/tree/ReformulationAssertStatements.py +31 -14
  281. nuitka/tree/ReformulationAssignmentStatements.py +5 -1
  282. nuitka/tree/ReformulationClasses3.py +94 -19
  283. nuitka/tree/ReformulationDictionaryCreation.py +1 -0
  284. nuitka/tree/ReformulationFunctionStatements.py +1 -1
  285. nuitka/tree/ReformulationMatchStatements.py +3 -1
  286. nuitka/tree/ReformulationYieldExpressions.py +23 -5
  287. nuitka/utils/CommandLineOptions.py +27 -3
  288. nuitka/utils/Download.py +2 -2
  289. nuitka/utils/Execution.py +36 -31
  290. nuitka/utils/FileOperations.py +18 -39
  291. nuitka/utils/Hashing.py +5 -1
  292. nuitka/utils/Importing.py +2 -14
  293. nuitka/utils/InlineCopies.py +52 -0
  294. nuitka/utils/InstalledPythons.py +9 -4
  295. nuitka/utils/Json.py +2 -2
  296. nuitka/utils/PackageResources.py +44 -0
  297. nuitka/utils/SharedLibraries.py +24 -0
  298. nuitka/utils/Signing.py +9 -1
  299. nuitka/utils/Utils.py +1 -0
  300. {Nuitka_winsvc-2.4.11.data → Nuitka_winsvc-2.5.6.data}/scripts/nuitka-run.cmd +0 -0
  301. {Nuitka_winsvc-2.4.11.data → Nuitka_winsvc-2.5.6.data}/scripts/nuitka.cmd +0 -0
  302. {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/LICENSE.txt +0 -0
  303. {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/entry_points.txt +0 -0
  304. {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,307 @@
1
+ from __future__ import annotations
2
+ import ast
3
+ import sys
4
+ import typing
5
+
6
+ if sys.version_info < (3, 9):
7
+ from astunparse import unparse
8
+
9
+ ast.unparse = unparse
10
+
11
+ def generate_stub_from_source(source_code, output_file_path, text_only=False):
12
+ tree = ast.parse(source_code)
13
+
14
+ class StubGenerator(ast.NodeVisitor):
15
+ def __init__(self):
16
+ self.stubs = []
17
+ self.imports_helper_dict = {}
18
+ self.imports_output = set()
19
+ self.typing_imports = typing.__all__
20
+
21
+ def visit_Import(self, node: ast.Import):
22
+ for alias in node.names:
23
+ self.imports_output.add(f"import {alias.name}")
24
+
25
+ def visit_ImportFrom(self, node):
26
+ module = node.module if node.module is not None else "."
27
+ for alias in node.names:
28
+ name = alias.name
29
+
30
+ if module not in self.imports_helper_dict:
31
+ self.imports_helper_dict[module] = set()
32
+ self.imports_helper_dict[module].add(name)
33
+
34
+ def visit_FunctionDef(self, node):
35
+ if any(isinstance(n, ast.ClassDef) for n in ast.walk(tree)):
36
+ if self.is_method(node):
37
+ self.visit_MethodDef(node)
38
+ else:
39
+ self.visit_RegularFunctionDef(node)
40
+ else:
41
+ self.visit_RegularFunctionDef(node)
42
+
43
+ def visit_Assign(self, node):
44
+ for target in node.targets:
45
+ if isinstance(target, ast.Name):
46
+ target_name = target.id
47
+ target_type = ast.unparse(node.value).strip()
48
+ if target_type in self.typing_imports:
49
+ self.imports_output.add(target_type)
50
+ if target_type in self.typing_imports:
51
+ stub = f"{target_name}: {target_type}\n"
52
+ self.stubs.append(stub)
53
+ else:
54
+ if isinstance(node.value, ast.Call):
55
+ if isinstance(node.value.func, ast.Name):
56
+ if node.value.func.id == "frozenset":
57
+ stub = f"{target_name} = frozenset({', '.join([ast.unparse(arg).strip() for arg in node.value.args])})\n"
58
+ self.stubs.append(stub)
59
+ elif node.value.func.id == "namedtuple":
60
+ tuple_name = ast.unparse(node.value.args[0]).strip()
61
+
62
+ stub = f"{target_name} = namedtuple({tuple_name}, {', '.join([ast.unparse(arg).strip() for arg in node.value.args[1:]])})\n"
63
+ self.stubs.append(stub)
64
+ elif isinstance(node.value, ast.Subscript):
65
+ if isinstance(node.value.value, ast.Name):
66
+ target_name = node.value.value.id
67
+ target_type = ast.unparse(node.value).strip()
68
+ if "typing_extensions" not in self.imports_helper_dict:
69
+ self.imports_helper_dict["typing_extensions"] = set()
70
+ self.imports_helper_dict["typing_extensions"].add(
71
+ "TypeAlias"
72
+ )
73
+ stub = f"{target_name}: TypeAlias = {target_type}\n"
74
+ self.stubs.append(stub)
75
+
76
+ elif isinstance(target, ast.Subscript):
77
+ if isinstance(target.value, ast.Name):
78
+ target_name = target.value.id
79
+ else:
80
+ continue
81
+ target_type = ast.unparse(node.value).strip()
82
+ stub = f"{target_name}: {target_type}\n"
83
+ self.stubs.append(stub)
84
+
85
+ def is_method(self, node):
86
+ for parent_node in ast.walk(tree):
87
+ if isinstance(parent_node, ast.ClassDef):
88
+ for child_node in parent_node.body:
89
+ if (
90
+ isinstance(child_node, ast.FunctionDef)
91
+ and child_node.name == node.name
92
+ ):
93
+ return True
94
+ return False
95
+
96
+ def visit_MethodDef(self, node):
97
+ args_list = []
98
+ for arg in node.args.args:
99
+ arg_type = self.get_arg_type(arg)
100
+ args_list.append(f"{arg.arg}: {arg_type}")
101
+ if node.returns:
102
+ return_type = self.get_return_type(node.returns)
103
+ else:
104
+ return_type = "typing.Any"
105
+
106
+ if return_type in self.typing_imports:
107
+ self.imports_output.add(return_type)
108
+ # handle the case where the node.name is __init__, __init__ is a special case which always returns None
109
+ if node.name == "__init__":
110
+ return_type = "None"
111
+ if node.decorator_list:
112
+ for decorator in node.decorator_list:
113
+ if isinstance(decorator, ast.Name):
114
+ if decorator.id == "classmethod":
115
+ args_list = args_list[1:]
116
+ stub = f" @classmethod\n def {node.name}(cls, {', '.join(args_list)}) -> {return_type}: ...\n"
117
+
118
+ self.stubs.append(stub)
119
+ return
120
+
121
+ elif decorator.id == "staticmethod":
122
+ stub = f" @staticmethod\n def {node.name}({', '.join(args_list)}) -> {return_type}: ...\n"
123
+ self.stubs.append(stub)
124
+ return
125
+ else:
126
+ stub = f" def {node.name}({', '.join(args_list)}) -> {return_type}: ...\n"
127
+ self.stubs.append(stub)
128
+ return
129
+ stub = (
130
+ f" def {node.name}({', '.join(args_list)}) -> {return_type}: ...\n"
131
+ )
132
+ self.stubs.append(stub)
133
+
134
+ def visit_RegularFunctionDef(self, node):
135
+ args_list = []
136
+ for arg in node.args.args:
137
+ arg_type = self.get_arg_type(arg)
138
+ args_list.append(f"{arg.arg}: {arg_type}")
139
+ if node.returns:
140
+ return_type = self.get_return_type(node.returns)
141
+ else:
142
+ return_type = "typing.Any"
143
+ stub = (
144
+ f"def {node.name}({', '.join(args_list)}) -> {return_type}:\n ...\n"
145
+ )
146
+ self.stubs.append(stub)
147
+
148
+ def visit_ClassDef(self, node):
149
+ class_name = node.name
150
+ stub = ""
151
+ case = self.special_cases(node)
152
+ if case == "TypedDict":
153
+ stub = f"class {class_name}(TypedDict):\n"
154
+ if "typing" not in self.imports_helper_dict:
155
+ self.imports_helper_dict["typing"] = set()
156
+ self.imports_helper_dict["typing"].add("TypedDict")
157
+ for key in node.body:
158
+ if isinstance(key, ast.Assign):
159
+ for target in key.targets:
160
+ if isinstance(target, ast.Name):
161
+ target_name = target.id
162
+ target_type = ast.unparse(key.value).strip()
163
+ stub += f" {target_name}: {target_type}\n"
164
+ elif isinstance(target, ast.Subscript):
165
+ if isinstance(target.value, ast.Name):
166
+ target_name = target.value.id
167
+ target_type = ast.unparse(key.value).strip()
168
+ stub += f" {target_name}: {target_type}\n"
169
+ elif isinstance(key, ast.AnnAssign):
170
+ target = key.target
171
+ if isinstance(target, ast.Name):
172
+ target_name = target.id
173
+ target_type = ast.unparse(key.annotation).strip()
174
+ stub += f" {target_name}: {target_type}\n"
175
+ elif isinstance(target, ast.Subscript):
176
+ if isinstance(target.value, ast.Name):
177
+ target_name = target.value.id
178
+ target_type = ast.unparse(key.annotation).strip()
179
+ stub += f" {target_name}: {target_type}\n"
180
+ stub += "\n"
181
+ elif case == "Exception":
182
+ if not any(isinstance(n, ast.FunctionDef) for n in node.body):
183
+ stub = f"\nclass {class_name}(Exception): ..."
184
+ else:
185
+ stub = f"\nclass {class_name}(Exception):"
186
+ elif case == "NamedTuple":
187
+ stub = f"class {class_name}(NamedTuple):\n"
188
+ self.imports_output.add("from typing import NamedTuple")
189
+ else:
190
+ is_dataclass = any(isinstance(n, ast.AnnAssign) for n in node.body)
191
+ if is_dataclass:
192
+ stub = "@dataclass\n"
193
+ self.imports_output.add("from dataclasses import dataclass")
194
+ stub += f"class {class_name}:"
195
+
196
+ self.stubs.append(stub)
197
+ methods = [n for n in node.body if isinstance(n, ast.FunctionDef)]
198
+ if methods:
199
+ self.stubs.append("\n")
200
+ for method in methods:
201
+ self.visit_FunctionDef(method)
202
+
203
+ def special_cases(self, node):
204
+ for obj in node.bases:
205
+ ob_instance = isinstance(obj, ast.Name)
206
+ if ob_instance:
207
+ if obj.id == "TypedDict": # type: ignore
208
+ return "TypedDict"
209
+ elif obj.id == "Exception": # type: ignore
210
+ return "Exception"
211
+ elif obj.id == "NamedTuple": # type: ignore
212
+ return "NamedTuple"
213
+ else:
214
+ return False
215
+ return False
216
+
217
+ def get_arg_type(self, arg_node):
218
+ selfs = ["self", "cls"]
219
+ if arg_node.arg in selfs:
220
+ if "typing_extensions" not in self.imports_helper_dict:
221
+ self.imports_helper_dict["typing_extensions"] = set()
222
+ self.imports_helper_dict["typing_extensions"].add("Self")
223
+ return "Self"
224
+ elif arg_node.annotation:
225
+ unparsed = ast.unparse(arg_node.annotation).strip()
226
+ return unparsed
227
+ else:
228
+ return "typing.Any"
229
+
230
+ def get_return_type(self, return_node):
231
+ if return_node:
232
+ unparsed = ast.unparse(return_node).strip()
233
+ return unparsed
234
+ else:
235
+ return "typing.Any"
236
+
237
+ def visit_AnnAssign(self, node):
238
+ target = node.target
239
+ if isinstance(node.annotation, ast.Name):
240
+ target_type = node.annotation.id
241
+ else:
242
+ target_type = ast.unparse(node.annotation).strip()
243
+
244
+ if isinstance(node.annotation, ast.Subscript):
245
+ if isinstance(target, ast.Name):
246
+ stub = f"{target.id}: {target_type}\n"
247
+ elif isinstance(target, ast.Name):
248
+ stub = f"{target.id}: {target_type}\n"
249
+ elif isinstance(node.annotation, ast.Name):
250
+ if isinstance(target, ast.Name):
251
+ stub = f"{target.id}: {target_type}\n"
252
+ elif isinstance(target, ast.Subscript):
253
+ if isinstance(target.value, ast.Name):
254
+ target_name = target.value.id
255
+ stub = f"{target_name}: {target_type}\n"
256
+ else:
257
+ raise NotImplementedError(
258
+ f"Type {type(node.annotation)} not implemented, report this issue"
259
+ )
260
+
261
+ self.stubs.append(stub)
262
+
263
+ def generate_imports(self):
264
+ imports_helper = set()
265
+ sorted_items = sorted(self.imports_helper_dict.items())
266
+ for module, names in sorted_items:
267
+ imports_helper.add(f"from {module} import {', '.join(sorted(names))}")
268
+
269
+ imports_helper.update(self.imports_output)
270
+
271
+ self.imports_output.add("from __future__ import annotations")
272
+
273
+ imports = "".join([f"{imp}\n" for imp in imports_helper])
274
+
275
+ return imports + "\n"
276
+
277
+ stub_generator = StubGenerator()
278
+ stub_generator.visit(tree)
279
+ out_str = ""
280
+ sempt = stub_generator.generate_imports()
281
+ if sempt:
282
+ out_str += sempt
283
+ for stub in stub_generator.stubs:
284
+ out_str += stub
285
+
286
+ if text_only:
287
+ return out_str
288
+ else:
289
+
290
+ with open(output_file_path, "w") as output_file:
291
+ output_file.write(out_str)
292
+
293
+ return None
294
+
295
+ def generate_stub(source_file_path, output_file_path, text_only=False):
296
+ with open(source_file_path, "r", encoding="utf-8") as source_file:
297
+ source_code = source_file.read()
298
+
299
+ return generate_stub_from_source(source_code=source_code, output_file_path=output_file_path, text_only=text_only)
300
+
301
+
302
+ def generate_text_stub(source_file_path):
303
+ stubs = generate_stub(source_file_path, "", text_only=True)
304
+ if stubs:
305
+ return stubs
306
+ else:
307
+ raise ValueError("Stub generation failed")
@@ -63,15 +63,16 @@ static void Nuitka_MarkAsyncgenAsNotRunning(struct Nuitka_AsyncgenObject *asyncg
63
63
 
64
64
  static long Nuitka_Asyncgen_tp_hash(struct Nuitka_AsyncgenObject *asyncgen) { return asyncgen->m_counter; }
65
65
 
66
- static PyObject *Nuitka_Asyncgen_get_name(struct Nuitka_AsyncgenObject *asyncgen) {
67
- CHECK_OBJECT(asyncgen);
66
+ static PyObject *Nuitka_Asyncgen_get_name(PyObject *self, void *data) {
67
+ CHECK_OBJECT(self);
68
68
 
69
+ struct Nuitka_AsyncgenObject *asyncgen = (struct Nuitka_AsyncgenObject *)self;
69
70
  Py_INCREF(asyncgen->m_name);
70
71
  return asyncgen->m_name;
71
72
  }
72
73
 
73
- static int Nuitka_Asyncgen_set_name(struct Nuitka_AsyncgenObject *asyncgen, PyObject *value) {
74
- CHECK_OBJECT(asyncgen);
74
+ static int Nuitka_Asyncgen_set_name(PyObject *self, PyObject *value, void *data) {
75
+ CHECK_OBJECT(self);
75
76
  CHECK_OBJECT_X(value);
76
77
 
77
78
  // Cannot be deleted, not be non-unicode value.
@@ -82,6 +83,7 @@ static int Nuitka_Asyncgen_set_name(struct Nuitka_AsyncgenObject *asyncgen, PyOb
82
83
  return -1;
83
84
  }
84
85
 
86
+ struct Nuitka_AsyncgenObject *asyncgen = (struct Nuitka_AsyncgenObject *)self;
85
87
  PyObject *tmp = asyncgen->m_name;
86
88
  Py_INCREF(value);
87
89
  asyncgen->m_name = value;
@@ -90,15 +92,16 @@ static int Nuitka_Asyncgen_set_name(struct Nuitka_AsyncgenObject *asyncgen, PyOb
90
92
  return 0;
91
93
  }
92
94
 
93
- static PyObject *Nuitka_Asyncgen_get_qualname(struct Nuitka_AsyncgenObject *asyncgen) {
94
- CHECK_OBJECT(asyncgen);
95
+ static PyObject *Nuitka_Asyncgen_get_qualname(PyObject *self, void *data) {
96
+ CHECK_OBJECT(self);
95
97
 
98
+ struct Nuitka_AsyncgenObject *asyncgen = (struct Nuitka_AsyncgenObject *)self;
96
99
  Py_INCREF(asyncgen->m_qualname);
97
100
  return asyncgen->m_qualname;
98
101
  }
99
102
 
100
- static int Nuitka_Asyncgen_set_qualname(struct Nuitka_AsyncgenObject *asyncgen, PyObject *value) {
101
- CHECK_OBJECT(asyncgen);
103
+ static int Nuitka_Asyncgen_set_qualname(PyObject *self, PyObject *value, void *data) {
104
+ CHECK_OBJECT(self);
102
105
  CHECK_OBJECT_X(value);
103
106
 
104
107
  // Cannot be deleted, not be non-unicode value.
@@ -109,6 +112,7 @@ static int Nuitka_Asyncgen_set_qualname(struct Nuitka_AsyncgenObject *asyncgen,
109
112
  return -1;
110
113
  }
111
114
 
115
+ struct Nuitka_AsyncgenObject *asyncgen = (struct Nuitka_AsyncgenObject *)self;
112
116
  PyObject *tmp = asyncgen->m_qualname;
113
117
  Py_INCREF(value);
114
118
  asyncgen->m_qualname = value;
@@ -117,9 +121,10 @@ static int Nuitka_Asyncgen_set_qualname(struct Nuitka_AsyncgenObject *asyncgen,
117
121
  return 0;
118
122
  }
119
123
 
120
- static PyObject *Nuitka_Asyncgen_get_ag_await(struct Nuitka_AsyncgenObject *asyncgen) {
121
- CHECK_OBJECT(asyncgen);
124
+ static PyObject *Nuitka_Asyncgen_get_ag_await(PyObject *self, void *data) {
125
+ CHECK_OBJECT(self);
122
126
 
127
+ struct Nuitka_AsyncgenObject *asyncgen = (struct Nuitka_AsyncgenObject *)self;
123
128
  if (asyncgen->m_yield_from) {
124
129
  Py_INCREF(asyncgen->m_yield_from);
125
130
  return asyncgen->m_yield_from;
@@ -129,7 +134,8 @@ static PyObject *Nuitka_Asyncgen_get_ag_await(struct Nuitka_AsyncgenObject *asyn
129
134
  }
130
135
  }
131
136
 
132
- static PyObject *Nuitka_Asyncgen_get_code(struct Nuitka_AsyncgenObject *asyncgen) {
137
+ static PyObject *Nuitka_Asyncgen_get_code(PyObject *self, void *data) {
138
+ struct Nuitka_AsyncgenObject *asyncgen = (struct Nuitka_AsyncgenObject *)self;
133
139
  CHECK_OBJECT(asyncgen);
134
140
  CHECK_OBJECT(asyncgen->m_code_object);
135
141
 
@@ -137,8 +143,8 @@ static PyObject *Nuitka_Asyncgen_get_code(struct Nuitka_AsyncgenObject *asyncgen
137
143
  return (PyObject *)asyncgen->m_code_object;
138
144
  }
139
145
 
140
- static int Nuitka_Asyncgen_set_code(struct Nuitka_AsyncgenObject *asyncgen, PyObject *value) {
141
- CHECK_OBJECT(asyncgen);
146
+ static int Nuitka_Asyncgen_set_code(PyObject *self, PyObject *value, void *data) {
147
+ CHECK_OBJECT(self);
142
148
 
143
149
  PyThreadState *tstate = PyThreadState_GET();
144
150
 
@@ -146,7 +152,8 @@ static int Nuitka_Asyncgen_set_code(struct Nuitka_AsyncgenObject *asyncgen, PyOb
146
152
  return -1;
147
153
  }
148
154
 
149
- static PyObject *Nuitka_Asyncgen_get_frame(struct Nuitka_AsyncgenObject *asyncgen) {
155
+ static PyObject *Nuitka_Asyncgen_get_frame(PyObject *self, void *data) {
156
+ struct Nuitka_AsyncgenObject *asyncgen = (struct Nuitka_AsyncgenObject *)self;
150
157
  CHECK_OBJECT(asyncgen);
151
158
  CHECK_OBJECT_X(asyncgen->m_frame);
152
159
 
@@ -159,8 +166,8 @@ static PyObject *Nuitka_Asyncgen_get_frame(struct Nuitka_AsyncgenObject *asyncge
159
166
  }
160
167
  }
161
168
 
162
- static int Nuitka_Asyncgen_set_frame(struct Nuitka_AsyncgenObject *asyncgen, PyObject *value) {
163
- CHECK_OBJECT(asyncgen);
169
+ static int Nuitka_Asyncgen_set_frame(PyObject *self, PyObject *value, void *data) {
170
+ CHECK_OBJECT(self);
164
171
  CHECK_OBJECT_X(value);
165
172
 
166
173
  PyThreadState *tstate = PyThreadState_GET();
@@ -463,7 +470,7 @@ static PyObject *_Nuitka_Asyncgen_send(PyThreadState *tstate, struct Nuitka_Asyn
463
470
 
464
471
  switch (res) {
465
472
  case PYGEN_RETURN:
466
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopAsyncIteration);
473
+ SET_CURRENT_EXCEPTION_STOP_ASYNC_ITERATION(tstate);
467
474
  return NULL;
468
475
  case PYGEN_NEXT:
469
476
  return result;
@@ -626,7 +633,7 @@ static PyObject *_Nuitka_Asyncgen_throw2(PyThreadState *tstate, struct Nuitka_As
626
633
  if (unlikely(ret == NULL)) {
627
634
  PyObject *val;
628
635
 
629
- if (_PyGen_FetchStopIterationValue(&val) == 0) {
636
+ if (Nuitka_PyGen_FetchStopIterationValue(tstate, &val)) {
630
637
  CHECK_OBJECT(val);
631
638
 
632
639
  asyncgen->m_yield_from = NULL;
@@ -770,7 +777,7 @@ static PyObject *Nuitka_Asyncgen_throw(PyThreadState *tstate, struct Nuitka_Asyn
770
777
 
771
778
  if (result == NULL) {
772
779
  if (HAS_ERROR_OCCURRED(tstate) == false) {
773
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopAsyncIteration);
780
+ SET_CURRENT_EXCEPTION_STOP_ASYNC_ITERATION(tstate);
774
781
  }
775
782
  }
776
783
 
@@ -1049,11 +1056,11 @@ static PyAsyncMethods Nuitka_Asyncgen_as_async = {
1049
1056
  // TODO: Set "__doc__" automatically for method clones of compiled types from
1050
1057
  // the documentation of built-in original type.
1051
1058
  static PyGetSetDef Nuitka_Asyncgen_tp_getset[] = {
1052
- {(char *)"__name__", (getter)Nuitka_Asyncgen_get_name, (setter)Nuitka_Asyncgen_set_name, NULL},
1053
- {(char *)"__qualname__", (getter)Nuitka_Asyncgen_get_qualname, (setter)Nuitka_Asyncgen_set_qualname, NULL},
1054
- {(char *)"ag_await", (getter)Nuitka_Asyncgen_get_ag_await, (setter)NULL, NULL},
1055
- {(char *)"ag_code", (getter)Nuitka_Asyncgen_get_code, (setter)Nuitka_Asyncgen_set_code, NULL},
1056
- {(char *)"ag_frame", (getter)Nuitka_Asyncgen_get_frame, (setter)Nuitka_Asyncgen_set_frame, NULL},
1059
+ {(char *)"__name__", Nuitka_Asyncgen_get_name, Nuitka_Asyncgen_set_name, NULL},
1060
+ {(char *)"__qualname__", Nuitka_Asyncgen_get_qualname, Nuitka_Asyncgen_set_qualname, NULL},
1061
+ {(char *)"ag_await", Nuitka_Asyncgen_get_ag_await, NULL, NULL},
1062
+ {(char *)"ag_code", Nuitka_Asyncgen_get_code, Nuitka_Asyncgen_set_code, NULL},
1063
+ {(char *)"ag_frame", Nuitka_Asyncgen_get_frame, Nuitka_Asyncgen_set_frame, NULL},
1057
1064
 
1058
1065
  {NULL}};
1059
1066
 
@@ -1367,7 +1374,7 @@ static PyObject *_Nuitka_Asyncgen_unwrap_value(PyThreadState *tstate, struct Nui
1367
1374
  PyObject *error = GET_ERROR_OCCURRED(tstate);
1368
1375
 
1369
1376
  if (error == NULL) {
1370
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopAsyncIteration);
1377
+ SET_CURRENT_EXCEPTION_STOP_ASYNC_ITERATION(tstate);
1371
1378
  asyncgen->m_closed = true;
1372
1379
  } else if (EXCEPTION_MATCH_BOOL_SINGLE(tstate, error, PyExc_StopAsyncIteration) ||
1373
1380
  EXCEPTION_MATCH_BOOL_SINGLE(tstate, error, PyExc_GeneratorExit)) {
@@ -1449,7 +1456,7 @@ static PyObject *Nuitka_AsyncgenAsend_send(struct Nuitka_AsyncgenAsendObject *as
1449
1456
 
1450
1457
  if (asyncgen_asend->m_state == AWAITABLE_STATE_CLOSED) {
1451
1458
  #if PYTHON_VERSION < 0x390
1452
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1459
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1453
1460
  #else
1454
1461
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "cannot reuse already awaited __anext__()/asend()");
1455
1462
  #endif
@@ -1557,7 +1564,7 @@ static PyObject *Nuitka_AsyncgenAsend_throw(struct Nuitka_AsyncgenAsendObject *a
1557
1564
  PyThreadState *tstate = PyThreadState_GET();
1558
1565
 
1559
1566
  if (asyncgen_asend->m_state == AWAITABLE_STATE_CLOSED) {
1560
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1567
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1561
1568
  return NULL;
1562
1569
  }
1563
1570
 
@@ -1601,7 +1608,7 @@ static PyObject *_Nuitka_AsyncgenAsend_throw2(PyThreadState *tstate, struct Nuit
1601
1608
  #endif
1602
1609
 
1603
1610
  if (asyncgen_asend->m_state == AWAITABLE_STATE_CLOSED) {
1604
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1611
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1605
1612
  return NULL;
1606
1613
  }
1607
1614
 
@@ -1610,8 +1617,8 @@ static PyObject *_Nuitka_AsyncgenAsend_throw2(PyThreadState *tstate, struct Nuit
1610
1617
  // TODO: This might not be all that necessary as this is not directly outside facing,
1611
1618
  // but there were tests failing when this was not the specific value.
1612
1619
  if (result == NULL) {
1613
- if (GET_ERROR_OCCURRED(tstate) == NULL) {
1614
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopAsyncIteration);
1620
+ if (HAS_ERROR_OCCURRED(tstate) == false) {
1621
+ SET_CURRENT_EXCEPTION_STOP_ASYNC_ITERATION(tstate);
1615
1622
  }
1616
1623
  }
1617
1624
 
@@ -1822,7 +1829,7 @@ static PyObject *Nuitka_AsyncgenAthrow_send(struct Nuitka_AsyncgenAthrowObject *
1822
1829
  // Closing twice is not allowed with 3.9 or higher.
1823
1830
  if (asyncgen_athrow->m_state == AWAITABLE_STATE_CLOSED) {
1824
1831
  #if PYTHON_VERSION < 0x390
1825
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1832
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1826
1833
  #else
1827
1834
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "cannot reuse already awaited aclose()/athrow()");
1828
1835
  #endif
@@ -1832,7 +1839,7 @@ static PyObject *Nuitka_AsyncgenAthrow_send(struct Nuitka_AsyncgenAthrowObject *
1832
1839
 
1833
1840
  // If finished, just report StopIteration.
1834
1841
  if (asyncgen->m_status == status_Finished) {
1835
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1842
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1836
1843
  return NULL;
1837
1844
  }
1838
1845
 
@@ -1856,9 +1863,9 @@ static PyObject *Nuitka_AsyncgenAthrow_send(struct Nuitka_AsyncgenAthrowObject *
1856
1863
  if (asyncgen->m_closed) {
1857
1864
  #if PYTHON_VERSION >= 0x380
1858
1865
  asyncgen_athrow->m_state = AWAITABLE_STATE_CLOSED;
1859
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopAsyncIteration);
1866
+ SET_CURRENT_EXCEPTION_STOP_ASYNC_ITERATION(tstate);
1860
1867
  #else
1861
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1868
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1862
1869
  #endif
1863
1870
  return NULL;
1864
1871
  }
@@ -1968,7 +1975,7 @@ check_error:
1968
1975
 
1969
1976
  if (asyncgen_athrow->m_args == NULL) {
1970
1977
  CLEAR_ERROR_OCCURRED(tstate);
1971
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1978
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1972
1979
  }
1973
1980
  } else if (PyErr_ExceptionMatches(PyExc_GeneratorExit)) {
1974
1981
  asyncgen_athrow->m_state = AWAITABLE_STATE_CLOSED;
@@ -1976,8 +1983,7 @@ check_error:
1976
1983
  #if PYTHON_VERSION >= 0x380
1977
1984
  if (asyncgen_athrow->m_args == NULL) {
1978
1985
  #endif
1979
- CLEAR_ERROR_OCCURRED(tstate);
1980
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
1986
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
1981
1987
  #if PYTHON_VERSION >= 0x380
1982
1988
  }
1983
1989
  #endif
@@ -2008,7 +2014,7 @@ static PyObject *Nuitka_AsyncgenAthrow_throw(struct Nuitka_AsyncgenAthrowObject
2008
2014
 
2009
2015
  if (asyncgen_athrow->m_state == AWAITABLE_STATE_CLOSED) {
2010
2016
  #if PYTHON_VERSION < 0x390
2011
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
2017
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
2012
2018
  #else
2013
2019
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "cannot reuse already awaited aclose()/athrow()");
2014
2020
  #endif
@@ -2036,7 +2042,7 @@ static PyObject *Nuitka_AsyncgenAthrow_throw(struct Nuitka_AsyncgenAthrowObject
2036
2042
 
2037
2043
  #if PYTHON_VERSION >= 0x390
2038
2044
  if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration) || PyErr_ExceptionMatches(PyExc_GeneratorExit)) {
2039
- SET_CURRENT_EXCEPTION_TYPE0(tstate, PyExc_StopIteration);
2045
+ SET_CURRENT_EXCEPTION_STOP_ITERATION_EMPTY(tstate);
2040
2046
  }
2041
2047
  #endif
2042
2048
 
@@ -150,7 +150,8 @@ static int Nuitka_Cell_tp_clear(struct Nuitka_CellObject *cell) {
150
150
  return 0;
151
151
  }
152
152
 
153
- static PyObject *Nuitka_Cell_get_contents(struct Nuitka_CellObject *cell, void *closure) {
153
+ static PyObject *Nuitka_Cell_get_contents(PyObject *self, void *data) {
154
+ struct Nuitka_CellObject *cell = (struct Nuitka_CellObject *)self;
154
155
  if (unlikely(cell->ob_ref == NULL)) {
155
156
  PyThreadState *tstate = PyThreadState_GET();
156
157
 
@@ -163,7 +164,8 @@ static PyObject *Nuitka_Cell_get_contents(struct Nuitka_CellObject *cell, void *
163
164
  }
164
165
 
165
166
  #if PYTHON_VERSION >= 0x370
166
- static int Nuitka_Cell_set_contents(struct Nuitka_CellObject *cell, PyObject *value) {
167
+ static int Nuitka_Cell_set_contents(PyObject *self, PyObject *value, void *data) {
168
+ struct Nuitka_CellObject *cell = (struct Nuitka_CellObject *)self;
167
169
  PyObject *old = cell->ob_ref;
168
170
 
169
171
  if (old != NULL && value == NULL) {
@@ -184,9 +186,9 @@ static int Nuitka_Cell_set_contents(struct Nuitka_CellObject *cell, PyObject *va
184
186
 
185
187
  static PyGetSetDef Nuitka_Cell_tp_getset[] = {
186
188
  #if PYTHON_VERSION < 0x370
187
- {(char *)"cell_contents", (getter)Nuitka_Cell_get_contents, NULL, NULL},
189
+ {(char *)"cell_contents", Nuitka_Cell_get_contents, NULL, NULL},
188
190
  #else
189
- {(char *)"cell_contents", (getter)Nuitka_Cell_get_contents, (setter)Nuitka_Cell_set_contents, NULL},
191
+ {(char *)"cell_contents", Nuitka_Cell_get_contents, Nuitka_Cell_set_contents, NULL},
190
192
  #endif
191
193
  {NULL}};
192
194