Nuitka-winsvc 2.7.7__cp313-cp313-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 (995) hide show
  1. nuitka/Builtins.py +259 -0
  2. nuitka/BytecodeCaching.py +184 -0
  3. nuitka/Bytecodes.py +109 -0
  4. nuitka/CacheCleanup.py +54 -0
  5. nuitka/Constants.py +425 -0
  6. nuitka/Errors.py +93 -0
  7. nuitka/HardImportRegistry.py +408 -0
  8. nuitka/MainControl.py +1201 -0
  9. nuitka/ModuleRegistry.py +364 -0
  10. nuitka/OptionParsing.py +2473 -0
  11. nuitka/Options.py +2948 -0
  12. nuitka/OutputDirectories.py +201 -0
  13. nuitka/PostProcessing.py +551 -0
  14. nuitka/Progress.py +252 -0
  15. nuitka/PythonFlavors.py +426 -0
  16. nuitka/PythonOperators.py +146 -0
  17. nuitka/PythonVersions.py +513 -0
  18. nuitka/Serialization.py +291 -0
  19. nuitka/SourceCodeReferences.py +176 -0
  20. nuitka/Tracing.py +579 -0
  21. nuitka/TreeXML.py +141 -0
  22. nuitka/Variables.py +515 -0
  23. nuitka/Version.py +88 -0
  24. nuitka/__init__.py +19 -0
  25. nuitka/__main__.py +224 -0
  26. nuitka/__past__.py +217 -0
  27. nuitka/build/Backend.scons +1111 -0
  28. nuitka/build/CCompilerVersion.scons +281 -0
  29. nuitka/build/DataComposerInterface.py +116 -0
  30. nuitka/build/Offsets.scons +626 -0
  31. nuitka/build/Onefile.scons +564 -0
  32. nuitka/build/SconsCaching.py +451 -0
  33. nuitka/build/SconsCompilerSettings.py +1133 -0
  34. nuitka/build/SconsHacks.py +215 -0
  35. nuitka/build/SconsInterface.py +664 -0
  36. nuitka/build/SconsProgress.py +100 -0
  37. nuitka/build/SconsSpawn.py +436 -0
  38. nuitka/build/SconsUtils.py +939 -0
  39. nuitka/build/__init__.py +19 -0
  40. nuitka/build/include/nuitka/allocator.h +450 -0
  41. nuitka/build/include/nuitka/builtins.h +97 -0
  42. nuitka/build/include/nuitka/calling.h +123 -0
  43. nuitka/build/include/nuitka/checkers.h +39 -0
  44. nuitka/build/include/nuitka/checksum_tools.h +28 -0
  45. nuitka/build/include/nuitka/compiled_asyncgen.h +281 -0
  46. nuitka/build/include/nuitka/compiled_cell.h +64 -0
  47. nuitka/build/include/nuitka/compiled_coroutine.h +271 -0
  48. nuitka/build/include/nuitka/compiled_frame.h +502 -0
  49. nuitka/build/include/nuitka/compiled_function.h +170 -0
  50. nuitka/build/include/nuitka/compiled_generator.h +287 -0
  51. nuitka/build/include/nuitka/compiled_method.h +54 -0
  52. nuitka/build/include/nuitka/constants.h +251 -0
  53. nuitka/build/include/nuitka/constants_blob.h +34 -0
  54. nuitka/build/include/nuitka/debug_settings.h +60 -0
  55. nuitka/build/include/nuitka/environment_variables.h +30 -0
  56. nuitka/build/include/nuitka/environment_variables_system.h +51 -0
  57. nuitka/build/include/nuitka/exception_groups.h +167 -0
  58. nuitka/build/include/nuitka/exceptions.h +1458 -0
  59. nuitka/build/include/nuitka/filesystem_paths.h +117 -0
  60. nuitka/build/include/nuitka/freelists.h +92 -0
  61. nuitka/build/include/nuitka/hedley.h +1774 -0
  62. nuitka/build/include/nuitka/helper/attributes.h +90 -0
  63. nuitka/build/include/nuitka/helper/boolean.h +86 -0
  64. nuitka/build/include/nuitka/helper/bytearrays.h +34 -0
  65. nuitka/build/include/nuitka/helper/bytes.h +28 -0
  66. nuitka/build/include/nuitka/helper/calling_generated.h +132 -0
  67. nuitka/build/include/nuitka/helper/comparisons_dual_eq.h +47 -0
  68. nuitka/build/include/nuitka/helper/comparisons_dual_ge.h +39 -0
  69. nuitka/build/include/nuitka/helper/comparisons_dual_gt.h +39 -0
  70. nuitka/build/include/nuitka/helper/comparisons_dual_le.h +47 -0
  71. nuitka/build/include/nuitka/helper/comparisons_dual_lt.h +47 -0
  72. nuitka/build/include/nuitka/helper/comparisons_dual_ne.h +39 -0
  73. nuitka/build/include/nuitka/helper/comparisons_eq.h +247 -0
  74. nuitka/build/include/nuitka/helper/comparisons_ge.h +197 -0
  75. nuitka/build/include/nuitka/helper/comparisons_gt.h +197 -0
  76. nuitka/build/include/nuitka/helper/comparisons_le.h +247 -0
  77. nuitka/build/include/nuitka/helper/comparisons_lt.h +247 -0
  78. nuitka/build/include/nuitka/helper/comparisons_ne.h +197 -0
  79. nuitka/build/include/nuitka/helper/complex.h +46 -0
  80. nuitka/build/include/nuitka/helper/dictionaries.h +481 -0
  81. nuitka/build/include/nuitka/helper/floats.h +32 -0
  82. nuitka/build/include/nuitka/helper/import_hard.h +121 -0
  83. nuitka/build/include/nuitka/helper/indexes.h +47 -0
  84. nuitka/build/include/nuitka/helper/ints.h +165 -0
  85. nuitka/build/include/nuitka/helper/iterators.h +376 -0
  86. nuitka/build/include/nuitka/helper/lists.h +94 -0
  87. nuitka/build/include/nuitka/helper/lists_generated.h +36 -0
  88. nuitka/build/include/nuitka/helper/mappings.h +39 -0
  89. nuitka/build/include/nuitka/helper/operations.h +114 -0
  90. nuitka/build/include/nuitka/helper/operations_binary_add.h +240 -0
  91. nuitka/build/include/nuitka/helper/operations_binary_bitand.h +108 -0
  92. nuitka/build/include/nuitka/helper/operations_binary_bitor.h +108 -0
  93. nuitka/build/include/nuitka/helper/operations_binary_bitxor.h +108 -0
  94. nuitka/build/include/nuitka/helper/operations_binary_divmod.h +103 -0
  95. nuitka/build/include/nuitka/helper/operations_binary_dual_add.h +34 -0
  96. nuitka/build/include/nuitka/helper/operations_binary_floordiv.h +103 -0
  97. nuitka/build/include/nuitka/helper/operations_binary_lshift.h +99 -0
  98. nuitka/build/include/nuitka/helper/operations_binary_matmult.h +60 -0
  99. nuitka/build/include/nuitka/helper/operations_binary_mod.h +304 -0
  100. nuitka/build/include/nuitka/helper/operations_binary_mult.h +247 -0
  101. nuitka/build/include/nuitka/helper/operations_binary_olddiv.h +125 -0
  102. nuitka/build/include/nuitka/helper/operations_binary_pow.h +90 -0
  103. nuitka/build/include/nuitka/helper/operations_binary_rshift.h +99 -0
  104. nuitka/build/include/nuitka/helper/operations_binary_sub.h +117 -0
  105. nuitka/build/include/nuitka/helper/operations_binary_truediv.h +103 -0
  106. nuitka/build/include/nuitka/helper/operations_builtin_types.h +247 -0
  107. nuitka/build/include/nuitka/helper/operations_inplace_add.h +173 -0
  108. nuitka/build/include/nuitka/helper/operations_inplace_bitand.h +76 -0
  109. nuitka/build/include/nuitka/helper/operations_inplace_bitor.h +76 -0
  110. nuitka/build/include/nuitka/helper/operations_inplace_bitxor.h +76 -0
  111. nuitka/build/include/nuitka/helper/operations_inplace_floordiv.h +95 -0
  112. nuitka/build/include/nuitka/helper/operations_inplace_lshift.h +62 -0
  113. nuitka/build/include/nuitka/helper/operations_inplace_matmult.h +60 -0
  114. nuitka/build/include/nuitka/helper/operations_inplace_mod.h +218 -0
  115. nuitka/build/include/nuitka/helper/operations_inplace_mult.h +184 -0
  116. nuitka/build/include/nuitka/helper/operations_inplace_olddiv.h +115 -0
  117. nuitka/build/include/nuitka/helper/operations_inplace_pow.h +87 -0
  118. nuitka/build/include/nuitka/helper/operations_inplace_rshift.h +62 -0
  119. nuitka/build/include/nuitka/helper/operations_inplace_sub.h +102 -0
  120. nuitka/build/include/nuitka/helper/operations_inplace_truediv.h +95 -0
  121. nuitka/build/include/nuitka/helper/raising.h +114 -0
  122. nuitka/build/include/nuitka/helper/rangeobjects.h +66 -0
  123. nuitka/build/include/nuitka/helper/richcomparisons.h +35 -0
  124. nuitka/build/include/nuitka/helper/sequences.h +33 -0
  125. nuitka/build/include/nuitka/helper/sets.h +25 -0
  126. nuitka/build/include/nuitka/helper/slices.h +314 -0
  127. nuitka/build/include/nuitka/helper/strings.h +30 -0
  128. nuitka/build/include/nuitka/helper/subscripts.h +390 -0
  129. nuitka/build/include/nuitka/helper/tuples.h +187 -0
  130. nuitka/build/include/nuitka/helpers.h +417 -0
  131. nuitka/build/include/nuitka/importing.h +149 -0
  132. nuitka/build/include/nuitka/incbin.h +402 -0
  133. nuitka/build/include/nuitka/jit_sources.h +25 -0
  134. nuitka/build/include/nuitka/prelude.h +626 -0
  135. nuitka/build/include/nuitka/printing.h +84 -0
  136. nuitka/build/include/nuitka/python_pgo.h +57 -0
  137. nuitka/build/include/nuitka/safe_string_ops.h +57 -0
  138. nuitka/build/include/nuitka/threading.h +142 -0
  139. nuitka/build/include/nuitka/tracing.h +82 -0
  140. nuitka/build/include/nuitka/type_aliases.h +30 -0
  141. nuitka/build/include/nuitka/unfreezing.h +91 -0
  142. nuitka/build/inline_copy/appdirs/LICENSE.txt +23 -0
  143. nuitka/build/inline_copy/appdirs/appdirs.py +611 -0
  144. nuitka/build/inline_copy/atomicwrites/LICENSE +19 -0
  145. nuitka/build/inline_copy/atomicwrites/atomicwrites.py +226 -0
  146. nuitka/build/inline_copy/bin/scons.py +58 -0
  147. nuitka/build/inline_copy/clcache/clcache/LICENSE +30 -0
  148. nuitka/build/inline_copy/clcache/clcache/__init__.py +4 -0
  149. nuitka/build/inline_copy/clcache/clcache/caching.py +2008 -0
  150. nuitka/build/inline_copy/colorama/LICENSE.txt +27 -0
  151. nuitka/build/inline_copy/colorama/colorama/__init__.py +6 -0
  152. nuitka/build/inline_copy/colorama/colorama/ansi.py +102 -0
  153. nuitka/build/inline_copy/colorama/colorama/ansitowin32.py +258 -0
  154. nuitka/build/inline_copy/colorama/colorama/initialise.py +80 -0
  155. nuitka/build/inline_copy/colorama/colorama/win32.py +152 -0
  156. nuitka/build/inline_copy/colorama/colorama/winterm.py +169 -0
  157. nuitka/build/inline_copy/glob2/LICENSE +27 -0
  158. nuitka/build/inline_copy/glob2/glob2/__init__.py +5 -0
  159. nuitka/build/inline_copy/glob2/glob2/compat.py +167 -0
  160. nuitka/build/inline_copy/glob2/glob2/fnmatch.py +141 -0
  161. nuitka/build/inline_copy/glob2/glob2/impl.py +216 -0
  162. nuitka/build/inline_copy/jinja2/LICENSE.rst +28 -0
  163. nuitka/build/inline_copy/jinja2/README.rst +2 -0
  164. nuitka/build/inline_copy/jinja2/jinja2/__init__.py +72 -0
  165. nuitka/build/inline_copy/jinja2/jinja2/_compat.py +105 -0
  166. nuitka/build/inline_copy/jinja2/jinja2/_identifier.py +2 -0
  167. nuitka/build/inline_copy/jinja2/jinja2/bccache.py +361 -0
  168. nuitka/build/inline_copy/jinja2/jinja2/compiler.py +1721 -0
  169. nuitka/build/inline_copy/jinja2/jinja2/constants.py +32 -0
  170. nuitka/build/inline_copy/jinja2/jinja2/debug.py +378 -0
  171. nuitka/build/inline_copy/jinja2/jinja2/defaults.py +56 -0
  172. nuitka/build/inline_copy/jinja2/jinja2/environment.py +1276 -0
  173. nuitka/build/inline_copy/jinja2/jinja2/exceptions.py +146 -0
  174. nuitka/build/inline_copy/jinja2/jinja2/ext.py +627 -0
  175. nuitka/build/inline_copy/jinja2/jinja2/filters.py +1190 -0
  176. nuitka/build/inline_copy/jinja2/jinja2/idtracking.py +286 -0
  177. nuitka/build/inline_copy/jinja2/jinja2/lexer.py +739 -0
  178. nuitka/build/inline_copy/jinja2/jinja2/loaders.py +483 -0
  179. nuitka/build/inline_copy/jinja2/jinja2/meta.py +106 -0
  180. nuitka/build/inline_copy/jinja2/jinja2/nativetypes.py +220 -0
  181. nuitka/build/inline_copy/jinja2/jinja2/nodes.py +999 -0
  182. nuitka/build/inline_copy/jinja2/jinja2/optimizer.py +49 -0
  183. nuitka/build/inline_copy/jinja2/jinja2/parser.py +903 -0
  184. nuitka/build/inline_copy/jinja2/jinja2/runtime.py +808 -0
  185. nuitka/build/inline_copy/jinja2/jinja2/sandbox.py +488 -0
  186. nuitka/build/inline_copy/jinja2/jinja2/tests.py +174 -0
  187. nuitka/build/inline_copy/jinja2/jinja2/utils.py +642 -0
  188. nuitka/build/inline_copy/jinja2/jinja2/visitor.py +87 -0
  189. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Action.py +1475 -0
  190. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Builder.py +905 -0
  191. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/CacheDir.py +314 -0
  192. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Conftest.py +805 -0
  193. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Debug.py +251 -0
  194. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Defaults.py +646 -0
  195. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Environment.py +2561 -0
  196. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/EnvironmentValues.py +119 -0
  197. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Errors.py +222 -0
  198. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Executor.py +660 -0
  199. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Job.py +439 -0
  200. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Memoize.py +242 -0
  201. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Node/Alias.py +176 -0
  202. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Node/FS.py +3861 -0
  203. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Node/Python.py +195 -0
  204. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Node/__init__.py +1784 -0
  205. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/PathList.py +224 -0
  206. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/__init__.py +341 -0
  207. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/aix.py +81 -0
  208. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/cygwin.py +61 -0
  209. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/darwin.py +70 -0
  210. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/hpux.py +45 -0
  211. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/irix.py +41 -0
  212. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/mingw.py +33 -0
  213. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/os2.py +55 -0
  214. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/posix.py +124 -0
  215. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/sunos.py +47 -0
  216. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/virtualenv.py +115 -0
  217. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Platform/win32.py +429 -0
  218. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/SConf.py +1119 -0
  219. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/SConsign.py +453 -0
  220. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Scanner/C.py +226 -0
  221. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Scanner/Dir.py +131 -0
  222. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Scanner/Prog.py +114 -0
  223. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Scanner/RC.py +57 -0
  224. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Scanner/__init__.py +436 -0
  225. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Script/Interactive.py +372 -0
  226. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Script/Main.py +1469 -0
  227. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Script/SConsOptions.py +1071 -0
  228. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Script/SConscript.py +686 -0
  229. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Script/__init__.py +425 -0
  230. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Subst.py +979 -0
  231. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Taskmaster.py +1062 -0
  232. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/386asm.py +61 -0
  233. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/GettextCommon.py +429 -0
  234. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/MSCommon/__init__.py +52 -0
  235. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/MSCommon/arch.py +66 -0
  236. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/MSCommon/common.py +371 -0
  237. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/MSCommon/netframework.py +83 -0
  238. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/MSCommon/sdk.py +411 -0
  239. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/MSCommon/vc.py +994 -0
  240. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/MSCommon/vs.py +608 -0
  241. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/PharLapCommon.py +116 -0
  242. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/__init__.py +882 -0
  243. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/aixc++.py +43 -0
  244. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/aixcc.py +74 -0
  245. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/aixcxx.py +77 -0
  246. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/aixlink.py +78 -0
  247. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/applelink.py +209 -0
  248. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/ar.py +63 -0
  249. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/as.py +49 -0
  250. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/asm.py +78 -0
  251. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/bcc32.py +81 -0
  252. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/c++.py +44 -0
  253. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/cc.py +105 -0
  254. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/clang.py +91 -0
  255. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/clangCommon/__init__.py +18 -0
  256. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/clangxx.py +99 -0
  257. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/cxx.py +95 -0
  258. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/cyglink.py +212 -0
  259. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/default.py +50 -0
  260. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/filesystem.py +98 -0
  261. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/g++.py +45 -0
  262. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/gas.py +56 -0
  263. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/gcc.py +110 -0
  264. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/gettext_tool.py +69 -0
  265. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/gnulink.py +70 -0
  266. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/gxx.py +78 -0
  267. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/hpc++.py +45 -0
  268. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/hpcc.py +53 -0
  269. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/hpcxx.py +88 -0
  270. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/hplink.py +72 -0
  271. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/icc.py +59 -0
  272. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/icl.py +52 -0
  273. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/ilink.py +55 -0
  274. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/ilink32.py +60 -0
  275. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/install.py +510 -0
  276. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/intelc.py +617 -0
  277. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/link.py +72 -0
  278. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/linkCommon/LoadableModule.py +131 -0
  279. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/linkCommon/SharedLibrary.py +218 -0
  280. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/linkCommon/__init__.py +171 -0
  281. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/linkloc.py +112 -0
  282. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/m4.py +63 -0
  283. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/masm.py +77 -0
  284. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/mingw.py +232 -0
  285. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/msgfmt.py +132 -0
  286. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/msginit.py +137 -0
  287. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/msgmerge.py +125 -0
  288. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/mslib.py +73 -0
  289. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/mslink.py +339 -0
  290. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/mssdk.py +50 -0
  291. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/msvc.py +325 -0
  292. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/msvs.py +2116 -0
  293. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/mwcc.py +207 -0
  294. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/mwld.py +108 -0
  295. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/nasm.py +72 -0
  296. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/rmic.py +139 -0
  297. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/rpcgen.py +70 -0
  298. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sgiar.py +68 -0
  299. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sgic++.py +43 -0
  300. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sgicc.py +53 -0
  301. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sgicxx.py +61 -0
  302. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sgilink.py +59 -0
  303. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sunar.py +64 -0
  304. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sunc++.py +45 -0
  305. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/suncc.py +58 -0
  306. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/suncxx.py +153 -0
  307. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/sunlink.py +79 -0
  308. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/tar.py +73 -0
  309. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/textfile.py +198 -0
  310. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/tlib.py +53 -0
  311. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/wix.py +104 -0
  312. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/xgettext.py +337 -0
  313. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Tool/zip.py +120 -0
  314. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Util.py +2134 -0
  315. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Utilities/ConfigureCache.py +171 -0
  316. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Utilities/__init__.py +0 -0
  317. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Utilities/sconsign.py +494 -0
  318. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Variables/BoolVariable.py +96 -0
  319. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Variables/EnumVariable.py +110 -0
  320. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Variables/ListVariable.py +152 -0
  321. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Variables/PackageVariable.py +107 -0
  322. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Variables/PathVariable.py +158 -0
  323. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Variables/__init__.py +334 -0
  324. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/Warnings.py +238 -0
  325. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/__init__.py +9 -0
  326. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/compat/__init__.py +104 -0
  327. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/compat/_scons_dbm.py +42 -0
  328. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/compat/win32.py +101 -0
  329. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/cpp.py +640 -0
  330. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/dblite.py +295 -0
  331. nuitka/build/inline_copy/lib/scons-4.3.0/SCons/exitfuncs.py +59 -0
  332. nuitka/build/inline_copy/markupsafe/LICENSE.rst +28 -0
  333. nuitka/build/inline_copy/markupsafe/markupsafe/__init__.py +327 -0
  334. nuitka/build/inline_copy/markupsafe/markupsafe/_compat.py +33 -0
  335. nuitka/build/inline_copy/markupsafe/markupsafe/_constants.py +264 -0
  336. nuitka/build/inline_copy/markupsafe/markupsafe/_native.py +69 -0
  337. nuitka/build/inline_copy/pefile/LICENSE.txt +21 -0
  338. nuitka/build/inline_copy/pefile/ordlookup/__init__.py +41 -0
  339. nuitka/build/inline_copy/pefile/ordlookup/oleaut32.py +400 -0
  340. nuitka/build/inline_copy/pefile/ordlookup/ws2_32.py +120 -0
  341. nuitka/build/inline_copy/pefile/pefile.py +8034 -0
  342. nuitka/build/inline_copy/pkg_resources/pkg_resources/__init__.py +3272 -0
  343. nuitka/build/inline_copy/pkg_resources/pkg_resources/py31compat.py +21 -0
  344. nuitka/build/inline_copy/python_hacl/LICENSE.txt +201 -0
  345. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_MD5.c +1430 -0
  346. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_MD5.h +66 -0
  347. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_SHA1.c +463 -0
  348. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_SHA1.h +66 -0
  349. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_SHA2.c +1273 -0
  350. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_SHA2.h +204 -0
  351. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_SHA3.c +734 -0
  352. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Hash_SHA3.h +131 -0
  353. nuitka/build/inline_copy/python_hacl/hacl_312/Hacl_Streaming_Types.h +83 -0
  354. nuitka/build/inline_copy/python_hacl/hacl_312/include/krml/FStar_UInt128_Verified.h +346 -0
  355. nuitka/build/inline_copy/python_hacl/hacl_312/include/krml/FStar_UInt_8_16_32_64.h +107 -0
  356. nuitka/build/inline_copy/python_hacl/hacl_312/include/krml/fstar_uint128_struct_endianness.h +68 -0
  357. nuitka/build/inline_copy/python_hacl/hacl_312/include/krml/internal/target.h +293 -0
  358. nuitka/build/inline_copy/python_hacl/hacl_312/include/krml/lowstar_endianness.h +231 -0
  359. nuitka/build/inline_copy/python_hacl/hacl_312/include/krml/types.h +14 -0
  360. nuitka/build/inline_copy/python_hacl/hacl_312/internal/Hacl_Hash_MD5.h +56 -0
  361. nuitka/build/inline_copy/python_hacl/hacl_312/internal/Hacl_Hash_SHA1.h +56 -0
  362. nuitka/build/inline_copy/python_hacl/hacl_312/internal/Hacl_Hash_SHA2.h +164 -0
  363. nuitka/build/inline_copy/python_hacl/hacl_312/internal/Hacl_Hash_SHA3.h +65 -0
  364. nuitka/build/inline_copy/python_hacl/hacl_312/python_hacl_namespaces.h +89 -0
  365. nuitka/build/inline_copy/stubgen/astunparse.py +938 -0
  366. nuitka/build/inline_copy/stubgen/six.py +998 -0
  367. nuitka/build/inline_copy/stubgen/stubgen.py +484 -0
  368. nuitka/build/inline_copy/tqdm/tqdm/__init__.py +40 -0
  369. nuitka/build/inline_copy/tqdm/tqdm/_main.py +9 -0
  370. nuitka/build/inline_copy/tqdm/tqdm/_monitor.py +97 -0
  371. nuitka/build/inline_copy/tqdm/tqdm/_tqdm.py +9 -0
  372. nuitka/build/inline_copy/tqdm/tqdm/_tqdm_notebook.py +9 -0
  373. nuitka/build/inline_copy/tqdm/tqdm/_tqdm_pandas.py +24 -0
  374. nuitka/build/inline_copy/tqdm/tqdm/_utils.py +12 -0
  375. nuitka/build/inline_copy/tqdm/tqdm/auto.py +44 -0
  376. nuitka/build/inline_copy/tqdm/tqdm/autonotebook.py +28 -0
  377. nuitka/build/inline_copy/tqdm/tqdm/dask.py +46 -0
  378. nuitka/build/inline_copy/tqdm/tqdm/notebook.py +316 -0
  379. nuitka/build/inline_copy/tqdm/tqdm/std.py +1524 -0
  380. nuitka/build/inline_copy/tqdm/tqdm/tk.py +207 -0
  381. nuitka/build/inline_copy/tqdm/tqdm/utils.py +351 -0
  382. nuitka/build/inline_copy/tqdm/tqdm/version.py +2 -0
  383. nuitka/build/inline_copy/yaml/LICENSE +20 -0
  384. nuitka/build/inline_copy/yaml/yaml/__init__.py +427 -0
  385. nuitka/build/inline_copy/yaml/yaml/composer.py +139 -0
  386. nuitka/build/inline_copy/yaml/yaml/constructor.py +748 -0
  387. nuitka/build/inline_copy/yaml/yaml/cyaml.py +101 -0
  388. nuitka/build/inline_copy/yaml/yaml/dumper.py +62 -0
  389. nuitka/build/inline_copy/yaml/yaml/emitter.py +1137 -0
  390. nuitka/build/inline_copy/yaml/yaml/error.py +75 -0
  391. nuitka/build/inline_copy/yaml/yaml/events.py +86 -0
  392. nuitka/build/inline_copy/yaml/yaml/loader.py +63 -0
  393. nuitka/build/inline_copy/yaml/yaml/nodes.py +49 -0
  394. nuitka/build/inline_copy/yaml/yaml/parser.py +589 -0
  395. nuitka/build/inline_copy/yaml/yaml/reader.py +185 -0
  396. nuitka/build/inline_copy/yaml/yaml/representer.py +389 -0
  397. nuitka/build/inline_copy/yaml/yaml/resolver.py +227 -0
  398. nuitka/build/inline_copy/yaml/yaml/scanner.py +1435 -0
  399. nuitka/build/inline_copy/yaml/yaml/serializer.py +111 -0
  400. nuitka/build/inline_copy/yaml/yaml/tokens.py +104 -0
  401. nuitka/build/inline_copy/zlib/LICENSE +22 -0
  402. nuitka/build/inline_copy/zlib/crc32.c +1049 -0
  403. nuitka/build/inline_copy/zlib/crc32.h +9446 -0
  404. nuitka/build/inline_copy/zlib/zconf.h +551 -0
  405. nuitka/build/inline_copy/zlib/zlib.h +1938 -0
  406. nuitka/build/inline_copy/zlib/zutil.h +275 -0
  407. nuitka/build/inline_copy/zstd/LICENSE.txt +30 -0
  408. nuitka/build/inline_copy/zstd/common/bitstream.h +463 -0
  409. nuitka/build/inline_copy/zstd/common/compiler.h +288 -0
  410. nuitka/build/inline_copy/zstd/common/cpu.h +213 -0
  411. nuitka/build/inline_copy/zstd/common/debug.h +107 -0
  412. nuitka/build/inline_copy/zstd/common/entropy_common.c +360 -0
  413. nuitka/build/inline_copy/zstd/common/error_private.c +56 -0
  414. nuitka/build/inline_copy/zstd/common/error_private.h +80 -0
  415. nuitka/build/inline_copy/zstd/common/fse.h +715 -0
  416. nuitka/build/inline_copy/zstd/common/fse_decompress.c +393 -0
  417. nuitka/build/inline_copy/zstd/common/huf.h +361 -0
  418. nuitka/build/inline_copy/zstd/common/mem.h +426 -0
  419. nuitka/build/inline_copy/zstd/common/xxhash.c +826 -0
  420. nuitka/build/inline_copy/zstd/common/xxhash.h +285 -0
  421. nuitka/build/inline_copy/zstd/common/zstd_common.c +83 -0
  422. nuitka/build/inline_copy/zstd/common/zstd_deps.h +111 -0
  423. nuitka/build/inline_copy/zstd/common/zstd_errors.h +95 -0
  424. nuitka/build/inline_copy/zstd/common/zstd_internal.h +478 -0
  425. nuitka/build/inline_copy/zstd/decompress/huf_decompress.c +1350 -0
  426. nuitka/build/inline_copy/zstd/decompress/zstd_ddict.c +244 -0
  427. nuitka/build/inline_copy/zstd/decompress/zstd_ddict.h +44 -0
  428. nuitka/build/inline_copy/zstd/decompress/zstd_decompress.c +1930 -0
  429. nuitka/build/inline_copy/zstd/decompress/zstd_decompress_block.c +1540 -0
  430. nuitka/build/inline_copy/zstd/decompress/zstd_decompress_block.h +62 -0
  431. nuitka/build/inline_copy/zstd/decompress/zstd_decompress_internal.h +190 -0
  432. nuitka/build/inline_copy/zstd/zstd.h +2391 -0
  433. nuitka/build/static_src/CompiledAsyncgenType.c +2211 -0
  434. nuitka/build/static_src/CompiledCellType.c +300 -0
  435. nuitka/build/static_src/CompiledCodeHelpers.c +2160 -0
  436. nuitka/build/static_src/CompiledCoroutineType.c +1946 -0
  437. nuitka/build/static_src/CompiledFrameType.c +1337 -0
  438. nuitka/build/static_src/CompiledFunctionType.c +3320 -0
  439. nuitka/build/static_src/CompiledGeneratorType.c +1997 -0
  440. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +2117 -0
  441. nuitka/build/static_src/CompiledMethodType.c +614 -0
  442. nuitka/build/static_src/GenerateHeadersMain.c +30 -0
  443. nuitka/build/static_src/HelpersAllocator.c +939 -0
  444. nuitka/build/static_src/HelpersAttributes.c +1241 -0
  445. nuitka/build/static_src/HelpersBuiltin.c +901 -0
  446. nuitka/build/static_src/HelpersBuiltinTypeMethods.c +3594 -0
  447. nuitka/build/static_src/HelpersBytes.c +107 -0
  448. nuitka/build/static_src/HelpersCalling.c +397 -0
  449. nuitka/build/static_src/HelpersCallingGenerated.c +14361 -0
  450. nuitka/build/static_src/HelpersChecksumTools.c +59 -0
  451. nuitka/build/static_src/HelpersClasses.c +91 -0
  452. nuitka/build/static_src/HelpersComparisonDualEq.c +183 -0
  453. nuitka/build/static_src/HelpersComparisonDualGe.c +121 -0
  454. nuitka/build/static_src/HelpersComparisonDualGt.c +121 -0
  455. nuitka/build/static_src/HelpersComparisonDualLe.c +183 -0
  456. nuitka/build/static_src/HelpersComparisonDualLt.c +183 -0
  457. nuitka/build/static_src/HelpersComparisonDualNe.c +121 -0
  458. nuitka/build/static_src/HelpersComparisonEq.c +12070 -0
  459. nuitka/build/static_src/HelpersComparisonEqUtils.c +169 -0
  460. nuitka/build/static_src/HelpersComparisonGe.c +11871 -0
  461. nuitka/build/static_src/HelpersComparisonGt.c +11855 -0
  462. nuitka/build/static_src/HelpersComparisonLe.c +11957 -0
  463. nuitka/build/static_src/HelpersComparisonLt.c +11941 -0
  464. nuitka/build/static_src/HelpersComparisonNe.c +11979 -0
  465. nuitka/build/static_src/HelpersConsole.c +124 -0
  466. nuitka/build/static_src/HelpersConstantsBlob.c +1487 -0
  467. nuitka/build/static_src/HelpersDeepcopy.c +636 -0
  468. nuitka/build/static_src/HelpersDictionaries.c +1739 -0
  469. nuitka/build/static_src/HelpersDictionariesGenerated.c +738 -0
  470. nuitka/build/static_src/HelpersDumpBacktraces.c +63 -0
  471. nuitka/build/static_src/HelpersEnvironmentVariables.c +65 -0
  472. nuitka/build/static_src/HelpersEnvironmentVariablesSystem.c +97 -0
  473. nuitka/build/static_src/HelpersExceptions.c +298 -0
  474. nuitka/build/static_src/HelpersFiles.c +353 -0
  475. nuitka/build/static_src/HelpersFilesystemPaths.c +1322 -0
  476. nuitka/build/static_src/HelpersFloats.c +92 -0
  477. nuitka/build/static_src/HelpersHeapStorage.c +68 -0
  478. nuitka/build/static_src/HelpersImport.c +506 -0
  479. nuitka/build/static_src/HelpersImportHard.c +526 -0
  480. nuitka/build/static_src/HelpersJitSources.c +48 -0
  481. nuitka/build/static_src/HelpersLists.c +899 -0
  482. nuitka/build/static_src/HelpersListsGenerated.c +564 -0
  483. nuitka/build/static_src/HelpersMappings.c +46 -0
  484. nuitka/build/static_src/HelpersMatching.c +192 -0
  485. nuitka/build/static_src/HelpersOperationBinaryAdd.c +6477 -0
  486. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +703 -0
  487. nuitka/build/static_src/HelpersOperationBinaryBitand.c +2738 -0
  488. nuitka/build/static_src/HelpersOperationBinaryBitor.c +2738 -0
  489. nuitka/build/static_src/HelpersOperationBinaryBitxor.c +2738 -0
  490. nuitka/build/static_src/HelpersOperationBinaryDivmod.c +2406 -0
  491. nuitka/build/static_src/HelpersOperationBinaryDivmodUtils.c +33 -0
  492. nuitka/build/static_src/HelpersOperationBinaryDualAdd.c +172 -0
  493. nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +2422 -0
  494. nuitka/build/static_src/HelpersOperationBinaryInplaceAdd.c +220 -0
  495. nuitka/build/static_src/HelpersOperationBinaryLshift.c +2846 -0
  496. nuitka/build/static_src/HelpersOperationBinaryMatmult.c +453 -0
  497. nuitka/build/static_src/HelpersOperationBinaryMod.c +6549 -0
  498. nuitka/build/static_src/HelpersOperationBinaryMult.c +6438 -0
  499. nuitka/build/static_src/HelpersOperationBinaryMultUtils.c +125 -0
  500. nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +2355 -0
  501. nuitka/build/static_src/HelpersOperationBinaryPow.c +2743 -0
  502. nuitka/build/static_src/HelpersOperationBinaryPowUtils.c +26 -0
  503. nuitka/build/static_src/HelpersOperationBinaryRshift.c +2706 -0
  504. nuitka/build/static_src/HelpersOperationBinarySub.c +2649 -0
  505. nuitka/build/static_src/HelpersOperationBinaryTruediv.c +2415 -0
  506. nuitka/build/static_src/HelpersOperationInplaceAdd.c +5211 -0
  507. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +144 -0
  508. nuitka/build/static_src/HelpersOperationInplaceBitand.c +1826 -0
  509. nuitka/build/static_src/HelpersOperationInplaceBitor.c +1826 -0
  510. nuitka/build/static_src/HelpersOperationInplaceBitxor.c +1826 -0
  511. nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +2605 -0
  512. nuitka/build/static_src/HelpersOperationInplaceLshift.c +1594 -0
  513. nuitka/build/static_src/HelpersOperationInplaceMatmult.c +603 -0
  514. nuitka/build/static_src/HelpersOperationInplaceMod.c +4762 -0
  515. nuitka/build/static_src/HelpersOperationInplaceMult.c +4689 -0
  516. nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +2553 -0
  517. nuitka/build/static_src/HelpersOperationInplacePow.c +2807 -0
  518. nuitka/build/static_src/HelpersOperationInplaceRshift.c +1534 -0
  519. nuitka/build/static_src/HelpersOperationInplaceSub.c +2894 -0
  520. nuitka/build/static_src/HelpersOperationInplaceTruediv.c +2612 -0
  521. nuitka/build/static_src/HelpersProfiling.c +104 -0
  522. nuitka/build/static_src/HelpersPythonPgo.c +113 -0
  523. nuitka/build/static_src/HelpersRaising.c +447 -0
  524. nuitka/build/static_src/HelpersSafeStrings.c +185 -0
  525. nuitka/build/static_src/HelpersSequences.c +134 -0
  526. nuitka/build/static_src/HelpersSlices.c +73 -0
  527. nuitka/build/static_src/HelpersStrings.c +998 -0
  528. nuitka/build/static_src/HelpersTuples.c +148 -0
  529. nuitka/build/static_src/HelpersTypes.c +329 -0
  530. nuitka/build/static_src/InspectPatcher.c +439 -0
  531. nuitka/build/static_src/MainProgram.c +2060 -0
  532. nuitka/build/static_src/MetaPathBasedLoader.c +2290 -0
  533. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +125 -0
  534. nuitka/build/static_src/MetaPathBasedLoaderResourceReader.c +158 -0
  535. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +785 -0
  536. nuitka/build/static_src/OnefileBootstrap.c +1580 -0
  537. nuitka/build/static_src/OnefileSplashScreen.cpp +275 -0
  538. nuitka/code_generation/AsyncgenCodes.py +186 -0
  539. nuitka/code_generation/AttributeCodes.py +357 -0
  540. nuitka/code_generation/BinaryOperationHelperDefinitions.py +720 -0
  541. nuitka/code_generation/BranchCodes.py +67 -0
  542. nuitka/code_generation/BuiltinCodes.py +529 -0
  543. nuitka/code_generation/CallCodes.py +1186 -0
  544. nuitka/code_generation/ClassCodes.py +156 -0
  545. nuitka/code_generation/CodeGeneration.py +1078 -0
  546. nuitka/code_generation/CodeHelperSelection.py +81 -0
  547. nuitka/code_generation/CodeHelpers.py +455 -0
  548. nuitka/code_generation/CodeObjectCodes.py +165 -0
  549. nuitka/code_generation/ComparisonCodes.py +569 -0
  550. nuitka/code_generation/ComparisonHelperDefinitions.py +146 -0
  551. nuitka/code_generation/ConditionalCodes.py +236 -0
  552. nuitka/code_generation/ConstantCodes.py +243 -0
  553. nuitka/code_generation/Contexts.py +1248 -0
  554. nuitka/code_generation/CoroutineCodes.py +253 -0
  555. nuitka/code_generation/CtypesCodes.py +46 -0
  556. nuitka/code_generation/DictCodes.py +918 -0
  557. nuitka/code_generation/Emission.py +75 -0
  558. nuitka/code_generation/ErrorCodes.py +281 -0
  559. nuitka/code_generation/EvalCodes.py +444 -0
  560. nuitka/code_generation/ExceptionCodes.py +337 -0
  561. nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +227 -0
  562. nuitka/code_generation/ExpressionCodes.py +61 -0
  563. nuitka/code_generation/FrameCodes.py +518 -0
  564. nuitka/code_generation/FunctionCodes.py +858 -0
  565. nuitka/code_generation/GeneratorCodes.py +218 -0
  566. nuitka/code_generation/GlobalConstants.py +249 -0
  567. nuitka/code_generation/GlobalsLocalsCodes.py +211 -0
  568. nuitka/code_generation/IdCodes.py +53 -0
  569. nuitka/code_generation/ImportCodes.py +468 -0
  570. nuitka/code_generation/Indentation.py +45 -0
  571. nuitka/code_generation/IndexCodes.py +50 -0
  572. nuitka/code_generation/InjectCCodes.py +28 -0
  573. nuitka/code_generation/IntegerCodes.py +110 -0
  574. nuitka/code_generation/IteratorCodes.py +378 -0
  575. nuitka/code_generation/JitCodes.py +44 -0
  576. nuitka/code_generation/LabelCodes.py +68 -0
  577. nuitka/code_generation/LineNumberCodes.py +91 -0
  578. nuitka/code_generation/ListCodes.py +502 -0
  579. nuitka/code_generation/LoaderCodes.py +193 -0
  580. nuitka/code_generation/LocalsDictCodes.py +359 -0
  581. nuitka/code_generation/LoopCodes.py +88 -0
  582. nuitka/code_generation/MatchCodes.py +67 -0
  583. nuitka/code_generation/ModuleCodes.py +247 -0
  584. nuitka/code_generation/Namify.py +260 -0
  585. nuitka/code_generation/NetworkxCodes.py +51 -0
  586. nuitka/code_generation/OperationCodes.py +398 -0
  587. nuitka/code_generation/PackageResourceCodes.py +986 -0
  588. nuitka/code_generation/PrintCodes.py +93 -0
  589. nuitka/code_generation/PythonAPICodes.py +215 -0
  590. nuitka/code_generation/RaisingCodes.py +481 -0
  591. nuitka/code_generation/Reports.py +115 -0
  592. nuitka/code_generation/ReturnCodes.py +143 -0
  593. nuitka/code_generation/SetCodes.py +196 -0
  594. nuitka/code_generation/SliceCodes.py +465 -0
  595. nuitka/code_generation/StringCodes.py +303 -0
  596. nuitka/code_generation/SubscriptCodes.py +263 -0
  597. nuitka/code_generation/TensorflowCodes.py +54 -0
  598. nuitka/code_generation/TryCodes.py +326 -0
  599. nuitka/code_generation/TupleCodes.py +115 -0
  600. nuitka/code_generation/TypeAliasCodes.py +120 -0
  601. nuitka/code_generation/VariableCodes.py +519 -0
  602. nuitka/code_generation/VariableDeclarations.py +279 -0
  603. nuitka/code_generation/YieldCodes.py +253 -0
  604. nuitka/code_generation/__init__.py +19 -0
  605. nuitka/code_generation/c_types/CTypeBases.py +177 -0
  606. nuitka/code_generation/c_types/CTypeBooleans.py +104 -0
  607. nuitka/code_generation/c_types/CTypeCFloats.py +57 -0
  608. nuitka/code_generation/c_types/CTypeCLongs.py +45 -0
  609. nuitka/code_generation/c_types/CTypeModuleDictVariables.py +109 -0
  610. nuitka/code_generation/c_types/CTypeNuitkaBooleans.py +150 -0
  611. nuitka/code_generation/c_types/CTypeNuitkaInts.py +200 -0
  612. nuitka/code_generation/c_types/CTypeNuitkaVoids.py +107 -0
  613. nuitka/code_generation/c_types/CTypePyObjectPointers.py +572 -0
  614. nuitka/code_generation/c_types/CTypeVoids.py +92 -0
  615. nuitka/code_generation/c_types/__init__.py +19 -0
  616. nuitka/code_generation/templates/CodeTemplatesAsyncgens.py +106 -0
  617. nuitka/code_generation/templates/CodeTemplatesConstants.py +296 -0
  618. nuitka/code_generation/templates/CodeTemplatesCoroutines.py +109 -0
  619. nuitka/code_generation/templates/CodeTemplatesExceptions.py +84 -0
  620. nuitka/code_generation/templates/CodeTemplatesFrames.py +235 -0
  621. nuitka/code_generation/templates/CodeTemplatesFunction.py +117 -0
  622. nuitka/code_generation/templates/CodeTemplatesGeneratorFunction.py +130 -0
  623. nuitka/code_generation/templates/CodeTemplatesIterators.py +40 -0
  624. nuitka/code_generation/templates/CodeTemplatesLoader.py +180 -0
  625. nuitka/code_generation/templates/CodeTemplatesModules.py +710 -0
  626. nuitka/code_generation/templates/CodeTemplatesVariables.py +388 -0
  627. nuitka/code_generation/templates/TemplateDebugWrapper.py +80 -0
  628. nuitka/code_generation/templates/__init__.py +19 -0
  629. nuitka/code_generation/templates_c/CodeTemplateCallsMethodPositional.c.j2 +321 -0
  630. nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +143 -0
  631. nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +677 -0
  632. nuitka/code_generation/templates_c/CodeTemplateCallsPositionalMethodDescr.c.j2 +165 -0
  633. nuitka/code_generation/templates_c/CodeTemplateMakeListHinted.c.j2 +38 -0
  634. nuitka/code_generation/templates_c/CodeTemplateMakeListSmall.c.j2 +41 -0
  635. nuitka/code_generation/templates_c/HelperBuiltinMethodOperation.c.j2 +53 -0
  636. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +364 -0
  637. nuitka/code_generation/templates_c/HelperImportHard.c.j2 +37 -0
  638. nuitka/code_generation/templates_c/HelperLongTools.c.j2 +53 -0
  639. nuitka/code_generation/templates_c/HelperObjectTools.c.j2 +20 -0
  640. nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +148 -0
  641. nuitka/code_generation/templates_c/HelperOperationBinaryDual.c.j2 +115 -0
  642. nuitka/code_generation/templates_c/HelperOperationComparison.c.j2 +352 -0
  643. nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +115 -0
  644. nuitka/code_generation/templates_c/HelperOperationComparisonDual.c.j2 +86 -0
  645. nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +31 -0
  646. nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +32 -0
  647. nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +112 -0
  648. nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +157 -0
  649. nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +115 -0
  650. nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +99 -0
  651. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +115 -0
  652. nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +281 -0
  653. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +420 -0
  654. nuitka/code_generation/templates_c/HelperSlotsBytes.c.j2 +51 -0
  655. nuitka/code_generation/templates_c/HelperSlotsCommon.c.j2 +71 -0
  656. nuitka/code_generation/templates_c/HelperSlotsFloat.c.j2 +327 -0
  657. nuitka/code_generation/templates_c/HelperSlotsInt.c.j2 +411 -0
  658. nuitka/code_generation/templates_c/HelperSlotsList.c.j2 +59 -0
  659. nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +229 -0
  660. nuitka/code_generation/templates_c/HelperSlotsSet.c.j2 +47 -0
  661. nuitka/code_generation/templates_c/HelperSlotsStr.c.j2 +55 -0
  662. nuitka/code_generation/templates_c/HelperSlotsTuple.c.j2 +58 -0
  663. nuitka/code_generation/templates_c/HelperSlotsUnicode.c.j2 +62 -0
  664. nuitka/containers/Namedtuples.py +51 -0
  665. nuitka/containers/OrderedDicts.py +191 -0
  666. nuitka/containers/OrderedSets.py +123 -0
  667. nuitka/containers/OrderedSetsFallback.py +139 -0
  668. nuitka/containers/__init__.py +19 -0
  669. nuitka/distutils/Build.py +76 -0
  670. nuitka/distutils/DistutilCommands.py +438 -0
  671. nuitka/distutils/__init__.py +19 -0
  672. nuitka/finalizations/Finalization.py +35 -0
  673. nuitka/finalizations/FinalizeMarkups.py +136 -0
  674. nuitka/finalizations/__init__.py +19 -0
  675. nuitka/freezer/DependsExe.py +257 -0
  676. nuitka/freezer/DllDependenciesCommon.py +97 -0
  677. nuitka/freezer/DllDependenciesMacOS.py +444 -0
  678. nuitka/freezer/DllDependenciesPosix.py +242 -0
  679. nuitka/freezer/DllDependenciesWin32.py +315 -0
  680. nuitka/freezer/ImportDetection.py +359 -0
  681. nuitka/freezer/IncludedDataFiles.py +689 -0
  682. nuitka/freezer/IncludedEntryPoints.py +376 -0
  683. nuitka/freezer/Onefile.py +296 -0
  684. nuitka/freezer/Standalone.py +520 -0
  685. nuitka/freezer/__init__.py +19 -0
  686. nuitka/importing/IgnoreListing.py +449 -0
  687. nuitka/importing/ImportCache.py +95 -0
  688. nuitka/importing/ImportResolving.py +186 -0
  689. nuitka/importing/Importing.py +1200 -0
  690. nuitka/importing/PreloadedPackages.py +164 -0
  691. nuitka/importing/Recursion.py +611 -0
  692. nuitka/importing/StandardLibrary.py +429 -0
  693. nuitka/importing/__init__.py +19 -0
  694. nuitka/nodes/AsyncgenNodes.py +107 -0
  695. nuitka/nodes/AttributeLookupNodes.py +124 -0
  696. nuitka/nodes/AttributeNodes.py +386 -0
  697. nuitka/nodes/AttributeNodesGenerated.py +10734 -0
  698. nuitka/nodes/BuiltinAllNodes.py +115 -0
  699. nuitka/nodes/BuiltinAnyNodes.py +124 -0
  700. nuitka/nodes/BuiltinComplexNodes.py +83 -0
  701. nuitka/nodes/BuiltinDecodingNodes.py +52 -0
  702. nuitka/nodes/BuiltinDecoratorNodes.py +85 -0
  703. nuitka/nodes/BuiltinDictNodes.py +140 -0
  704. nuitka/nodes/BuiltinFormatNodes.py +159 -0
  705. nuitka/nodes/BuiltinHashNodes.py +63 -0
  706. nuitka/nodes/BuiltinInputNodes.py +39 -0
  707. nuitka/nodes/BuiltinIntegerNodes.py +170 -0
  708. nuitka/nodes/BuiltinIteratorNodes.py +391 -0
  709. nuitka/nodes/BuiltinLenNodes.py +61 -0
  710. nuitka/nodes/BuiltinNextNodes.py +111 -0
  711. nuitka/nodes/BuiltinOpenNodes.py +148 -0
  712. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +7367 -0
  713. nuitka/nodes/BuiltinRangeNodes.py +690 -0
  714. nuitka/nodes/BuiltinRefNodes.py +314 -0
  715. nuitka/nodes/BuiltinSumNodes.py +104 -0
  716. nuitka/nodes/BuiltinTypeNodes.py +454 -0
  717. nuitka/nodes/BuiltinVarsNodes.py +44 -0
  718. nuitka/nodes/BytesNodes.py +829 -0
  719. nuitka/nodes/CallNodes.py +217 -0
  720. nuitka/nodes/Checkers.py +55 -0
  721. nuitka/nodes/ChildrenHavingMixins.py +21576 -0
  722. nuitka/nodes/ClassNodes.py +286 -0
  723. nuitka/nodes/CodeObjectSpecs.py +230 -0
  724. nuitka/nodes/ComparisonNodes.py +687 -0
  725. nuitka/nodes/ConditionalNodes.py +884 -0
  726. nuitka/nodes/ConstantRefNodes.py +1717 -0
  727. nuitka/nodes/ContainerMakingNodes.py +408 -0
  728. nuitka/nodes/ContainerOperationNodes.py +87 -0
  729. nuitka/nodes/CoroutineNodes.py +144 -0
  730. nuitka/nodes/CtypesNodes.py +51 -0
  731. nuitka/nodes/DictionaryNodes.py +1513 -0
  732. nuitka/nodes/ExceptionNodes.py +393 -0
  733. nuitka/nodes/ExecEvalNodes.py +229 -0
  734. nuitka/nodes/ExpressionBases.py +1301 -0
  735. nuitka/nodes/ExpressionBasesGenerated.py +2103 -0
  736. nuitka/nodes/ExpressionShapeMixins.py +886 -0
  737. nuitka/nodes/FrameNodes.py +413 -0
  738. nuitka/nodes/FunctionAttributeNodes.py +102 -0
  739. nuitka/nodes/FunctionNodes.py +1303 -0
  740. nuitka/nodes/FutureSpecs.py +224 -0
  741. nuitka/nodes/GeneratorNodes.py +201 -0
  742. nuitka/nodes/GlobalsLocalsNodes.py +209 -0
  743. nuitka/nodes/HardImportNodesGenerated.py +3599 -0
  744. nuitka/nodes/ImportHardNodes.py +185 -0
  745. nuitka/nodes/ImportNodes.py +1366 -0
  746. nuitka/nodes/IndicatorMixins.py +79 -0
  747. nuitka/nodes/InjectCNodes.py +51 -0
  748. nuitka/nodes/IterationHandles.py +407 -0
  749. nuitka/nodes/KeyValuePairNodes.py +378 -0
  750. nuitka/nodes/ListOperationNodes.py +525 -0
  751. nuitka/nodes/LocalsDictNodes.py +717 -0
  752. nuitka/nodes/LocalsScopes.py +505 -0
  753. nuitka/nodes/LoopNodes.py +445 -0
  754. nuitka/nodes/MatchNodes.py +60 -0
  755. nuitka/nodes/ModuleAttributeNodes.py +180 -0
  756. nuitka/nodes/ModuleNodes.py +1137 -0
  757. nuitka/nodes/NetworkxNodes.py +45 -0
  758. nuitka/nodes/NodeBases.py +890 -0
  759. nuitka/nodes/NodeMakingHelpers.py +481 -0
  760. nuitka/nodes/NodeMetaClasses.py +172 -0
  761. nuitka/nodes/OperatorNodes.py +944 -0
  762. nuitka/nodes/OperatorNodesUnary.py +403 -0
  763. nuitka/nodes/OsSysNodes.py +215 -0
  764. nuitka/nodes/OutlineNodes.py +372 -0
  765. nuitka/nodes/PackageMetadataNodes.py +982 -0
  766. nuitka/nodes/PackageResourceNodes.py +424 -0
  767. nuitka/nodes/PrintNodes.py +105 -0
  768. nuitka/nodes/ReturnNodes.py +255 -0
  769. nuitka/nodes/SideEffectNodes.py +139 -0
  770. nuitka/nodes/SliceNodes.py +386 -0
  771. nuitka/nodes/StatementBasesGenerated.py +3419 -0
  772. nuitka/nodes/StatementNodes.py +316 -0
  773. nuitka/nodes/StrNodes.py +919 -0
  774. nuitka/nodes/StringConcatenationNodes.py +103 -0
  775. nuitka/nodes/SubscriptNodes.py +245 -0
  776. nuitka/nodes/TensorflowNodes.py +38 -0
  777. nuitka/nodes/TryNodes.py +519 -0
  778. nuitka/nodes/TypeMatchNodes.py +65 -0
  779. nuitka/nodes/TypeNodes.py +390 -0
  780. nuitka/nodes/VariableAssignNodes.py +1177 -0
  781. nuitka/nodes/VariableDelNodes.py +320 -0
  782. nuitka/nodes/VariableNameNodes.py +153 -0
  783. nuitka/nodes/VariableRefNodes.py +895 -0
  784. nuitka/nodes/VariableReleaseNodes.py +153 -0
  785. nuitka/nodes/YieldNodes.py +121 -0
  786. nuitka/nodes/__init__.py +19 -0
  787. nuitka/nodes/shapes/BuiltinTypeShapes.py +4290 -0
  788. nuitka/nodes/shapes/ControlFlowDescriptions.py +199 -0
  789. nuitka/nodes/shapes/IteratorShapes.py +71 -0
  790. nuitka/nodes/shapes/ShapeMixins.py +255 -0
  791. nuitka/nodes/shapes/StandardShapes.py +1384 -0
  792. nuitka/nodes/shapes/__init__.py +19 -0
  793. nuitka/optimizations/BytecodeDemotion.py +105 -0
  794. nuitka/optimizations/FunctionInlining.py +110 -0
  795. nuitka/optimizations/Graphs.py +70 -0
  796. nuitka/optimizations/Optimization.py +363 -0
  797. nuitka/optimizations/OptimizeBuiltinCalls.py +1582 -0
  798. nuitka/optimizations/Tags.py +76 -0
  799. nuitka/optimizations/TraceCollections.py +1257 -0
  800. nuitka/optimizations/ValueTraces.py +980 -0
  801. nuitka/optimizations/__init__.py +19 -0
  802. nuitka/pgo/PGO.py +160 -0
  803. nuitka/pgo/__init__.py +19 -0
  804. nuitka/plugins/PluginBase.py +1924 -0
  805. nuitka/plugins/Plugins.py +2007 -0
  806. nuitka/plugins/YamlPluginBase.py +121 -0
  807. nuitka/plugins/__init__.py +19 -0
  808. nuitka/plugins/standard/AntiBloatPlugin.py +1024 -0
  809. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +95 -0
  810. nuitka/plugins/standard/DataFilesPlugin.py +311 -0
  811. nuitka/plugins/standard/DelvewheelPlugin.py +150 -0
  812. nuitka/plugins/standard/DillPlugin/DillPlugin.c +37 -0
  813. nuitka/plugins/standard/DillPlugin/cloudpickle-postLoad.py +67 -0
  814. nuitka/plugins/standard/DillPlugin/dill-postLoad.py +223 -0
  815. nuitka/plugins/standard/DillPlugin.py +137 -0
  816. nuitka/plugins/standard/DllFilesPlugin.py +527 -0
  817. nuitka/plugins/standard/EnumPlugin.py +64 -0
  818. nuitka/plugins/standard/EventletPlugin.py +57 -0
  819. nuitka/plugins/standard/GeventPlugin.py +64 -0
  820. nuitka/plugins/standard/GiPlugin.py +118 -0
  821. nuitka/plugins/standard/GlfwPlugin.py +138 -0
  822. nuitka/plugins/standard/ImplicitImports.py +845 -0
  823. nuitka/plugins/standard/KivyPlugin.py +141 -0
  824. nuitka/plugins/standard/MatplotlibPlugin.py +256 -0
  825. nuitka/plugins/standard/MultiprocessingPlugin.py +199 -0
  826. nuitka/plugins/standard/NumpyPlugin.py +35 -0
  827. nuitka/plugins/standard/OptionsNannyPlugin.py +158 -0
  828. nuitka/plugins/standard/PbrPlugin.py +62 -0
  829. nuitka/plugins/standard/PkgResourcesPlugin.py +162 -0
  830. nuitka/plugins/standard/PlaywrightPlugin.py +179 -0
  831. nuitka/plugins/standard/PmwPlugin.py +248 -0
  832. nuitka/plugins/standard/PySidePyQtPlugin.py +1666 -0
  833. nuitka/plugins/standard/PywebViewPlugin.py +81 -0
  834. nuitka/plugins/standard/SpacyPlugin.py +137 -0
  835. nuitka/plugins/standard/TensorflowPlugin.py +35 -0
  836. nuitka/plugins/standard/TkinterPlugin.py +416 -0
  837. nuitka/plugins/standard/TorchPlugin.py +35 -0
  838. nuitka/plugins/standard/TransformersPlugin.py +121 -0
  839. nuitka/plugins/standard/TrioPlugin.py +33 -0
  840. nuitka/plugins/standard/UpxPlugin.py +174 -0
  841. nuitka/plugins/standard/__init__.py +19 -0
  842. nuitka/plugins/standard/standard.nuitka-package.config.yml +9313 -0
  843. nuitka/plugins/standard/stdlib2.nuitka-package.config.yml +78 -0
  844. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +468 -0
  845. nuitka/reports/CompilationReportReader.py +83 -0
  846. nuitka/reports/LicenseReport.rst.j2 +41 -0
  847. nuitka/reports/Reports.py +961 -0
  848. nuitka/reports/__init__.py +19 -0
  849. nuitka/specs/BuiltinBytesOperationSpecs.py +180 -0
  850. nuitka/specs/BuiltinDictOperationSpecs.py +82 -0
  851. nuitka/specs/BuiltinListOperationSpecs.py +80 -0
  852. nuitka/specs/BuiltinParameterSpecs.py +831 -0
  853. nuitka/specs/BuiltinStrOperationSpecs.py +181 -0
  854. nuitka/specs/BuiltinTypeOperationSpecs.py +34 -0
  855. nuitka/specs/BuiltinUnicodeOperationSpecs.py +123 -0
  856. nuitka/specs/HardImportSpecs.py +236 -0
  857. nuitka/specs/ParameterSpecs.py +630 -0
  858. nuitka/specs/__init__.py +19 -0
  859. nuitka/tools/Basics.py +55 -0
  860. nuitka/tools/__init__.py +19 -0
  861. nuitka/tools/commercial/__init__.py +21 -0
  862. nuitka/tools/data_composer/DataComposer.py +593 -0
  863. nuitka/tools/data_composer/__init__.py +19 -0
  864. nuitka/tools/data_composer/__main__.py +41 -0
  865. nuitka/tools/environments/CreateEnvironment.py +69 -0
  866. nuitka/tools/environments/Virtualenv.py +158 -0
  867. nuitka/tools/environments/__init__.py +19 -0
  868. nuitka/tools/general/__init__.py +19 -0
  869. nuitka/tools/general/dll_report/__init__.py +19 -0
  870. nuitka/tools/general/dll_report/__main__.py +83 -0
  871. nuitka/tools/general/find_module/FindModuleCode.py +127 -0
  872. nuitka/tools/general/find_module/__init__.py +19 -0
  873. nuitka/tools/general/generate_header/GenerateHeader.py +73 -0
  874. nuitka/tools/general/generate_header/__init__.py +19 -0
  875. nuitka/tools/onefile_compressor/OnefileCompressor.py +390 -0
  876. nuitka/tools/onefile_compressor/__init__.py +19 -0
  877. nuitka/tools/onefile_compressor/__main__.py +41 -0
  878. nuitka/tools/podman/Podman.py +55 -0
  879. nuitka/tools/podman/__init__.py +19 -0
  880. nuitka/tools/podman/__main__.py +425 -0
  881. nuitka/tools/profiler/__init__.py +19 -0
  882. nuitka/tools/profiler/__main__.py +93 -0
  883. nuitka/tools/scanning/DisplayDistributions.py +39 -0
  884. nuitka/tools/scanning/DisplayPackageDLLs.py +151 -0
  885. nuitka/tools/scanning/DisplayPackageData.py +73 -0
  886. nuitka/tools/scanning/__init__.py +19 -0
  887. nuitka/tools/specialize/CTypeDescriptions.py +1928 -0
  888. nuitka/tools/specialize/Common.py +380 -0
  889. nuitka/tools/specialize/SpecializeC.py +1483 -0
  890. nuitka/tools/specialize/SpecializePython.py +1151 -0
  891. nuitka/tools/specialize/__init__.py +19 -0
  892. nuitka/tools/testing/Common.py +2007 -0
  893. nuitka/tools/testing/Constructs.py +53 -0
  894. nuitka/tools/testing/DocTests.py +156 -0
  895. nuitka/tools/testing/OutputComparison.py +313 -0
  896. nuitka/tools/testing/Pythons.py +34 -0
  897. nuitka/tools/testing/RuntimeTracing.py +260 -0
  898. nuitka/tools/testing/SearchModes.py +208 -0
  899. nuitka/tools/testing/Valgrind.py +103 -0
  900. nuitka/tools/testing/__init__.py +19 -0
  901. nuitka/tools/testing/check_reference_counts/__init__.py +19 -0
  902. nuitka/tools/testing/check_reference_counts/__main__.py +107 -0
  903. nuitka/tools/testing/compare_with_cpython/__init__.py +19 -0
  904. nuitka/tools/testing/compare_with_cpython/__main__.py +942 -0
  905. nuitka/tools/testing/find_sxs_modules/__init__.py +19 -0
  906. nuitka/tools/testing/find_sxs_modules/__main__.py +73 -0
  907. nuitka/tools/testing/measure_construct_performance/__init__.py +19 -0
  908. nuitka/tools/testing/measure_construct_performance/__main__.py +288 -0
  909. nuitka/tools/testing/run_nuitka_tests/__init__.py +19 -0
  910. nuitka/tools/testing/run_nuitka_tests/__main__.py +1091 -0
  911. nuitka/tools/watch/AutoStage.py +145 -0
  912. nuitka/tools/watch/Common.py +55 -0
  913. nuitka/tools/watch/Conda.py +125 -0
  914. nuitka/tools/watch/GitHub.py +113 -0
  915. nuitka/tools/watch/Pacman.py +73 -0
  916. nuitka/tools/watch/Pipenv.py +145 -0
  917. nuitka/tools/watch/__init__.py +19 -0
  918. nuitka/tools/watch/__main__.py +615 -0
  919. nuitka/tree/Building.py +1459 -0
  920. nuitka/tree/ComplexCallHelperFunctions.py +2150 -0
  921. nuitka/tree/Extractions.py +48 -0
  922. nuitka/tree/FutureSpecState.py +71 -0
  923. nuitka/tree/InternalModule.py +96 -0
  924. nuitka/tree/Operations.py +45 -0
  925. nuitka/tree/ReformulationAssertStatements.py +97 -0
  926. nuitka/tree/ReformulationAssignmentStatements.py +1260 -0
  927. nuitka/tree/ReformulationBooleanExpressions.py +97 -0
  928. nuitka/tree/ReformulationCallExpressions.py +314 -0
  929. nuitka/tree/ReformulationClasses.py +407 -0
  930. nuitka/tree/ReformulationClasses3.py +1149 -0
  931. nuitka/tree/ReformulationComparisonExpressions.py +174 -0
  932. nuitka/tree/ReformulationContractionExpressions.py +676 -0
  933. nuitka/tree/ReformulationDictionaryCreation.py +304 -0
  934. nuitka/tree/ReformulationExecStatements.py +386 -0
  935. nuitka/tree/ReformulationForLoopStatements.py +215 -0
  936. nuitka/tree/ReformulationFunctionStatements.py +931 -0
  937. nuitka/tree/ReformulationImportStatements.py +333 -0
  938. nuitka/tree/ReformulationLambdaExpressions.py +185 -0
  939. nuitka/tree/ReformulationMatchStatements.py +797 -0
  940. nuitka/tree/ReformulationMultidist.py +80 -0
  941. nuitka/tree/ReformulationNamespacePackages.py +239 -0
  942. nuitka/tree/ReformulationPrintStatements.py +127 -0
  943. nuitka/tree/ReformulationSequenceCreation.py +438 -0
  944. nuitka/tree/ReformulationSubscriptExpressions.py +123 -0
  945. nuitka/tree/ReformulationTryExceptStatements.py +418 -0
  946. nuitka/tree/ReformulationTryFinallyStatements.py +239 -0
  947. nuitka/tree/ReformulationWhileLoopStatements.py +160 -0
  948. nuitka/tree/ReformulationWithStatements.py +382 -0
  949. nuitka/tree/ReformulationYieldExpressions.py +133 -0
  950. nuitka/tree/SourceHandling.py +476 -0
  951. nuitka/tree/SyntaxErrors.py +143 -0
  952. nuitka/tree/TreeHelpers.py +720 -0
  953. nuitka/tree/VariableClosure.py +483 -0
  954. nuitka/tree/__init__.py +19 -0
  955. nuitka/utils/AppDirs.py +104 -0
  956. nuitka/utils/CStrings.py +208 -0
  957. nuitka/utils/CommandLineOptions.py +207 -0
  958. nuitka/utils/Distributions.py +728 -0
  959. nuitka/utils/Download.py +217 -0
  960. nuitka/utils/Execution.py +517 -0
  961. nuitka/utils/FileOperations.py +1587 -0
  962. nuitka/utils/Hashing.py +137 -0
  963. nuitka/utils/Images.py +79 -0
  964. nuitka/utils/Importing.py +335 -0
  965. nuitka/utils/InlineCopies.py +52 -0
  966. nuitka/utils/InstalledPythons.py +254 -0
  967. nuitka/utils/InstanceCounters.py +86 -0
  968. nuitka/utils/Jinja2.py +158 -0
  969. nuitka/utils/Json.py +40 -0
  970. nuitka/utils/MacOSApp.py +134 -0
  971. nuitka/utils/MemoryUsage.py +165 -0
  972. nuitka/utils/ModuleNames.py +317 -0
  973. nuitka/utils/PackageResources.py +44 -0
  974. nuitka/utils/ReExecute.py +152 -0
  975. nuitka/utils/Rest.py +60 -0
  976. nuitka/utils/SharedLibraries.py +1014 -0
  977. nuitka/utils/Shebang.py +113 -0
  978. nuitka/utils/Signing.py +144 -0
  979. nuitka/utils/SlotMetaClasses.py +57 -0
  980. nuitka/utils/StaticLibraries.py +260 -0
  981. nuitka/utils/ThreadedExecutor.py +87 -0
  982. nuitka/utils/Timing.py +102 -0
  983. nuitka/utils/Utils.py +483 -0
  984. nuitka/utils/WindowsFileUsage.py +337 -0
  985. nuitka/utils/WindowsResources.py +652 -0
  986. nuitka/utils/Yaml.py +247 -0
  987. nuitka/utils/__init__.py +19 -0
  988. nuitka_winsvc-2.7.7.data/scripts/nuitka-run.cmd +24 -0
  989. nuitka_winsvc-2.7.7.data/scripts/nuitka.cmd +30 -0
  990. nuitka_winsvc-2.7.7.dist-info/METADATA +115 -0
  991. nuitka_winsvc-2.7.7.dist-info/RECORD +995 -0
  992. nuitka_winsvc-2.7.7.dist-info/WHEEL +5 -0
  993. nuitka_winsvc-2.7.7.dist-info/entry_points.txt +7 -0
  994. nuitka_winsvc-2.7.7.dist-info/licenses/LICENSE.txt +202 -0
  995. nuitka_winsvc-2.7.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,3320 @@
1
+ // Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
+
3
+ // Compiled function type.
4
+
5
+ // The backbone of the integration into CPython. Try to behave as well as normal
6
+ // functions and built-in functions, or even better.
7
+
8
+ #include "nuitka/prelude.h"
9
+
10
+ #include "nuitka/compiled_method.h"
11
+
12
+ #include "nuitka/freelists.h"
13
+
14
+ // Needed for offsetof
15
+ #include <stddef.h>
16
+ #include <structmember.h>
17
+
18
+ // spell-checker: ignore qualname,kwdefaults,getset,weakrefs,vectorcall,nargsf,m_varnames
19
+
20
+ #if _DEBUG_REFCOUNTS
21
+ int count_active_Nuitka_Function_Type;
22
+ int count_allocated_Nuitka_Function_Type;
23
+ int count_released_Nuitka_Function_Type;
24
+ #endif
25
+
26
+ // tp_descr_get slot, bind a function to an object.
27
+ static PyObject *Nuitka_Function_descr_get(PyObject *function, PyObject *object, PyObject *class_object) {
28
+ assert(Nuitka_Function_Check(function));
29
+ CHECK_OBJECT((PyObject *)function);
30
+ assert(_PyObject_GC_IS_TRACKED(function));
31
+
32
+ #if PYTHON_VERSION >= 0x300
33
+ if (object == NULL || object == Py_None) {
34
+ Py_INCREF(function);
35
+ return function;
36
+ }
37
+ #endif
38
+
39
+ return Nuitka_Method_New((struct Nuitka_FunctionObject *)function, object == Py_None ? NULL : object, class_object);
40
+ }
41
+
42
+ // tp_repr slot, decide how compiled function shall be output to "repr" built-in
43
+ static PyObject *Nuitka_Function_tp_repr(struct Nuitka_FunctionObject *function) {
44
+ CHECK_OBJECT((PyObject *)function);
45
+ assert(Nuitka_Function_Check((PyObject *)function));
46
+ assert(_PyObject_GC_IS_TRACKED(function));
47
+
48
+ #if PYTHON_VERSION < 0x300
49
+ return Nuitka_String_FromFormat("<compiled_function %s at %p>", Nuitka_String_AsString(function->m_name), function);
50
+ #else
51
+ return Nuitka_String_FromFormat("<compiled_function %U at %p>", function->m_qualname, function);
52
+ #endif
53
+ }
54
+
55
+ static long Nuitka_Function_tp_traverse(struct Nuitka_FunctionObject *function, visitproc visit, void *arg) {
56
+ CHECK_OBJECT((PyObject *)function);
57
+ assert(Nuitka_Function_Check((PyObject *)function));
58
+ assert(_PyObject_GC_IS_TRACKED(function));
59
+
60
+ // TODO: Identify the impact of not visiting other owned objects. It appears
61
+ // to be mostly harmless, as these are strings.
62
+ Py_VISIT(function->m_dict);
63
+
64
+ for (Py_ssize_t i = 0; i < function->m_closure_given; i++) {
65
+ Py_VISIT(function->m_closure[i]);
66
+ }
67
+
68
+ return 0;
69
+ }
70
+
71
+ static long Nuitka_Function_tp_hash(struct Nuitka_FunctionObject *function) {
72
+ CHECK_OBJECT((PyObject *)function);
73
+ assert(Nuitka_Function_Check((PyObject *)function));
74
+ assert(_PyObject_GC_IS_TRACKED(function));
75
+
76
+ return function->m_counter;
77
+ }
78
+
79
+ static PyObject *Nuitka_Function_get_name(PyObject *self, void *data) {
80
+ CHECK_OBJECT(self);
81
+ assert(Nuitka_Function_Check(self));
82
+ assert(_PyObject_GC_IS_TRACKED(self));
83
+
84
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
85
+ PyObject *result = function->m_name;
86
+ CHECK_OBJECT(result);
87
+
88
+ Py_INCREF(result);
89
+ return result;
90
+ }
91
+
92
+ static int Nuitka_Function_set_name(PyObject *self, PyObject *value, void *data) {
93
+ CHECK_OBJECT(self);
94
+ assert(Nuitka_Function_Check(self));
95
+ assert(_PyObject_GC_IS_TRACKED(self));
96
+ CHECK_OBJECT_X(value);
97
+
98
+ #if PYTHON_VERSION < 0x300
99
+ if (unlikely(value == NULL || PyString_Check(value) == 0))
100
+ #else
101
+ if (unlikely(value == NULL || PyUnicode_Check(value) == 0))
102
+ #endif
103
+ {
104
+ PyThreadState *tstate = PyThreadState_GET();
105
+
106
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "__name__ must be set to a string object");
107
+ return -1;
108
+ }
109
+
110
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
111
+ PyObject *old = function->m_name;
112
+ CHECK_OBJECT(old);
113
+
114
+ Py_INCREF(value);
115
+ function->m_name = value;
116
+ Py_DECREF(old);
117
+
118
+ return 0;
119
+ }
120
+
121
+ #if PYTHON_VERSION >= 0x300
122
+ static PyObject *Nuitka_Function_get_qualname(PyObject *self, void *data) {
123
+ CHECK_OBJECT(self);
124
+ assert(Nuitka_Function_Check(self));
125
+ assert(_PyObject_GC_IS_TRACKED(self));
126
+
127
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
128
+ PyObject *result = function->m_qualname;
129
+ CHECK_OBJECT(result);
130
+
131
+ Py_INCREF(result);
132
+ return result;
133
+ }
134
+
135
+ static int Nuitka_Function_set_qualname(PyObject *self, PyObject *value, void *data) {
136
+ CHECK_OBJECT(self);
137
+ assert(Nuitka_Function_Check(self));
138
+ assert(_PyObject_GC_IS_TRACKED(self));
139
+ CHECK_OBJECT_X(value);
140
+
141
+ if (unlikely(value == NULL || PyUnicode_Check(value) == 0)) {
142
+ PyThreadState *tstate = PyThreadState_GET();
143
+
144
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "__qualname__ must be set to a string object");
145
+ return -1;
146
+ }
147
+
148
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
149
+ PyObject *old = function->m_qualname;
150
+ Py_INCREF(value);
151
+ function->m_qualname = value;
152
+ Py_DECREF(old);
153
+
154
+ return 0;
155
+ }
156
+ #endif
157
+
158
+ static PyObject *Nuitka_Function_get_doc(PyObject *self, void *data) {
159
+ CHECK_OBJECT(self);
160
+ assert(Nuitka_Function_Check(self));
161
+ assert(_PyObject_GC_IS_TRACKED(self));
162
+
163
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
164
+ PyObject *result = function->m_doc;
165
+
166
+ if (result == NULL) {
167
+ result = Py_None;
168
+ }
169
+
170
+ CHECK_OBJECT(result);
171
+
172
+ Py_INCREF(result);
173
+ return result;
174
+ }
175
+
176
+ static int Nuitka_Function_set_doc(PyObject *self, PyObject *value, void *data) {
177
+ CHECK_OBJECT(self);
178
+ assert(Nuitka_Function_Check(self));
179
+ assert(_PyObject_GC_IS_TRACKED(self));
180
+ CHECK_OBJECT_X(value);
181
+
182
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
183
+ PyObject *old = function->m_doc;
184
+
185
+ function->m_doc = value;
186
+ Py_XINCREF(value);
187
+
188
+ Py_XDECREF(old);
189
+
190
+ return 0;
191
+ }
192
+
193
+ static PyObject *Nuitka_Function_get_dict(PyObject *self, void *data) {
194
+ CHECK_OBJECT(self);
195
+ assert(Nuitka_Function_Check(self));
196
+ assert(_PyObject_GC_IS_TRACKED(self));
197
+
198
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
199
+ if (function->m_dict == NULL) {
200
+ NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
201
+
202
+ function->m_dict = MAKE_DICT_EMPTY(tstate);
203
+ }
204
+
205
+ CHECK_OBJECT(function->m_dict);
206
+
207
+ Py_INCREF(function->m_dict);
208
+ return function->m_dict;
209
+ }
210
+
211
+ static int Nuitka_Function_set_dict(PyObject *self, PyObject *value, void *data) {
212
+ CHECK_OBJECT(self);
213
+ assert(Nuitka_Function_Check(self));
214
+ assert(_PyObject_GC_IS_TRACKED(self));
215
+ CHECK_OBJECT_X(value);
216
+
217
+ if (unlikely(value == NULL)) {
218
+ PyThreadState *tstate = PyThreadState_GET();
219
+
220
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "function's dictionary may not be deleted");
221
+ return -1;
222
+ }
223
+
224
+ if (likely(PyDict_Check(value))) {
225
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
226
+ PyObject *old = function->m_dict;
227
+ CHECK_OBJECT_X(old);
228
+
229
+ Py_INCREF(value);
230
+ function->m_dict = value;
231
+ Py_XDECREF(old);
232
+
233
+ return 0;
234
+ } else {
235
+ PyThreadState *tstate = PyThreadState_GET();
236
+
237
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "setting function's dictionary to a non-dict");
238
+ return -1;
239
+ }
240
+ }
241
+
242
+ static PyObject *Nuitka_Function_get_code(PyObject *self, void *data) {
243
+ CHECK_OBJECT(self);
244
+ assert(Nuitka_Function_Check(self));
245
+ assert(_PyObject_GC_IS_TRACKED(self));
246
+
247
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
248
+ PyObject *result = (PyObject *)function->m_code_object;
249
+ Py_INCREF(result);
250
+ return result;
251
+ }
252
+
253
+ static int Nuitka_Function_set_code(PyObject *self, PyObject *value, void *data) {
254
+ CHECK_OBJECT(self);
255
+ assert(Nuitka_Function_Check(self));
256
+ assert(_PyObject_GC_IS_TRACKED(self));
257
+
258
+ PyThreadState *tstate = PyThreadState_GET();
259
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "__code__ is not writable in Nuitka");
260
+ return -1;
261
+ }
262
+
263
+ static PyObject *Nuitka_Function_get_compiled(PyObject *self, void *data) {
264
+ CHECK_OBJECT(self);
265
+ assert(Nuitka_Function_Check(self));
266
+ assert(_PyObject_GC_IS_TRACKED(self));
267
+
268
+ PyObject *result = Nuitka_dunder_compiled_value;
269
+ CHECK_OBJECT(result);
270
+
271
+ Py_INCREF(result);
272
+ return result;
273
+ }
274
+
275
+ static int Nuitka_Function_set_compiled(PyObject *self, PyObject *value, void *data) {
276
+ CHECK_OBJECT(self);
277
+ assert(Nuitka_Function_Check(self));
278
+ assert(_PyObject_GC_IS_TRACKED(self));
279
+
280
+ PyThreadState *tstate = PyThreadState_GET();
281
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "__compiled__ is not writable");
282
+ return -1;
283
+ }
284
+
285
+ static PyObject *Nuitka_Function_get_compiled_constant(PyObject *self, void *data) {
286
+ CHECK_OBJECT(self);
287
+ assert(Nuitka_Function_Check(self));
288
+ assert(_PyObject_GC_IS_TRACKED(self));
289
+
290
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
291
+ PyObject *result = function->m_constant_return_value;
292
+
293
+ if (result == NULL) {
294
+ PyThreadState *tstate = PyThreadState_GET();
295
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_AttributeError, "non-constant return value");
296
+
297
+ return NULL;
298
+ }
299
+ CHECK_OBJECT(result);
300
+
301
+ Py_INCREF_IMMORTAL(result);
302
+ return result;
303
+ }
304
+
305
+ static int Nuitka_Function_set_compiled_constant(PyObject *self, PyObject *value, void *data) {
306
+ CHECK_OBJECT(self);
307
+ assert(Nuitka_Function_Check(self));
308
+ assert(_PyObject_GC_IS_TRACKED(self));
309
+
310
+ PyThreadState *tstate = PyThreadState_GET();
311
+
312
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_RuntimeError, "__compiled_constant__ is not writable");
313
+ return -1;
314
+ }
315
+
316
+ static PyObject *Nuitka_Function_get_closure(PyObject *self, void *data) {
317
+ CHECK_OBJECT(self);
318
+ assert(Nuitka_Function_Check(self));
319
+ assert(_PyObject_GC_IS_TRACKED(self));
320
+
321
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
322
+ if (function->m_closure_given > 0) {
323
+ NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
324
+ return MAKE_TUPLE(tstate, (PyObject *const *)function->m_closure, function->m_closure_given);
325
+ } else {
326
+ Py_INCREF_IMMORTAL(Py_None);
327
+ return Py_None;
328
+ }
329
+ }
330
+
331
+ static int Nuitka_Function_set_closure(PyObject *self, PyObject *value, void *data) {
332
+ CHECK_OBJECT(self);
333
+ assert(Nuitka_Function_Check(self));
334
+ assert(_PyObject_GC_IS_TRACKED(self));
335
+
336
+ PyThreadState *tstate = PyThreadState_GET();
337
+
338
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate,
339
+ #if PYTHON_VERSION < 0x300
340
+ PyExc_TypeError,
341
+ #else
342
+ PyExc_AttributeError,
343
+ #endif
344
+ "readonly attribute");
345
+
346
+ return -1;
347
+ }
348
+
349
+ static PyObject *Nuitka_Function_get_defaults(PyObject *self, void *data) {
350
+ CHECK_OBJECT(self);
351
+ assert(Nuitka_Function_Check(self));
352
+ assert(_PyObject_GC_IS_TRACKED(self));
353
+
354
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
355
+ PyObject *result = (PyObject *)function->m_defaults;
356
+ CHECK_OBJECT(result);
357
+
358
+ Py_INCREF(result);
359
+ return result;
360
+ }
361
+
362
+ static void _onUpdatedCompiledFunctionDefaultsValue(struct Nuitka_FunctionObject *function) {
363
+ CHECK_OBJECT((PyObject *)function);
364
+ assert(Nuitka_Function_Check((PyObject *)function));
365
+
366
+ if (function->m_defaults == Py_None) {
367
+ function->m_defaults_given = 0;
368
+ } else {
369
+ function->m_defaults_given = PyTuple_GET_SIZE(function->m_defaults);
370
+ }
371
+ }
372
+
373
+ static int Nuitka_Function_set_defaults(PyObject *self, PyObject *value, void *data) {
374
+ CHECK_OBJECT(self);
375
+ assert(Nuitka_Function_Check(self));
376
+ assert(_PyObject_GC_IS_TRACKED(self));
377
+ CHECK_OBJECT_X(value);
378
+
379
+ if (value == NULL) {
380
+ value = Py_None;
381
+ }
382
+
383
+ if (unlikely(value != Py_None && PyTuple_Check(value) == false)) {
384
+ PyThreadState *tstate = PyThreadState_GET();
385
+
386
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "__defaults__ must be set to a tuple object");
387
+ return -1;
388
+ }
389
+
390
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
391
+ PyObject *old = function->m_defaults;
392
+ CHECK_OBJECT(old);
393
+
394
+ Py_INCREF(value);
395
+ function->m_defaults = value;
396
+ Py_DECREF(old);
397
+
398
+ _onUpdatedCompiledFunctionDefaultsValue(function);
399
+
400
+ return 0;
401
+ }
402
+
403
+ #if PYTHON_VERSION >= 0x300
404
+ static PyObject *Nuitka_Function_get_kwdefaults(PyObject *self, void *data) {
405
+ CHECK_OBJECT(self);
406
+ assert(Nuitka_Function_Check(self));
407
+ assert(_PyObject_GC_IS_TRACKED(self));
408
+
409
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
410
+ PyObject *result = function->m_kwdefaults;
411
+ CHECK_OBJECT_X(result);
412
+
413
+ if (result == NULL) {
414
+ result = Py_None;
415
+ }
416
+
417
+ Py_INCREF(result);
418
+ return result;
419
+ }
420
+
421
+ static int Nuitka_Function_set_kwdefaults(PyObject *self, PyObject *value, void *data) {
422
+ CHECK_OBJECT(self);
423
+ assert(Nuitka_Function_Check(self));
424
+ assert(_PyObject_GC_IS_TRACKED(self));
425
+ CHECK_OBJECT_X(value);
426
+
427
+ if (value == NULL) {
428
+ value = Py_None;
429
+ }
430
+
431
+ if (unlikely(value != Py_None && PyDict_Check(value) == false)) {
432
+ PyThreadState *tstate = PyThreadState_GET();
433
+
434
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "__kwdefaults__ must be set to a dict object");
435
+ return -1;
436
+ }
437
+
438
+ if (value == Py_None) {
439
+ value = NULL;
440
+ }
441
+
442
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
443
+ PyObject *old = function->m_kwdefaults;
444
+ CHECK_OBJECT_X(old);
445
+
446
+ Py_XINCREF(value);
447
+ function->m_kwdefaults = value;
448
+ Py_XDECREF(old);
449
+
450
+ return 0;
451
+ }
452
+
453
+ static PyObject *Nuitka_Function_get_annotations(PyObject *self, void *data) {
454
+ CHECK_OBJECT(self);
455
+ assert(Nuitka_Function_Check(self));
456
+ assert(_PyObject_GC_IS_TRACKED(self));
457
+
458
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
459
+ if (function->m_annotations == NULL) {
460
+ NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
461
+
462
+ function->m_annotations = MAKE_DICT_EMPTY(tstate);
463
+ }
464
+ CHECK_OBJECT(function->m_annotations);
465
+
466
+ Py_INCREF(function->m_annotations);
467
+ return function->m_annotations;
468
+ }
469
+
470
+ static int Nuitka_Function_set_annotations(PyObject *self, PyObject *value, void *data) {
471
+ CHECK_OBJECT(self);
472
+ assert(Nuitka_Function_Check(self));
473
+ assert(_PyObject_GC_IS_TRACKED(self));
474
+
475
+ if (unlikely(value != NULL && PyDict_Check(value) == false)) {
476
+ PyThreadState *tstate = PyThreadState_GET();
477
+
478
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "__annotations__ must be set to a dict object");
479
+ return -1;
480
+ }
481
+
482
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
483
+ PyObject *old = function->m_annotations;
484
+ CHECK_OBJECT_X(old);
485
+
486
+ Py_XINCREF(value);
487
+ function->m_annotations = value;
488
+ Py_XDECREF(old);
489
+
490
+ return 0;
491
+ }
492
+
493
+ #endif
494
+
495
+ static int Nuitka_Function_set_globals(PyObject *self, PyObject *value, void *data) {
496
+ CHECK_OBJECT(self);
497
+ assert(Nuitka_Function_Check(self));
498
+ assert(_PyObject_GC_IS_TRACKED(self));
499
+
500
+ PyThreadState *tstate = PyThreadState_GET();
501
+
502
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "readonly attribute");
503
+ return -1;
504
+ }
505
+
506
+ static PyObject *Nuitka_Function_get_globals(PyObject *self, void *data) {
507
+ CHECK_OBJECT(self);
508
+ assert(Nuitka_Function_Check(self));
509
+ assert(_PyObject_GC_IS_TRACKED(self));
510
+
511
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
512
+ PyObject *result = PyModule_GetDict(function->m_module);
513
+ CHECK_OBJECT(result);
514
+
515
+ Py_INCREF(result);
516
+ return result;
517
+ }
518
+
519
+ #if PYTHON_VERSION >= 0x3a0
520
+ static int Nuitka_Function_set_builtins(PyObject *self, PyObject *value, void *data) {
521
+ CHECK_OBJECT(self);
522
+ assert(Nuitka_Function_Check(self));
523
+ assert(_PyObject_GC_IS_TRACKED(self));
524
+
525
+ PyThreadState *tstate = PyThreadState_GET();
526
+
527
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "readonly attribute");
528
+ return -1;
529
+ }
530
+
531
+ static PyObject *Nuitka_Function_get_builtins(PyObject *self, void *data) {
532
+ CHECK_OBJECT(self);
533
+ assert(Nuitka_Function_Check(self));
534
+ assert(_PyObject_GC_IS_TRACKED(self));
535
+
536
+ PyThreadState *tstate = PyThreadState_GET();
537
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
538
+ return LOOKUP_SUBSCRIPT(tstate, PyModule_GetDict(function->m_module), const_str_plain___builtins__);
539
+ }
540
+ #endif
541
+
542
+ #if PYTHON_VERSION >= 0x3c0
543
+ static int Nuitka_Function_set_type_params(PyObject *self, PyObject *value, void *data) {
544
+ CHECK_OBJECT(self);
545
+ CHECK_OBJECT_X(self);
546
+ assert(Nuitka_Function_Check(self));
547
+ assert(_PyObject_GC_IS_TRACKED(self));
548
+
549
+ if (unlikely(value == NULL || !PyTuple_Check(value))) {
550
+ PyThreadState *tstate = PyThreadState_GET();
551
+
552
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "__type_params__ must be set to a tuple");
553
+ return -1;
554
+ }
555
+
556
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
557
+ Py_SETREF(function->m_type_params, Py_NewRef(value));
558
+ return 0;
559
+ }
560
+
561
+ static PyObject *Nuitka_Function_get_type_params(PyObject *self, void *data) {
562
+ CHECK_OBJECT(self);
563
+ assert(Nuitka_Function_Check(self));
564
+ assert(_PyObject_GC_IS_TRACKED(self));
565
+
566
+ // TODO: Probably not needed anymore?
567
+ Py_INCREF(const_tuple_empty);
568
+ return const_tuple_empty;
569
+ }
570
+ #endif
571
+
572
+ static int Nuitka_Function_set_module(PyObject *self, PyObject *value, void *data) {
573
+ CHECK_OBJECT(self);
574
+ assert(Nuitka_Function_Check(self));
575
+ assert(_PyObject_GC_IS_TRACKED(self));
576
+ CHECK_OBJECT_X(value);
577
+
578
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
579
+ if (function->m_dict == NULL) {
580
+ NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
581
+
582
+ function->m_dict = MAKE_DICT_EMPTY(tstate);
583
+ }
584
+
585
+ if (value == NULL) {
586
+ value = Py_None;
587
+ }
588
+
589
+ return DICT_SET_ITEM(function->m_dict, const_str_plain___module__, value) ? 0 : -1;
590
+ }
591
+
592
+ static PyObject *Nuitka_Function_get_module(PyObject *self, void *data) {
593
+ CHECK_OBJECT(self);
594
+ assert(Nuitka_Function_Check(self));
595
+ assert(_PyObject_GC_IS_TRACKED(self));
596
+
597
+ PyObject *result;
598
+
599
+ PyThreadState *tstate = PyThreadState_GET();
600
+
601
+ // The __dict__ might overrule this.
602
+ struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)self;
603
+ if (function->m_dict) {
604
+ result = DICT_GET_ITEM1(tstate, function->m_dict, const_str_plain___module__);
605
+
606
+ if (result != NULL) {
607
+ return result;
608
+ }
609
+ }
610
+
611
+ result = MODULE_NAME1(tstate, function->m_module);
612
+ return result;
613
+ }
614
+
615
+ static PyGetSetDef Nuitka_Function_getset[] = {
616
+ #if PYTHON_VERSION >= 0x300
617
+ {(char *)"__qualname__", Nuitka_Function_get_qualname, Nuitka_Function_set_qualname, NULL},
618
+ #endif
619
+ #if PYTHON_VERSION < 0x300
620
+ {(char *)"func_name", Nuitka_Function_get_name, Nuitka_Function_set_name, NULL},
621
+ #endif
622
+ {(char *)"__name__", Nuitka_Function_get_name, Nuitka_Function_set_name, NULL},
623
+ #if PYTHON_VERSION < 0x300
624
+ {(char *)"func_doc", Nuitka_Function_get_doc, Nuitka_Function_set_doc, NULL},
625
+ #endif
626
+ {(char *)"__doc__", Nuitka_Function_get_doc, Nuitka_Function_set_doc, NULL},
627
+ #if PYTHON_VERSION < 0x300
628
+ {(char *)"func_dict", Nuitka_Function_get_dict, Nuitka_Function_set_dict, NULL},
629
+ #endif
630
+ {(char *)"__dict__", Nuitka_Function_get_dict, Nuitka_Function_set_dict, NULL},
631
+ #if PYTHON_VERSION < 0x300
632
+ {(char *)"func_code", Nuitka_Function_get_code, Nuitka_Function_set_code, NULL},
633
+ #endif
634
+ {(char *)"__code__", Nuitka_Function_get_code, Nuitka_Function_set_code, NULL},
635
+ #if PYTHON_VERSION < 0x300
636
+ {(char *)"func_defaults", Nuitka_Function_get_defaults, Nuitka_Function_set_defaults, NULL},
637
+ #endif
638
+ {(char *)"__defaults__", Nuitka_Function_get_defaults, Nuitka_Function_set_defaults, NULL},
639
+ #if PYTHON_VERSION < 0x300
640
+ {(char *)"func_globals", Nuitka_Function_get_globals, Nuitka_Function_set_globals, NULL},
641
+ #endif
642
+ {(char *)"__closure__", Nuitka_Function_get_closure, Nuitka_Function_set_closure, NULL},
643
+ #if PYTHON_VERSION < 0x300
644
+ {(char *)"func_closure", Nuitka_Function_get_closure, Nuitka_Function_set_closure, NULL},
645
+ #endif
646
+ {(char *)"__globals__", Nuitka_Function_get_globals, Nuitka_Function_set_globals, NULL},
647
+ {(char *)"__module__", Nuitka_Function_get_module, Nuitka_Function_set_module, NULL},
648
+ #if PYTHON_VERSION >= 0x300
649
+ {(char *)"__kwdefaults__", Nuitka_Function_get_kwdefaults, Nuitka_Function_set_kwdefaults, NULL},
650
+ {(char *)"__annotations__", Nuitka_Function_get_annotations, Nuitka_Function_set_annotations, NULL},
651
+ #endif
652
+ #if PYTHON_VERSION >= 0x3a0
653
+ {(char *)"__builtins__", Nuitka_Function_get_builtins, Nuitka_Function_set_builtins, NULL},
654
+ #endif
655
+ #if PYTHON_VERSION >= 0x3c0
656
+ {(char *)"__type_params__", Nuitka_Function_get_type_params, Nuitka_Function_set_type_params, NULL},
657
+ #endif
658
+ {(char *)"__compiled__", Nuitka_Function_get_compiled, Nuitka_Function_set_compiled, NULL},
659
+ {(char *)"__compiled_constant__", Nuitka_Function_get_compiled_constant, Nuitka_Function_set_compiled_constant,
660
+ NULL},
661
+ {NULL}};
662
+
663
+ static PyObject *Nuitka_Function_reduce(struct Nuitka_FunctionObject *function, PyObject *unused) {
664
+ CHECK_OBJECT((PyObject *)function);
665
+ assert(Nuitka_Function_Check((PyObject *)function));
666
+ assert(_PyObject_GC_IS_TRACKED(function));
667
+
668
+ PyObject *result;
669
+
670
+ #if PYTHON_VERSION < 0x300
671
+ result = function->m_name;
672
+ #else
673
+ result = function->m_qualname;
674
+ #endif
675
+
676
+ Py_INCREF(result);
677
+ return result;
678
+ }
679
+
680
+ static PyObject *Nuitka_Function_clone(struct Nuitka_FunctionObject *function, PyObject *unused) {
681
+ CHECK_OBJECT((PyObject *)function);
682
+ assert(Nuitka_Function_Check((PyObject *)function));
683
+ assert(_PyObject_GC_IS_TRACKED(function));
684
+
685
+ for (Py_ssize_t i = 0; i < function->m_closure_given; i++) {
686
+ assert(function->m_closure[i]);
687
+ Py_INCREF(function->m_closure[i]);
688
+ }
689
+
690
+ Py_INCREF(function->m_defaults);
691
+
692
+ #if PYTHON_VERSION >= 0x300
693
+ #if 0
694
+ PRINT_STRING("Nuitka_Function_clone:");
695
+ PRINT_ITEM((PyObject *)function);
696
+ PRINT_NEW_LINE();
697
+ #endif
698
+
699
+ PyThreadState *tstate = PyThreadState_GET();
700
+
701
+ PyObject *annotations = function->m_annotations;
702
+ if (annotations != NULL) {
703
+ if (DICT_SIZE(annotations) != 0) {
704
+ annotations = DICT_COPY(tstate, annotations);
705
+ } else {
706
+ annotations = NULL;
707
+ }
708
+ }
709
+
710
+ PyObject *kwdefaults = function->m_kwdefaults;
711
+ if (kwdefaults != NULL) {
712
+ if (DICT_SIZE(kwdefaults) != 0) {
713
+ kwdefaults = DICT_COPY(tstate, kwdefaults);
714
+ } else {
715
+ kwdefaults = NULL;
716
+ }
717
+ }
718
+ #endif
719
+
720
+ struct Nuitka_FunctionObject *result =
721
+ Nuitka_Function_New(function->m_c_code, function->m_name,
722
+ #if PYTHON_VERSION >= 0x300
723
+ function->m_qualname,
724
+ #endif
725
+ function->m_code_object, function->m_defaults,
726
+ #if PYTHON_VERSION >= 0x300
727
+ kwdefaults, annotations,
728
+ #endif
729
+ function->m_module, function->m_doc, function->m_closure, function->m_closure_given);
730
+
731
+ return (PyObject *)result;
732
+ }
733
+
734
+ // Freelist setup
735
+ #define MAX_FUNCTION_FREE_LIST_COUNT 100
736
+ static struct Nuitka_FunctionObject *free_list_functions = NULL;
737
+ static int free_list_functions_count = 0;
738
+
739
+ static void Nuitka_Function_tp_dealloc(struct Nuitka_FunctionObject *function) {
740
+ #if _DEBUG_REFCOUNTS
741
+ count_active_Nuitka_Function_Type -= 1;
742
+ count_released_Nuitka_Function_Type += 1;
743
+ #endif
744
+
745
+ assert(Nuitka_Function_Check((PyObject *)function));
746
+ assert(_PyObject_GC_IS_TRACKED(function));
747
+
748
+ #ifndef __NUITKA_NO_ASSERT__
749
+ PyThreadState *tstate = PyThreadState_GET();
750
+
751
+ // Save the current exception, if any, we must to not corrupt it.
752
+ struct Nuitka_ExceptionPreservationItem saved_exception_state1;
753
+ FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state1);
754
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state1);
755
+ #endif
756
+ assert(_PyObject_GC_IS_TRACKED(function));
757
+ Nuitka_GC_UnTrack(function);
758
+
759
+ if (function->m_weakrefs != NULL) {
760
+ PyObject_ClearWeakRefs((PyObject *)function);
761
+ }
762
+
763
+ Py_DECREF(function->m_name);
764
+ #if PYTHON_VERSION >= 0x300
765
+ Py_DECREF(function->m_qualname);
766
+ #endif
767
+
768
+ #if PYTHON_VERSION >= 0x3c0
769
+ Py_DECREF(function->m_type_params);
770
+ #endif
771
+
772
+ // These may actually resurrect the object, not?
773
+ Py_XDECREF(function->m_dict);
774
+ Py_DECREF(function->m_defaults);
775
+
776
+ Py_XDECREF(function->m_doc);
777
+
778
+ #if PYTHON_VERSION >= 0x300
779
+ Py_XDECREF(function->m_kwdefaults);
780
+ Py_XDECREF(function->m_annotations);
781
+ #endif
782
+
783
+ for (Py_ssize_t i = 0; i < function->m_closure_given; i++) {
784
+ assert(function->m_closure[i]);
785
+ Py_DECREF(function->m_closure[i]);
786
+
787
+ // Note: No need to set to NULL, each function creation makes
788
+ // a full copy, doing the init.
789
+ }
790
+
791
+ /* Put the object into free list or release to GC */
792
+ releaseToFreeList(free_list_functions, function, MAX_FUNCTION_FREE_LIST_COUNT);
793
+
794
+ #ifndef __NUITKA_NO_ASSERT__
795
+ struct Nuitka_ExceptionPreservationItem saved_exception_state2;
796
+ FETCH_ERROR_OCCURRED_STATE(tstate, &saved_exception_state2);
797
+ RESTORE_ERROR_OCCURRED_STATE(tstate, &saved_exception_state2);
798
+
799
+ ASSERT_SAME_EXCEPTION_STATE(&saved_exception_state1, &saved_exception_state2);
800
+ #endif
801
+ }
802
+
803
+ static PyMethodDef Nuitka_Function_methods[] = {{"__reduce__", (PyCFunction)Nuitka_Function_reduce, METH_NOARGS, NULL},
804
+ {"clone", (PyCFunction)Nuitka_Function_clone, METH_NOARGS, NULL},
805
+ {NULL}};
806
+
807
+ static PyObject *Nuitka_Function_tp_call(struct Nuitka_FunctionObject *function, PyObject *tuple_args, PyObject *kw);
808
+
809
+ PyTypeObject Nuitka_Function_Type = {
810
+ PyVarObject_HEAD_INIT(NULL, 0) "compiled_function", // tp_name
811
+ sizeof(struct Nuitka_FunctionObject), // tp_basicsize
812
+ sizeof(struct Nuitka_CellObject *), // tp_itemsize
813
+ (destructor)Nuitka_Function_tp_dealloc, // tp_dealloc
814
+ #if PYTHON_VERSION < 0x380 || defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_SLOT)
815
+ 0, // tp_print
816
+ #else
817
+ offsetof(struct Nuitka_FunctionObject, m_vectorcall), // tp_vectorcall_offset
818
+ #endif
819
+ 0, // tp_getattr
820
+ 0, // tp_setattr
821
+ 0, // tp_compare
822
+ (reprfunc)Nuitka_Function_tp_repr, // tp_repr
823
+ 0, // tp_as_number
824
+ 0, // tp_as_sequence
825
+ 0, // tp_as_mapping
826
+ (hashfunc)Nuitka_Function_tp_hash, // tp_hash
827
+ (ternaryfunc)Nuitka_Function_tp_call, // tp_call
828
+ 0, // tp_str
829
+ 0, // tp_getattro (PyObject_GenericGetAttr)
830
+ 0, // tp_setattro
831
+ 0, // tp_as_buffer
832
+ Py_TPFLAGS_DEFAULT |
833
+ #if PYTHON_VERSION < 0x300
834
+ Py_TPFLAGS_HAVE_WEAKREFS |
835
+ #endif
836
+ #if PYTHON_VERSION >= 0x380
837
+ _Py_TPFLAGS_HAVE_VECTORCALL | Py_TPFLAGS_METHOD_DESCRIPTOR |
838
+ #endif
839
+ Py_TPFLAGS_HAVE_GC, // tp_flags
840
+ 0, // tp_doc
841
+ (traverseproc)Nuitka_Function_tp_traverse, // tp_traverse
842
+ 0, // tp_clear
843
+ 0, // tp_richcompare
844
+ offsetof(struct Nuitka_FunctionObject, m_weakrefs), // tp_weaklistoffset
845
+ 0, // tp_iter
846
+ 0, // tp_iternext
847
+ Nuitka_Function_methods, // tp_methods
848
+ 0, // tp_members
849
+ Nuitka_Function_getset, // tp_getset
850
+ 0, // tp_base
851
+ 0, // tp_dict
852
+ Nuitka_Function_descr_get, // tp_descr_get
853
+ 0, // tp_descr_set
854
+ offsetof(struct Nuitka_FunctionObject, m_dict), // tp_dictoffset
855
+ 0, // tp_init
856
+ 0, // tp_alloc
857
+ 0, // tp_new
858
+ 0, // tp_free
859
+ 0, // tp_is_gc
860
+ 0, // tp_bases
861
+ 0, // tp_mro
862
+ 0, // tp_cache
863
+ 0, // tp_subclasses
864
+ 0, // tp_weaklist
865
+ 0, // tp_del
866
+ 0 // tp_version_tag
867
+ #if PYTHON_VERSION >= 0x300
868
+ ,
869
+ 0 // tp_finalizer
870
+ #endif
871
+ };
872
+
873
+ void _initCompiledFunctionType(void) {
874
+ Nuitka_PyType_Ready(&Nuitka_Function_Type, &PyFunction_Type, true, false, false, false, false);
875
+
876
+ // Be a paranoid subtype of uncompiled function, we want nothing shared.
877
+ assert(Nuitka_Function_Type.tp_doc != PyFunction_Type.tp_doc);
878
+ assert(Nuitka_Function_Type.tp_traverse != PyFunction_Type.tp_traverse);
879
+ assert(Nuitka_Function_Type.tp_clear != PyFunction_Type.tp_clear || PyFunction_Type.tp_clear == NULL);
880
+ assert(Nuitka_Function_Type.tp_richcompare != PyFunction_Type.tp_richcompare ||
881
+ PyFunction_Type.tp_richcompare == NULL);
882
+ assert(Nuitka_Function_Type.tp_weaklistoffset != PyFunction_Type.tp_weaklistoffset);
883
+ assert(Nuitka_Function_Type.tp_iter != PyFunction_Type.tp_iter || PyFunction_Type.tp_iter == NULL);
884
+ assert(Nuitka_Function_Type.tp_iternext != PyFunction_Type.tp_iternext || PyFunction_Type.tp_iternext == NULL);
885
+ assert(Nuitka_Function_Type.tp_methods != PyFunction_Type.tp_methods);
886
+ assert(Nuitka_Function_Type.tp_members != PyFunction_Type.tp_members);
887
+ assert(Nuitka_Function_Type.tp_getset != PyFunction_Type.tp_getset);
888
+ assert(Nuitka_Function_Type.tp_dict != PyFunction_Type.tp_dict);
889
+ assert(Nuitka_Function_Type.tp_descr_get != PyFunction_Type.tp_descr_get);
890
+
891
+ assert(Nuitka_Function_Type.tp_descr_set != PyFunction_Type.tp_descr_set || PyFunction_Type.tp_descr_set == NULL);
892
+ assert(Nuitka_Function_Type.tp_dictoffset != PyFunction_Type.tp_dictoffset);
893
+ // TODO: These get changed and into the same thing, not sure what to compare against, project something
894
+ // assert(Nuitka_Function_Type.tp_init != PyFunction_Type.tp_init || PyFunction_Type.tp_init == NULL);
895
+ // assert(Nuitka_Function_Type.tp_alloc != PyFunction_Type.tp_alloc || PyFunction_Type.tp_alloc == NULL);
896
+ // assert(Nuitka_Function_Type.tp_new != PyFunction_Type.tp_new || PyFunction_Type.tp_new == NULL);
897
+ // assert(Nuitka_Function_Type.tp_free != PyFunction_Type.tp_free || PyFunction_Type.tp_free == NULL);
898
+ assert(Nuitka_Function_Type.tp_bases != PyFunction_Type.tp_bases);
899
+ assert(Nuitka_Function_Type.tp_mro != PyFunction_Type.tp_mro);
900
+ assert(Nuitka_Function_Type.tp_cache != PyFunction_Type.tp_cache || PyFunction_Type.tp_cache == NULL);
901
+ assert(Nuitka_Function_Type.tp_subclasses != PyFunction_Type.tp_subclasses || PyFunction_Type.tp_cache == NULL);
902
+ assert(Nuitka_Function_Type.tp_weaklist != PyFunction_Type.tp_weaklist);
903
+ assert(Nuitka_Function_Type.tp_del != PyFunction_Type.tp_del || PyFunction_Type.tp_del == NULL);
904
+ #if PYTHON_VERSION >= 0x300
905
+ assert(Nuitka_Function_Type.tp_finalize != PyFunction_Type.tp_finalize || PyFunction_Type.tp_finalize == NULL);
906
+ #endif
907
+
908
+ // Make sure we don't miss out on attributes we are not having or should not have.
909
+ #ifndef __NUITKA_NO_ASSERT__
910
+ for (struct PyGetSetDef *own = &Nuitka_Function_getset[0]; own->name != NULL; own++) {
911
+ bool found = false;
912
+
913
+ for (struct PyGetSetDef *related = PyFunction_Type.tp_getset; related->name != NULL; related++) {
914
+ if (strcmp(related->name, own->name) == 0) {
915
+ found = true;
916
+ }
917
+ }
918
+
919
+ if (found == false) {
920
+ if (strcmp(own->name, "__doc__") == 0) {
921
+ // We do that one differently right now.
922
+ continue;
923
+ }
924
+ #if PYTHON_VERSION < 0x300
925
+ if (strcmp(own->name, "func_doc") == 0) {
926
+ // We do that one differently right now.
927
+ continue;
928
+ }
929
+ #endif
930
+
931
+ if (strcmp(own->name, "__globals__") == 0) {
932
+ // We do that one differently right now.
933
+ continue;
934
+ }
935
+
936
+ #if PYTHON_VERSION < 0x300
937
+ if (strcmp(own->name, "func_globals") == 0) {
938
+ // We do that one differently right now.
939
+ continue;
940
+ }
941
+ #endif
942
+
943
+ #if PYTHON_VERSION >= 0x3a0
944
+ if (strcmp(own->name, "__builtins__") == 0) {
945
+ // We do that one differently right now.
946
+ continue;
947
+ }
948
+ #endif
949
+
950
+ if (strcmp(own->name, "__module__") == 0) {
951
+ // We do that one differently right now.
952
+ continue;
953
+ }
954
+
955
+ if (strcmp(own->name, "__closure__") == 0) {
956
+ // We have to do that differently, because we do not keep this around until
957
+ // needed, and we make it read-only
958
+ continue;
959
+ }
960
+
961
+ #if PYTHON_VERSION < 0x300
962
+ if (strcmp(own->name, "func_closure") == 0) {
963
+ // We have to do that differently, because we do not keep this around until
964
+ // needed, and we make it read-only
965
+ continue;
966
+ }
967
+ #endif
968
+
969
+ if (strcmp(own->name, "__compiled__") == 0 || strcmp(own->name, "__compiled_constant__") == 0) {
970
+ // We have to do that differently, because we do not keep this around until
971
+ // needed, and we make it read-only
972
+ continue;
973
+ }
974
+
975
+ PRINT_FORMAT("Not found in uncompiled type: %s\n", own->name);
976
+ NUITKA_CANNOT_GET_HERE("Type problem");
977
+ }
978
+ }
979
+
980
+ for (struct PyGetSetDef *related = PyFunction_Type.tp_getset; related->name != NULL; related++) {
981
+ bool found = false;
982
+
983
+ for (struct PyGetSetDef *own = &Nuitka_Function_getset[0]; own->name != NULL; own++) {
984
+ if (strcmp(related->name, own->name) == 0) {
985
+ found = true;
986
+ }
987
+ }
988
+
989
+ if (found == false) {
990
+ PRINT_FORMAT("Not found in compiled type: %s\n", related->name);
991
+ NUITKA_CANNOT_GET_HERE("Type problem");
992
+ }
993
+ }
994
+
995
+ for (struct PyMemberDef *related = PyFunction_Type.tp_members; related->name != NULL; related++) {
996
+ bool found = false;
997
+
998
+ for (struct PyGetSetDef *own = &Nuitka_Function_getset[0]; own->name != NULL; own++) {
999
+ if (strcmp(related->name, own->name) == 0) {
1000
+ found = true;
1001
+ }
1002
+ }
1003
+
1004
+ if (found == false) {
1005
+ PRINT_FORMAT("Not found in compiled type: %s\n", related->name);
1006
+ NUITKA_CANNOT_GET_HERE("Type problem");
1007
+ }
1008
+ }
1009
+ #endif
1010
+ }
1011
+
1012
+ // Shared implementations for empty functions. When a function body is empty, but
1013
+ // still needs to exist, e.g. overloaded functions, this is saving the effort to
1014
+ // produce one.
1015
+ static PyObject *_Nuitka_FunctionEmptyCodeNoneImpl(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1016
+ PyObject **python_pars) {
1017
+ CHECK_OBJECT((PyObject *)function);
1018
+ assert(Nuitka_Function_Check((PyObject *)function));
1019
+ assert(_PyObject_GC_IS_TRACKED(function));
1020
+
1021
+ Py_ssize_t arg_count = function->m_args_overall_count;
1022
+
1023
+ for (Py_ssize_t i = 0; i < arg_count; i++) {
1024
+ Py_DECREF(python_pars[i]);
1025
+ }
1026
+
1027
+ PyObject *result = Py_None;
1028
+
1029
+ Py_INCREF(result);
1030
+ return result;
1031
+ }
1032
+
1033
+ static PyObject *_Nuitka_FunctionEmptyCodeTrueImpl(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1034
+ PyObject **python_pars) {
1035
+ CHECK_OBJECT((PyObject *)function);
1036
+ assert(Nuitka_Function_Check((PyObject *)function));
1037
+ assert(_PyObject_GC_IS_TRACKED(function));
1038
+
1039
+ Py_ssize_t arg_count = function->m_args_overall_count;
1040
+
1041
+ for (Py_ssize_t i = 0; i < arg_count; i++) {
1042
+ Py_DECREF(python_pars[i]);
1043
+ }
1044
+
1045
+ PyObject *result = Py_True;
1046
+
1047
+ Py_INCREF_IMMORTAL(result);
1048
+ return result;
1049
+ }
1050
+
1051
+ static PyObject *_Nuitka_FunctionEmptyCodeFalseImpl(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1052
+ PyObject **python_pars) {
1053
+ CHECK_OBJECT((PyObject *)function);
1054
+ assert(Nuitka_Function_Check((PyObject *)function));
1055
+ assert(_PyObject_GC_IS_TRACKED(function));
1056
+
1057
+ Py_ssize_t arg_count = function->m_args_overall_count;
1058
+
1059
+ for (Py_ssize_t i = 0; i < arg_count; i++) {
1060
+ Py_DECREF(python_pars[i]);
1061
+ }
1062
+
1063
+ PyObject *result = Py_False;
1064
+ Py_INCREF_IMMORTAL(result);
1065
+ return result;
1066
+ }
1067
+
1068
+ static PyObject *_Nuitka_FunctionEmptyCodeGenericImpl(PyThreadState *tstate,
1069
+ struct Nuitka_FunctionObject const *function,
1070
+ PyObject **python_pars) {
1071
+ CHECK_OBJECT((PyObject *)function);
1072
+ assert(Nuitka_Function_Check((PyObject *)function));
1073
+ assert(_PyObject_GC_IS_TRACKED(function));
1074
+
1075
+ Py_ssize_t arg_count = function->m_args_overall_count;
1076
+
1077
+ for (Py_ssize_t i = 0; i < arg_count; i++) {
1078
+ Py_DECREF(python_pars[i]);
1079
+ }
1080
+
1081
+ PyObject *result = function->m_constant_return_value;
1082
+
1083
+ Py_INCREF_IMMORTAL(result);
1084
+ return result;
1085
+ }
1086
+
1087
+ void Nuitka_Function_EnableConstReturnTrue(struct Nuitka_FunctionObject *function) {
1088
+ function->m_constant_return_value = Py_True;
1089
+ function->m_c_code = _Nuitka_FunctionEmptyCodeTrueImpl;
1090
+ }
1091
+
1092
+ void Nuitka_Function_EnableConstReturnFalse(struct Nuitka_FunctionObject *function) {
1093
+ function->m_constant_return_value = Py_False;
1094
+ function->m_c_code = _Nuitka_FunctionEmptyCodeFalseImpl;
1095
+ }
1096
+
1097
+ void Nuitka_Function_EnableConstReturnGeneric(struct Nuitka_FunctionObject *function, PyObject *value) {
1098
+ function->m_constant_return_value = value;
1099
+ function->m_c_code = _Nuitka_FunctionEmptyCodeGenericImpl;
1100
+ }
1101
+
1102
+ #ifdef _NUITKA_PLUGIN_DILL_ENABLED
1103
+ int Nuitka_Function_GetFunctionCodeIndex(PyThreadState *tstate, struct Nuitka_FunctionObject *function,
1104
+ function_impl_code const *function_table) {
1105
+
1106
+ if (function->m_c_code == _Nuitka_FunctionEmptyCodeTrueImpl) {
1107
+ return -2;
1108
+ }
1109
+
1110
+ if (function->m_c_code == _Nuitka_FunctionEmptyCodeFalseImpl) {
1111
+ return -3;
1112
+ }
1113
+
1114
+ if (function->m_c_code == _Nuitka_FunctionEmptyCodeNoneImpl) {
1115
+ return -4;
1116
+ }
1117
+
1118
+ if (function->m_c_code == _Nuitka_FunctionEmptyCodeGenericImpl) {
1119
+ return -5;
1120
+ }
1121
+
1122
+ function_impl_code const *current = function_table;
1123
+ int offset = 0;
1124
+
1125
+ while (*current != NULL) {
1126
+ if (*current == function->m_c_code) {
1127
+ break;
1128
+ }
1129
+
1130
+ current += 1;
1131
+ offset += 1;
1132
+ }
1133
+
1134
+ if (*current == NULL) {
1135
+ #if 0
1136
+ PRINT_STRING("Looking for:");
1137
+ PRINT_ITEM((PyObject *)function);
1138
+ PRINT_NEW_LINE();
1139
+ #endif
1140
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "Cannot find compiled function in module.");
1141
+ return -1;
1142
+ }
1143
+
1144
+ return offset;
1145
+ }
1146
+
1147
+ PyObject *Nuitka_Function_GetFunctionState(struct Nuitka_FunctionObject *function,
1148
+ function_impl_code const *function_table) {
1149
+ PyThreadState *tstate = PyThreadState_GET();
1150
+
1151
+ int offset = Nuitka_Function_GetFunctionCodeIndex(tstate, function, function_table);
1152
+
1153
+ if (unlikely(offset == -1)) {
1154
+ #if 0
1155
+ PRINT_STRING("Looking for:");
1156
+ PRINT_ITEM(func);
1157
+ PRINT_NEW_LINE();
1158
+ #endif
1159
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "Cannot find compiled function in module.");
1160
+ return NULL;
1161
+ }
1162
+
1163
+ PyObject *code_object_desc = Nuitka_Function_ExtractCodeObjectDescription(tstate, function);
1164
+
1165
+ PyObject *result = MAKE_TUPLE_EMPTY(tstate, 10);
1166
+ PyTuple_SET_ITEM(result, 0, Nuitka_PyLong_FromLong(offset));
1167
+ PyTuple_SET_ITEM(result, 1, code_object_desc);
1168
+ PyTuple_SET_ITEM0(result, 2, function->m_defaults);
1169
+ #if PYTHON_VERSION >= 0x300
1170
+ PyTuple_SET_ITEM0(result, 3, function->m_kwdefaults ? function->m_kwdefaults : Py_None);
1171
+ #else
1172
+ PyTuple_SET_ITEM_IMMORTAL(result, 3, Py_None);
1173
+ #endif
1174
+ PyTuple_SET_ITEM0(result, 4, function->m_doc != NULL ? function->m_doc : Py_None);
1175
+
1176
+ if (offset == -5) {
1177
+ CHECK_OBJECT(function->m_constant_return_value);
1178
+ PyTuple_SET_ITEM_IMMORTAL(result, 5, function->m_constant_return_value);
1179
+ } else {
1180
+ PyTuple_SET_ITEM_IMMORTAL(result, 5, Py_None);
1181
+ }
1182
+
1183
+ #if PYTHON_VERSION >= 0x300
1184
+ PyTuple_SET_ITEM0(result, 6, function->m_qualname);
1185
+ #else
1186
+ PyTuple_SET_ITEM_IMMORTAL(result, 6, Py_None);
1187
+ #endif
1188
+
1189
+ PyObject *closure = PyObject_GetAttr((PyObject *)function, const_str_plain___closure__);
1190
+
1191
+ if (closure != Py_None) {
1192
+ for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(closure); i++) {
1193
+ struct Nuitka_CellObject *cell = (struct Nuitka_CellObject *)PyTuple_GET_ITEM(closure, i);
1194
+
1195
+ assert(Nuitka_Cell_Check((PyObject *)cell));
1196
+
1197
+ PyTuple_SET_ITEM0(closure, i, cell->ob_ref);
1198
+ }
1199
+ }
1200
+
1201
+ PyTuple_SET_ITEM(result, 7, closure);
1202
+
1203
+ #if PYTHON_VERSION >= 0x300
1204
+ PyTuple_SET_ITEM0(result, 8,
1205
+ (function->m_annotations && DICT_SIZE(function->m_annotations) > 0) ? function->m_annotations
1206
+ : Py_None);
1207
+ #else
1208
+ PyTuple_SET_ITEM_IMMORTAL(result, 8, Py_None);
1209
+ #endif
1210
+
1211
+ PyTuple_SET_ITEM0(result, 9, function->m_dict ? function->m_dict : Py_None);
1212
+ CHECK_OBJECT_DEEP(result);
1213
+
1214
+ return result;
1215
+ }
1216
+
1217
+ struct Nuitka_FunctionObject *Nuitka_Function_CreateFunctionViaCodeIndex(
1218
+ PyObject *module, PyObject *function_qualname, PyObject *function_index, PyObject *code_object_desc,
1219
+ PyObject *constant_return_value, PyObject *defaults, PyObject *kw_defaults, PyObject *doc, PyObject *closure,
1220
+ PyObject *annotations, PyObject *func_dict, function_impl_code const *function_table, int function_table_size) {
1221
+ int offset = PyLong_AsLong(function_index);
1222
+
1223
+ if (offset > function_table_size || offset < -5 || offset == -1) {
1224
+ PyThreadState *tstate = PyThreadState_GET();
1225
+
1226
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "Wrong offset for compiled function.");
1227
+ return NULL;
1228
+ }
1229
+
1230
+ PyObject *filename = PyTuple_GET_ITEM(code_object_desc, 0);
1231
+ PyObject *function_name = PyTuple_GET_ITEM(code_object_desc, 1);
1232
+ PyObject *line = PyTuple_GET_ITEM(code_object_desc, 2);
1233
+ int line_int = PyLong_AsLong(line);
1234
+ assert(line_int != -1);
1235
+
1236
+ PyObject *arg_names = PyTuple_GET_ITEM(code_object_desc, 3);
1237
+ PyObject *arg_count = PyTuple_GET_ITEM(code_object_desc, 4);
1238
+ int arg_count_int = PyLong_AsLong(arg_count);
1239
+ assert(arg_count_int != -1);
1240
+
1241
+ PyObject *flags = PyTuple_GET_ITEM(code_object_desc, 5);
1242
+ int flags_int = PyLong_AsLong(flags);
1243
+ assert(flags_int != -1);
1244
+
1245
+ PyObject *kw_only_count = PyTuple_GET_ITEM(code_object_desc, 6);
1246
+ int kw_only_count_int = PyLong_AsLong(kw_only_count);
1247
+ assert(kw_only_count_int != -1);
1248
+
1249
+ PyObject *pos_only_count = PyTuple_GET_ITEM(code_object_desc, 7);
1250
+ int pos_only_count_int = PyLong_AsLong(pos_only_count);
1251
+ assert(pos_only_count_int != -1);
1252
+
1253
+ PyCodeObject *code_object =
1254
+ MAKE_CODE_OBJECT(filename, line_int, flags_int, function_name, function_qualname, arg_names,
1255
+ NULL, // free_vars
1256
+ arg_count_int, kw_only_count_int, pos_only_count_int);
1257
+ if (unlikely(code_object == NULL)) {
1258
+ return NULL;
1259
+ }
1260
+
1261
+ Py_ssize_t closure_size;
1262
+
1263
+ if (closure != Py_None) {
1264
+ closure_size = PyTuple_GET_SIZE(closure);
1265
+ } else {
1266
+ closure_size = 0;
1267
+ }
1268
+
1269
+ NUITKA_DYNAMIC_ARRAY_DECL(closure_cells, struct Nuitka_CellObject *, closure_size);
1270
+
1271
+ for (Py_ssize_t i = 0; i < closure_size; i++) {
1272
+ closure_cells[i] = Nuitka_Cell_New0(PyTuple_GET_ITEM(closure, i));
1273
+ }
1274
+
1275
+ // Function creation takes no reference to these.
1276
+ Py_INCREF(defaults);
1277
+
1278
+ if (kw_defaults == Py_None) {
1279
+ kw_defaults = NULL;
1280
+ } else {
1281
+ Py_INCREF(kw_defaults);
1282
+ }
1283
+
1284
+ if (annotations == Py_None) {
1285
+ annotations = NULL;
1286
+ } else {
1287
+ Py_INCREF(annotations);
1288
+ }
1289
+
1290
+ struct Nuitka_FunctionObject *result =
1291
+ Nuitka_Function_New(offset >= 0 ? function_table[offset] : NULL, code_object->co_name,
1292
+ #if PYTHON_VERSION >= 0x300
1293
+ function_qualname,
1294
+ #endif
1295
+ code_object, defaults,
1296
+ #if PYTHON_VERSION >= 0x300
1297
+ kw_defaults, annotations,
1298
+ #endif
1299
+ module, doc, closure_cells, closure_size);
1300
+
1301
+ CHECK_OBJECT(result);
1302
+
1303
+ if (offset == -2) {
1304
+ Nuitka_Function_EnableConstReturnTrue(result);
1305
+ } else if (offset == -3) {
1306
+ Nuitka_Function_EnableConstReturnFalse(result);
1307
+ } else if (offset == -4) {
1308
+ result->m_c_code = _Nuitka_FunctionEmptyCodeNoneImpl;
1309
+ } else if (offset == -5) {
1310
+ CHECK_OBJECT(constant_return_value);
1311
+
1312
+ Nuitka_Function_EnableConstReturnGeneric(result, constant_return_value);
1313
+
1314
+ Py_INCREF_IMMORTAL(constant_return_value);
1315
+ } else if (offset < 0) {
1316
+ // Try to catch if we are missing values for the specialized shared
1317
+ // bodies.
1318
+ NUITKA_CANNOT_GET_HERE("Compiled function unpickle problem");
1319
+ }
1320
+
1321
+ assert(result->m_dict == NULL);
1322
+ if (func_dict != Py_None) {
1323
+ Py_INCREF(func_dict);
1324
+ result->m_dict = func_dict;
1325
+ }
1326
+
1327
+ assert(result->m_c_code != NULL);
1328
+
1329
+ return result;
1330
+ }
1331
+
1332
+ PyObject *Nuitka_Function_ExtractCodeObjectDescription(PyThreadState *tstate, struct Nuitka_FunctionObject *function) {
1333
+ PyObject *code_object_desc = MAKE_TUPLE_EMPTY(tstate, 8);
1334
+
1335
+ PyTuple_SET_ITEM0(code_object_desc, 0, function->m_code_object->co_filename);
1336
+ PyTuple_SET_ITEM0(code_object_desc, 1, function->m_code_object->co_name);
1337
+ PyTuple_SET_ITEM(code_object_desc, 2, Nuitka_PyLong_FromLong(function->m_code_object->co_firstlineno));
1338
+ #if PYTHON_VERSION < 0x3b0
1339
+ PyTuple_SET_ITEM0(code_object_desc, 3, function->m_code_object->co_varnames);
1340
+ #else
1341
+ // spell-checker: ignore PyCode_GetVarnames
1342
+ PyTuple_SET_ITEM(code_object_desc, 3, PyCode_GetVarnames(function->m_code_object));
1343
+ #endif
1344
+ PyTuple_SET_ITEM(code_object_desc, 4, Nuitka_PyLong_FromLong(function->m_code_object->co_argcount));
1345
+ PyTuple_SET_ITEM(code_object_desc, 5, Nuitka_PyLong_FromLong(function->m_code_object->co_flags));
1346
+
1347
+ #if PYTHON_VERSION < 0x380
1348
+ PyTuple_SET_ITEM0(code_object_desc, 6, const_int_0);
1349
+ #else
1350
+ PyTuple_SET_ITEM(code_object_desc, 6, Nuitka_PyLong_FromLong(function->m_code_object->co_posonlyargcount));
1351
+ #endif
1352
+
1353
+ #if PYTHON_VERSION < 0x3b0
1354
+ PyTuple_SET_ITEM0(code_object_desc, 7, const_int_0);
1355
+ #else
1356
+ PyTuple_SET_ITEM(code_object_desc, 7, Nuitka_PyLong_FromLong(function->m_code_object->co_kwonlyargcount));
1357
+ #endif
1358
+
1359
+ CHECK_OBJECT_DEEP(code_object_desc);
1360
+
1361
+ return code_object_desc;
1362
+ }
1363
+ #endif
1364
+
1365
+ #if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_SLOT)
1366
+ static PyObject *Nuitka_Function_tp_vectorcall(struct Nuitka_FunctionObject *function, PyObject *const *stack,
1367
+ size_t nargsf, PyObject *kw_names);
1368
+ #endif
1369
+
1370
+ // Make a function with closure.
1371
+ #if PYTHON_VERSION < 0x300
1372
+ struct Nuitka_FunctionObject *Nuitka_Function_New(function_impl_code c_code, PyObject *name, PyCodeObject *code_object,
1373
+ PyObject *defaults, PyObject *module, PyObject *doc,
1374
+ struct Nuitka_CellObject **closure, Py_ssize_t closure_given)
1375
+ #else
1376
+ struct Nuitka_FunctionObject *Nuitka_Function_New(function_impl_code c_code, PyObject *name, PyObject *qualname,
1377
+ PyCodeObject *code_object, PyObject *defaults, PyObject *kw_defaults,
1378
+ PyObject *annotations, PyObject *module, PyObject *doc,
1379
+ struct Nuitka_CellObject **closure, Py_ssize_t closure_given)
1380
+ #endif
1381
+ {
1382
+ #if _DEBUG_REFCOUNTS
1383
+ count_active_Nuitka_Function_Type += 1;
1384
+ count_allocated_Nuitka_Function_Type += 1;
1385
+ #endif
1386
+
1387
+ struct Nuitka_FunctionObject *result;
1388
+
1389
+ // Macro to assign result memory from GC or free list.
1390
+ allocateFromFreeList(free_list_functions, struct Nuitka_FunctionObject, Nuitka_Function_Type, closure_given);
1391
+
1392
+ assert(closure_given == 0 || closure != NULL);
1393
+
1394
+ memcpy(&result->m_closure[0], closure, closure_given * sizeof(struct Nuitka_CellObject *));
1395
+ result->m_closure_given = closure_given;
1396
+
1397
+ if (c_code != NULL) {
1398
+ result->m_c_code = c_code;
1399
+ result->m_constant_return_value = NULL;
1400
+ } else {
1401
+ result->m_c_code = _Nuitka_FunctionEmptyCodeNoneImpl;
1402
+ result->m_constant_return_value = Py_None;
1403
+ }
1404
+
1405
+ Py_INCREF(name);
1406
+ result->m_name = name;
1407
+
1408
+ #if PYTHON_VERSION >= 0x300
1409
+ // The "qualname" defaults to NULL for most compact C code.
1410
+ if (qualname == NULL) {
1411
+ qualname = name;
1412
+ }
1413
+ CHECK_OBJECT(qualname);
1414
+
1415
+ Py_INCREF(qualname);
1416
+ result->m_qualname = qualname;
1417
+ #endif
1418
+
1419
+ if (defaults == NULL) {
1420
+ Py_INCREF_IMMORTAL(Py_None);
1421
+ defaults = Py_None;
1422
+ }
1423
+ CHECK_OBJECT(defaults);
1424
+ assert(defaults == Py_None || (PyTuple_Check(defaults) && PyTuple_GET_SIZE(defaults) > 0));
1425
+ result->m_defaults = defaults;
1426
+
1427
+ _onUpdatedCompiledFunctionDefaultsValue(result);
1428
+
1429
+ #if PYTHON_VERSION >= 0x300
1430
+ assert(kw_defaults == NULL || (PyDict_Check(kw_defaults) && DICT_SIZE(kw_defaults) > 0));
1431
+ result->m_kwdefaults = kw_defaults;
1432
+
1433
+ assert(annotations == NULL || (PyDict_Check(annotations) && DICT_SIZE(annotations) > 0));
1434
+ result->m_annotations = annotations;
1435
+ #endif
1436
+
1437
+ result->m_code_object = code_object;
1438
+ result->m_args_positional_count = code_object->co_argcount;
1439
+ result->m_args_keywords_count = result->m_args_positional_count;
1440
+ #if PYTHON_VERSION >= 0x300
1441
+ result->m_args_keywords_count += code_object->co_kwonlyargcount;
1442
+ #endif
1443
+ #if PYTHON_VERSION >= 0x380
1444
+ result->m_args_pos_only_count = code_object->co_posonlyargcount;
1445
+ #endif
1446
+
1447
+ result->m_args_overall_count = result->m_args_keywords_count + ((code_object->co_flags & CO_VARARGS) ? 1 : 0) +
1448
+ ((code_object->co_flags & CO_VARKEYWORDS) ? 1 : 0);
1449
+
1450
+ result->m_args_simple = (code_object->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) == 0;
1451
+ #if PYTHON_VERSION >= 0x300
1452
+ if (code_object->co_kwonlyargcount > 0) {
1453
+ result->m_args_simple = false;
1454
+ }
1455
+ #endif
1456
+
1457
+ if ((code_object->co_flags & CO_VARARGS) != 0) {
1458
+ result->m_args_star_list_index = result->m_args_keywords_count;
1459
+ } else {
1460
+ result->m_args_star_list_index = -1;
1461
+ }
1462
+
1463
+ if ((code_object->co_flags & CO_VARKEYWORDS) != 0) {
1464
+ result->m_args_star_dict_index = result->m_args_keywords_count;
1465
+
1466
+ if (code_object->co_flags & CO_VARARGS) {
1467
+ result->m_args_star_dict_index += 1;
1468
+ }
1469
+ } else {
1470
+ result->m_args_star_dict_index = -1;
1471
+ }
1472
+
1473
+ result->m_varnames = Nuitka_GetCodeVarNames(code_object);
1474
+
1475
+ result->m_module = module;
1476
+
1477
+ Py_XINCREF(doc);
1478
+ result->m_doc = doc;
1479
+
1480
+ result->m_dict = NULL;
1481
+ result->m_weakrefs = NULL;
1482
+
1483
+ static long Nuitka_Function_counter = 0;
1484
+ result->m_counter = Nuitka_Function_counter++;
1485
+
1486
+ #if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_SLOT)
1487
+ result->m_vectorcall = (vectorcallfunc)Nuitka_Function_tp_vectorcall;
1488
+ #endif
1489
+
1490
+ #if PYTHON_VERSION >= 0x3c0
1491
+ result->m_type_params = const_tuple_empty;
1492
+ assert(_Py_IsImmortal(result->m_type_params));
1493
+ #endif
1494
+
1495
+ Nuitka_GC_Track(result);
1496
+
1497
+ assert(Py_REFCNT(result) == 1);
1498
+
1499
+ return result;
1500
+ }
1501
+
1502
+ #if PYTHON_VERSION >= 0x300
1503
+ static void formatErrorNoArgumentAllowedKwSplit(struct Nuitka_FunctionObject const *function, PyObject *kw_name,
1504
+ Py_ssize_t given) {
1505
+ #if PYTHON_VERSION < 0x3a0
1506
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1507
+ #else
1508
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1509
+ #endif
1510
+
1511
+ PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%s'", function_name,
1512
+ Nuitka_String_AsString(kw_name));
1513
+ }
1514
+ #endif
1515
+
1516
+ static void formatErrorNoArgumentAllowed(struct Nuitka_FunctionObject const *function,
1517
+ #if PYTHON_VERSION >= 0x300
1518
+ PyObject *kw,
1519
+ #endif
1520
+ Py_ssize_t given) {
1521
+ #if PYTHON_VERSION < 0x3a0
1522
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1523
+ #else
1524
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1525
+ #endif
1526
+
1527
+ #if PYTHON_VERSION < 0x300
1528
+ PyErr_Format(PyExc_TypeError, "%s() takes no arguments (%zd given)", function_name, given);
1529
+ #else
1530
+ if (kw == NULL) {
1531
+ PyErr_Format(PyExc_TypeError, "%s() takes 0 positional arguments but %zd was given", function_name, given);
1532
+ } else {
1533
+ PyObject *tmp_iter = PyObject_GetIter(kw);
1534
+ PyObject *tmp_arg_name = PyIter_Next(tmp_iter);
1535
+ Py_DECREF(tmp_iter);
1536
+
1537
+ PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%s'", function_name,
1538
+ Nuitka_String_AsString(tmp_arg_name));
1539
+
1540
+ Py_DECREF(tmp_arg_name);
1541
+ }
1542
+ #endif
1543
+ }
1544
+
1545
+ static void formatErrorMultipleValuesGiven(struct Nuitka_FunctionObject const *function, Py_ssize_t index) {
1546
+ #if PYTHON_VERSION < 0x390
1547
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1548
+ #else
1549
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1550
+ #endif
1551
+
1552
+ PyErr_Format(PyExc_TypeError,
1553
+ #if PYTHON_VERSION < 0x300
1554
+ "%s() got multiple values for keyword argument '%s'",
1555
+ #else
1556
+ "%s() got multiple values for argument '%s'",
1557
+ #endif
1558
+ function_name, Nuitka_String_AsString(function->m_varnames[index]));
1559
+ }
1560
+
1561
+ #if PYTHON_VERSION < 0x300
1562
+ static void formatErrorTooFewArguments(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1563
+ #if PYTHON_VERSION < 0x270
1564
+ Py_ssize_t kw_size,
1565
+ #endif
1566
+ Py_ssize_t given) {
1567
+ Py_ssize_t required_parameter_count = function->m_args_positional_count - function->m_defaults_given;
1568
+
1569
+ #if PYTHON_VERSION < 0x390
1570
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1571
+ #else
1572
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1573
+ #endif
1574
+ char const *violation =
1575
+ (function->m_defaults != Py_None || function->m_args_star_list_index != -1) ? "at least" : "exactly";
1576
+ char const *plural = required_parameter_count == 1 ? "" : "s";
1577
+
1578
+ #if PYTHON_VERSION < 0x270
1579
+ if (kw_size > 0) {
1580
+ PyErr_Format(PyExc_TypeError, "%s() takes %s %zd non-keyword argument%s (%zd given)", function_name, violation,
1581
+ required_parameter_count, plural, given - function->m_defaults_given);
1582
+ } else {
1583
+ PyErr_Format(PyExc_TypeError, "%s() takes %s %zd argument%s (%zd given)", function_name, violation,
1584
+ required_parameter_count, plural, given);
1585
+ }
1586
+ #else
1587
+ PyErr_Format(PyExc_TypeError, "%s() takes %s %zd argument%s (%zd given)", function_name, violation,
1588
+ required_parameter_count, plural, given);
1589
+ #endif
1590
+ }
1591
+ #else
1592
+ static void formatErrorTooFewArguments(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1593
+ PyObject **values) {
1594
+ #if PYTHON_VERSION < 0x3a0
1595
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1596
+ #else
1597
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1598
+ #endif
1599
+
1600
+ Py_ssize_t max_missing = 0;
1601
+
1602
+ for (Py_ssize_t i = function->m_args_positional_count - 1 - function->m_defaults_given; i >= 0; --i) {
1603
+ if (values[i] == NULL) {
1604
+ max_missing += 1;
1605
+ }
1606
+ }
1607
+
1608
+ PyObject *list_str = PyUnicode_FromString("");
1609
+
1610
+ PyObject *comma_str = PyUnicode_FromString(", ");
1611
+ PyObject *and_str = PyUnicode_FromString(max_missing == 2 ? " and " : ", and ");
1612
+
1613
+ Py_ssize_t missing = 0;
1614
+ for (Py_ssize_t i = function->m_args_positional_count - 1 - function->m_defaults_given; i >= 0; --i) {
1615
+ if (values[i] == NULL) {
1616
+ PyObject *current_str = function->m_varnames[i];
1617
+
1618
+ PyObject *current = PyObject_Repr(current_str);
1619
+
1620
+ if (missing == 0) {
1621
+ PyObject *old = list_str;
1622
+
1623
+ list_str = UNICODE_CONCAT(tstate, list_str, current);
1624
+
1625
+ Py_DECREF(old);
1626
+ } else if (missing == 1) {
1627
+ PyObject *old = list_str;
1628
+
1629
+ list_str = UNICODE_CONCAT(tstate, and_str, list_str);
1630
+
1631
+ Py_DECREF(old);
1632
+ old = list_str;
1633
+
1634
+ list_str = UNICODE_CONCAT(tstate, current, list_str);
1635
+
1636
+ Py_DECREF(old);
1637
+ } else {
1638
+ PyObject *old = list_str;
1639
+
1640
+ list_str = UNICODE_CONCAT(tstate, comma_str, list_str);
1641
+
1642
+ Py_DECREF(old);
1643
+ old = list_str;
1644
+
1645
+ list_str = UNICODE_CONCAT(tstate, current, list_str);
1646
+
1647
+ Py_DECREF(old);
1648
+ }
1649
+
1650
+ Py_DECREF(current);
1651
+
1652
+ missing += 1;
1653
+ }
1654
+ }
1655
+
1656
+ Py_DECREF(comma_str);
1657
+ Py_DECREF(and_str);
1658
+
1659
+ PyErr_Format(PyExc_TypeError, "%s() missing %zd required positional argument%s: %s", function_name, max_missing,
1660
+ max_missing > 1 ? "s" : "", Nuitka_String_AsString(list_str));
1661
+
1662
+ Py_DECREF(list_str);
1663
+ }
1664
+ #endif
1665
+
1666
+ static void formatErrorTooManyArguments(struct Nuitka_FunctionObject const *function, Py_ssize_t given
1667
+ #if PYTHON_VERSION < 0x270
1668
+ ,
1669
+ Py_ssize_t kw_size
1670
+
1671
+ #endif
1672
+ #if PYTHON_VERSION >= 0x300
1673
+ ,
1674
+ Py_ssize_t kw_only
1675
+ #endif
1676
+ ) {
1677
+ Py_ssize_t top_level_parameter_count = function->m_args_positional_count;
1678
+
1679
+ #if PYTHON_VERSION < 0x3a0
1680
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1681
+ #else
1682
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1683
+ #endif
1684
+
1685
+ #if PYTHON_VERSION < 0x300
1686
+ char const *violation = function->m_defaults != Py_None ? "at most" : "exactly";
1687
+ #endif
1688
+ char const *plural = top_level_parameter_count == 1 ? "" : "s";
1689
+
1690
+ #if PYTHON_VERSION < 0x270
1691
+ PyErr_Format(PyExc_TypeError, "%s() takes %s %zd%s argument%s (%zd given)", function_name, violation,
1692
+ top_level_parameter_count, kw_size > 0 ? " non-keyword" : "", plural, given);
1693
+ #elif PYTHON_VERSION < 0x300
1694
+ PyErr_Format(PyExc_TypeError, "%s() takes %s %zd argument%s (%zd given)", function_name, violation,
1695
+ top_level_parameter_count, plural, given);
1696
+ #else
1697
+ char keyword_only_part[100];
1698
+
1699
+ if (kw_only > 0) {
1700
+ snprintf(keyword_only_part, sizeof(keyword_only_part) - 1,
1701
+ " positional argument%s (and %" PY_FORMAT_SIZE_T "d keyword-only argument%s)", given != 1 ? "s" : "",
1702
+ kw_only, kw_only != 1 ? "s" : "");
1703
+ } else {
1704
+ keyword_only_part[0] = 0;
1705
+ }
1706
+
1707
+ if (function->m_defaults_given == 0) {
1708
+ PyErr_Format(PyExc_TypeError, "%s() takes %zd positional argument%s but %zd%s were given", function_name,
1709
+ top_level_parameter_count, plural, given, keyword_only_part);
1710
+ } else {
1711
+ PyErr_Format(PyExc_TypeError, "%s() takes from %zd to %zd positional argument%s but %zd%s were given",
1712
+ function_name, top_level_parameter_count - function->m_defaults_given, top_level_parameter_count,
1713
+ plural, given, keyword_only_part);
1714
+ }
1715
+ #endif
1716
+ }
1717
+
1718
+ #if PYTHON_VERSION >= 0x300
1719
+ static void formatErrorTooFewKwOnlyArguments(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1720
+ PyObject **kw_vars) {
1721
+ #if PYTHON_VERSION < 0x3a0
1722
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1723
+ #else
1724
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1725
+ #endif
1726
+
1727
+ Py_ssize_t co_kwonlyargcount = function->m_code_object->co_kwonlyargcount;
1728
+
1729
+ Py_ssize_t max_missing = 0;
1730
+
1731
+ for (Py_ssize_t i = co_kwonlyargcount - 1; i >= 0; --i) {
1732
+ if (kw_vars[i] == NULL) {
1733
+ max_missing += 1;
1734
+ }
1735
+ }
1736
+
1737
+ PyObject *list_str = PyUnicode_FromString("");
1738
+
1739
+ PyObject *comma_str = PyUnicode_FromString(", ");
1740
+ PyObject *and_str = PyUnicode_FromString(max_missing == 2 ? " and " : ", and ");
1741
+
1742
+ Py_ssize_t missing = 0;
1743
+ for (Py_ssize_t i = co_kwonlyargcount - 1; i >= 0; --i) {
1744
+ if (kw_vars[i] == NULL) {
1745
+ PyObject *current_str = function->m_varnames[function->m_args_positional_count + i];
1746
+
1747
+ PyObject *current = PyObject_Repr(current_str);
1748
+
1749
+ if (missing == 0) {
1750
+ PyObject *old = list_str;
1751
+
1752
+ list_str = UNICODE_CONCAT(tstate, list_str, current);
1753
+
1754
+ if (unlikely(list_str == NULL)) {
1755
+ list_str = old;
1756
+ break;
1757
+ }
1758
+
1759
+ Py_DECREF(old);
1760
+ } else if (missing == 1) {
1761
+ PyObject *old = list_str;
1762
+
1763
+ list_str = UNICODE_CONCAT(tstate, and_str, list_str);
1764
+
1765
+ if (unlikely(list_str == NULL)) {
1766
+ list_str = old;
1767
+ break;
1768
+ }
1769
+
1770
+ Py_DECREF(old);
1771
+ old = list_str;
1772
+
1773
+ list_str = UNICODE_CONCAT(tstate, current, list_str);
1774
+
1775
+ if (unlikely(list_str == NULL)) {
1776
+ list_str = old;
1777
+ break;
1778
+ }
1779
+
1780
+ Py_DECREF(old);
1781
+ } else {
1782
+ PyObject *old = list_str;
1783
+
1784
+ list_str = UNICODE_CONCAT(tstate, comma_str, list_str);
1785
+
1786
+ if (unlikely(list_str == NULL)) {
1787
+ list_str = old;
1788
+ break;
1789
+ }
1790
+
1791
+ Py_DECREF(old);
1792
+ old = list_str;
1793
+
1794
+ list_str = UNICODE_CONCAT(tstate, current, list_str);
1795
+
1796
+ if (unlikely(list_str == NULL)) {
1797
+ list_str = old;
1798
+ break;
1799
+ }
1800
+
1801
+ Py_DECREF(old);
1802
+ }
1803
+
1804
+ Py_DECREF(current);
1805
+
1806
+ missing += 1;
1807
+ }
1808
+ }
1809
+
1810
+ Py_DECREF(comma_str);
1811
+ Py_DECREF(and_str);
1812
+
1813
+ PyErr_Format(PyExc_TypeError, "%s() missing %zd required keyword-only argument%s: %s", function_name, max_missing,
1814
+ max_missing > 1 ? "s" : "", Nuitka_String_AsString(list_str));
1815
+
1816
+ Py_DECREF(list_str);
1817
+ }
1818
+ #endif
1819
+
1820
+ static void formatErrorKeywordsMustBeString(PyThreadState *tstate, struct Nuitka_FunctionObject const *function) {
1821
+ #if PYTHON_VERSION < 0x390
1822
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1823
+ SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() keywords must be strings", function_name);
1824
+ #else
1825
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "keywords must be strings");
1826
+ #endif
1827
+ }
1828
+
1829
+ static inline bool checkKeywordType(PyObject *arg_name) {
1830
+ #if PYTHON_VERSION < 0x300
1831
+ return (PyString_Check(arg_name) || PyUnicode_Check(arg_name));
1832
+ #else
1833
+ return PyUnicode_Check(arg_name) != 0;
1834
+ #endif
1835
+ }
1836
+
1837
+ static inline bool RICH_COMPARE_EQ_CBOOL_ARG_NAMES(PyObject *operand1, PyObject *operand2) {
1838
+ // Compare with argument name. We know our type, but from the outside, it
1839
+ // can be a derived type, or in case of Python2, a unicode value to compare
1840
+ // with a string. These half sided comparisons will make the switch to the
1841
+ // special one immediately if possible though.
1842
+
1843
+ #if PYTHON_VERSION < 0x300
1844
+ nuitka_bool result = RICH_COMPARE_EQ_NBOOL_STR_OBJECT(operand1, operand2);
1845
+ #else
1846
+ nuitka_bool result = RICH_COMPARE_EQ_NBOOL_UNICODE_OBJECT(operand1, operand2);
1847
+ #endif
1848
+
1849
+ // Should be close to impossible, we will have to ignore it though.
1850
+ if (unlikely(result == NUITKA_BOOL_EXCEPTION)) {
1851
+ PyThreadState *tstate = PyThreadState_GET();
1852
+
1853
+ CLEAR_ERROR_OCCURRED(tstate);
1854
+ return false;
1855
+ }
1856
+
1857
+ return result == NUITKA_BOOL_TRUE;
1858
+ }
1859
+
1860
+ #if PYTHON_VERSION < 0x300
1861
+ static Py_ssize_t handleKeywordArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1862
+ PyObject **python_pars, PyObject *kw)
1863
+ #else
1864
+ static Py_ssize_t handleKeywordArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
1865
+ PyObject **python_pars, Py_ssize_t *kw_only_found, PyObject *kw)
1866
+ #endif
1867
+ {
1868
+ Py_ssize_t keywords_count = function->m_args_keywords_count;
1869
+
1870
+ #if PYTHON_VERSION >= 0x300
1871
+ Py_ssize_t keyword_after_index = function->m_args_positional_count;
1872
+ #endif
1873
+
1874
+ assert(function->m_args_star_dict_index == -1);
1875
+
1876
+ Py_ssize_t kw_found = 0;
1877
+ Py_ssize_t pos = 0;
1878
+ PyObject *key, *value;
1879
+
1880
+ while (Nuitka_DictNext(kw, &pos, &key, &value)) {
1881
+ if (unlikely(!checkKeywordType(key))) {
1882
+ formatErrorKeywordsMustBeString(tstate, function);
1883
+ return -1;
1884
+ }
1885
+
1886
+ NUITKA_MAY_BE_UNUSED bool found = false;
1887
+
1888
+ Py_INCREF(key);
1889
+ Py_INCREF(value);
1890
+
1891
+ #if PYTHON_VERSION < 0x380
1892
+ Py_ssize_t kw_arg_start = 0;
1893
+ #else
1894
+ Py_ssize_t kw_arg_start = function->m_args_pos_only_count;
1895
+ #endif
1896
+
1897
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
1898
+ if (function->m_varnames[i] == key) {
1899
+ assert(python_pars[i] == NULL);
1900
+ python_pars[i] = value;
1901
+
1902
+ #if PYTHON_VERSION >= 0x300
1903
+ if (i >= keyword_after_index) {
1904
+ *kw_only_found += 1;
1905
+ }
1906
+ #endif
1907
+
1908
+ found = true;
1909
+ break;
1910
+ }
1911
+ }
1912
+
1913
+ if (found == false) {
1914
+ PyObject **var_names = function->m_varnames;
1915
+
1916
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
1917
+ if (RICH_COMPARE_EQ_CBOOL_ARG_NAMES(var_names[i], key)) {
1918
+ assert(python_pars[i] == NULL);
1919
+ python_pars[i] = value;
1920
+
1921
+ #if PYTHON_VERSION >= 0x300
1922
+ if (i >= keyword_after_index) {
1923
+ *kw_only_found += 1;
1924
+ }
1925
+ #endif
1926
+
1927
+ found = true;
1928
+ break;
1929
+ }
1930
+ }
1931
+ }
1932
+
1933
+ if (unlikely(found == false)) {
1934
+ bool pos_only_error = false;
1935
+
1936
+ for (Py_ssize_t i = 0; i < kw_arg_start; i++) {
1937
+ PyObject **var_names = function->m_varnames;
1938
+
1939
+ if (RICH_COMPARE_EQ_CBOOL_ARG_NAMES(var_names[i], key)) {
1940
+ pos_only_error = true;
1941
+ break;
1942
+ }
1943
+ }
1944
+
1945
+ #if PYTHON_VERSION < 0x3a0
1946
+ char const *function_name = Nuitka_String_AsString(function->m_name);
1947
+ #else
1948
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
1949
+ #endif
1950
+
1951
+ if (pos_only_error == true) {
1952
+ PyErr_Format(PyExc_TypeError,
1953
+ "%s() got some positional-only arguments passed as keyword arguments: '%s'", function_name,
1954
+ Nuitka_String_Check(key) ? Nuitka_String_AsString(key) : "<non-string>");
1955
+
1956
+ } else {
1957
+ PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%s'", function_name,
1958
+ Nuitka_String_Check(key) ? Nuitka_String_AsString(key) : "<non-string>");
1959
+ }
1960
+
1961
+ Py_DECREF(key);
1962
+ Py_DECREF(value);
1963
+
1964
+ return -1;
1965
+ }
1966
+
1967
+ Py_DECREF(key);
1968
+
1969
+ kw_found += 1;
1970
+ }
1971
+
1972
+ return kw_found;
1973
+ }
1974
+
1975
+ #if PYTHON_VERSION < 0x300
1976
+ static Py_ssize_t handleKeywordArgsSplit(struct Nuitka_FunctionObject const *function, PyObject **python_pars,
1977
+ PyObject *const *kw_values, PyObject *kw_names)
1978
+ #else
1979
+ static Py_ssize_t handleKeywordArgsSplit(struct Nuitka_FunctionObject const *function, PyObject **python_pars,
1980
+ Py_ssize_t *kw_only_found, PyObject *const *kw_values, PyObject *kw_names)
1981
+ #endif
1982
+ {
1983
+ Py_ssize_t keywords_count = function->m_args_keywords_count;
1984
+
1985
+ #if PYTHON_VERSION >= 0x300
1986
+ Py_ssize_t keyword_after_index = function->m_args_positional_count;
1987
+ #endif
1988
+
1989
+ assert(function->m_args_star_dict_index == -1);
1990
+
1991
+ Py_ssize_t kw_found = 0;
1992
+
1993
+ Py_ssize_t kw_names_size = PyTuple_GET_SIZE(kw_names);
1994
+
1995
+ for (Py_ssize_t kw_index = 0; kw_index < kw_names_size; kw_index++) {
1996
+ PyObject *key = PyTuple_GET_ITEM(kw_names, kw_index);
1997
+ PyObject *value = kw_values[kw_index];
1998
+
1999
+ assert(checkKeywordType(key));
2000
+
2001
+ NUITKA_MAY_BE_UNUSED bool found = false;
2002
+
2003
+ #if PYTHON_VERSION < 0x380
2004
+ Py_ssize_t kw_arg_start = 0;
2005
+ #else
2006
+ Py_ssize_t kw_arg_start = function->m_args_pos_only_count;
2007
+ #endif
2008
+
2009
+ Py_INCREF(value);
2010
+
2011
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
2012
+ if (function->m_varnames[i] == key) {
2013
+ assert(python_pars[i] == NULL);
2014
+ python_pars[i] = value;
2015
+
2016
+ #if PYTHON_VERSION >= 0x300
2017
+ if (i >= keyword_after_index) {
2018
+ *kw_only_found += 1;
2019
+ }
2020
+ #endif
2021
+
2022
+ found = true;
2023
+ break;
2024
+ }
2025
+ }
2026
+
2027
+ if (found == false) {
2028
+ PyObject **var_names = function->m_varnames;
2029
+
2030
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
2031
+ // TODO: Could do better here, STR/UNICODE key knowledge being there.
2032
+ if (RICH_COMPARE_EQ_CBOOL_ARG_NAMES(var_names[i], key)) {
2033
+ assert(python_pars[i] == NULL);
2034
+ python_pars[i] = value;
2035
+
2036
+ #if PYTHON_VERSION >= 0x300
2037
+ if (i >= keyword_after_index) {
2038
+ *kw_only_found += 1;
2039
+ }
2040
+ #endif
2041
+
2042
+ found = true;
2043
+ break;
2044
+ }
2045
+ }
2046
+ }
2047
+
2048
+ if (unlikely(found == false)) {
2049
+ bool pos_only_error = false;
2050
+
2051
+ for (Py_ssize_t i = 0; i < kw_arg_start; i++) {
2052
+ PyObject **var_names = function->m_varnames;
2053
+
2054
+ if (RICH_COMPARE_EQ_CBOOL_ARG_NAMES(var_names[i], key)) {
2055
+ pos_only_error = true;
2056
+ break;
2057
+ }
2058
+ }
2059
+
2060
+ #if PYTHON_VERSION < 0x3a0
2061
+ char const *function_name = Nuitka_String_AsString(function->m_name);
2062
+ #else
2063
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
2064
+ #endif
2065
+
2066
+ if (pos_only_error == true) {
2067
+ PyErr_Format(PyExc_TypeError,
2068
+ "%s() got some positional-only arguments passed as keyword arguments: '%s'", function_name,
2069
+ Nuitka_String_Check(key) ? Nuitka_String_AsString(key) : "<non-string>");
2070
+
2071
+ } else {
2072
+ PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%s'", function_name,
2073
+ Nuitka_String_Check(key) ? Nuitka_String_AsString(key) : "<non-string>");
2074
+ }
2075
+
2076
+ Py_DECREF(value);
2077
+
2078
+ return -1;
2079
+ }
2080
+
2081
+ kw_found += 1;
2082
+ }
2083
+
2084
+ return kw_found;
2085
+ }
2086
+
2087
+ static PyObject *COPY_DICT_KW(PyThreadState *tstate, PyObject *dict_value);
2088
+
2089
+ static bool MAKE_STAR_DICT_DICTIONARY_COPY(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2090
+ PyObject **python_pars, PyObject *kw) {
2091
+ Py_ssize_t star_dict_index = function->m_args_star_dict_index;
2092
+ assert(star_dict_index != -1);
2093
+
2094
+ if (kw == NULL || ((PyDictObject *)kw)->ma_used == 0) {
2095
+ python_pars[star_dict_index] = MAKE_DICT_EMPTY(tstate);
2096
+ } else {
2097
+ python_pars[star_dict_index] = COPY_DICT_KW(tstate, kw);
2098
+
2099
+ if (unlikely(python_pars[star_dict_index] == NULL)) {
2100
+ formatErrorKeywordsMustBeString(tstate, function);
2101
+ return false;
2102
+ }
2103
+ }
2104
+
2105
+ return true;
2106
+ }
2107
+
2108
+ #if PYTHON_VERSION < 0x300
2109
+ static Py_ssize_t handleKeywordArgsWithStarDict(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2110
+ PyObject **python_pars, PyObject *kw)
2111
+ #else
2112
+ static Py_ssize_t handleKeywordArgsWithStarDict(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2113
+ PyObject **python_pars, Py_ssize_t *kw_only_found, PyObject *kw)
2114
+ #endif
2115
+ {
2116
+ assert(function->m_args_star_dict_index != -1);
2117
+
2118
+ if (unlikely(MAKE_STAR_DICT_DICTIONARY_COPY(tstate, function, python_pars, kw) == false)) {
2119
+ return -1;
2120
+ }
2121
+
2122
+ Py_ssize_t kw_found = 0;
2123
+ Py_ssize_t keywords_count = function->m_args_keywords_count;
2124
+ #if PYTHON_VERSION >= 0x300
2125
+ Py_ssize_t keyword_after_index = function->m_args_positional_count;
2126
+ #endif
2127
+
2128
+ Py_ssize_t star_dict_index = function->m_args_star_dict_index;
2129
+
2130
+ PyObject **var_names = function->m_varnames;
2131
+
2132
+ #if PYTHON_VERSION < 0x380
2133
+ Py_ssize_t kw_arg_start = 0;
2134
+ #else
2135
+ Py_ssize_t kw_arg_start = function->m_args_pos_only_count;
2136
+ #endif
2137
+
2138
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
2139
+ PyObject *arg_name = var_names[i];
2140
+
2141
+ PyObject *kw_arg_value = DICT_GET_ITEM1(tstate, python_pars[star_dict_index], arg_name);
2142
+
2143
+ if (kw_arg_value != NULL) {
2144
+ assert(python_pars[i] == NULL);
2145
+
2146
+ python_pars[i] = kw_arg_value;
2147
+
2148
+ DICT_REMOVE_ITEM(python_pars[star_dict_index], arg_name);
2149
+
2150
+ kw_found += 1;
2151
+
2152
+ #if PYTHON_VERSION >= 0x300
2153
+ if (i >= keyword_after_index) {
2154
+ *kw_only_found += 1;
2155
+ }
2156
+ #endif
2157
+ }
2158
+ }
2159
+
2160
+ return kw_found;
2161
+ }
2162
+
2163
+ #if PYTHON_VERSION < 0x300
2164
+ static Py_ssize_t
2165
+ handleKeywordArgsSplitWithStarDict(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2166
+ PyObject **python_pars, PyObject *const *kw_values, PyObject *kw_names)
2167
+ #else
2168
+ static Py_ssize_t handleKeywordArgsSplitWithStarDict(PyThreadState *tstate,
2169
+ struct Nuitka_FunctionObject const *function,
2170
+ PyObject **python_pars, Py_ssize_t *kw_only_found,
2171
+ PyObject *const *kw_values, PyObject *kw_names)
2172
+ #endif
2173
+ {
2174
+
2175
+ Py_ssize_t star_dict_index = function->m_args_star_dict_index;
2176
+ assert(star_dict_index != -1);
2177
+
2178
+ Py_ssize_t kw_names_size = PyTuple_GET_SIZE(kw_names);
2179
+
2180
+ python_pars[star_dict_index] = _PyDict_NewPresized(kw_names_size);
2181
+
2182
+ for (Py_ssize_t i = 0; i < kw_names_size; i++) {
2183
+ PyObject *key = PyTuple_GET_ITEM(kw_names, i);
2184
+ PyObject *value = kw_values[i];
2185
+
2186
+ DICT_SET_ITEM(python_pars[star_dict_index], key, value);
2187
+ }
2188
+
2189
+ Py_ssize_t kw_found = 0;
2190
+ Py_ssize_t keywords_count = function->m_args_keywords_count;
2191
+ #if PYTHON_VERSION >= 0x300
2192
+ Py_ssize_t keyword_after_index = function->m_args_positional_count;
2193
+ #endif
2194
+
2195
+ PyObject **var_names = function->m_varnames;
2196
+
2197
+ #if PYTHON_VERSION < 0x380
2198
+ Py_ssize_t kw_arg_start = 0;
2199
+ #else
2200
+ Py_ssize_t kw_arg_start = function->m_args_pos_only_count;
2201
+ #endif
2202
+
2203
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
2204
+ PyObject *arg_name = var_names[i];
2205
+
2206
+ PyObject *kw_arg_value = DICT_GET_ITEM1(tstate, python_pars[star_dict_index], arg_name);
2207
+
2208
+ if (kw_arg_value != NULL) {
2209
+ assert(python_pars[i] == NULL);
2210
+
2211
+ python_pars[i] = kw_arg_value;
2212
+
2213
+ DICT_REMOVE_ITEM(python_pars[star_dict_index], arg_name);
2214
+
2215
+ kw_found += 1;
2216
+
2217
+ #if PYTHON_VERSION >= 0x300
2218
+ if (i >= keyword_after_index) {
2219
+ *kw_only_found += 1;
2220
+ }
2221
+ #endif
2222
+ }
2223
+ }
2224
+
2225
+ return kw_found;
2226
+ }
2227
+
2228
+ static void makeStarListTupleCopy(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2229
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size) {
2230
+ assert(function->m_args_star_list_index != -1);
2231
+ Py_ssize_t list_star_index = function->m_args_star_list_index;
2232
+
2233
+ // Copy left-over argument values to the star list parameter given.
2234
+ if (args_size > function->m_args_positional_count) {
2235
+ python_pars[list_star_index] =
2236
+ MAKE_TUPLE(tstate, &args[function->m_args_positional_count], args_size - function->m_args_positional_count);
2237
+ } else {
2238
+ python_pars[list_star_index] = const_tuple_empty;
2239
+ Py_INCREF(const_tuple_empty);
2240
+ }
2241
+ }
2242
+
2243
+ static void makeStarListTupleCopyMethod(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2244
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size) {
2245
+ assert(function->m_args_star_list_index != -1);
2246
+ Py_ssize_t list_star_index = function->m_args_star_list_index;
2247
+
2248
+ // Copy left-over argument values to the star list parameter given.
2249
+ if (args_size + 1 > function->m_args_positional_count) {
2250
+ python_pars[list_star_index] = MAKE_TUPLE(tstate, &args[function->m_args_positional_count - 1],
2251
+ args_size + 1 - function->m_args_positional_count);
2252
+ } else {
2253
+ python_pars[list_star_index] = const_tuple_empty;
2254
+ Py_INCREF(const_tuple_empty);
2255
+ }
2256
+ }
2257
+
2258
+ static bool _handleArgumentsPlainOnly(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2259
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size) {
2260
+ Py_ssize_t arg_count = function->m_args_positional_count;
2261
+
2262
+ // Check if too many arguments were given in case of non list star arg.
2263
+ // For Python3 it's done only later, when more knowledge has
2264
+ // been gained.
2265
+ #if PYTHON_VERSION < 0x300
2266
+ if (function->m_args_star_list_index == -1) {
2267
+ if (unlikely(args_size > arg_count)) {
2268
+ #if PYTHON_VERSION < 0x270
2269
+ formatErrorTooManyArguments(function, args_size, 0);
2270
+ #else
2271
+ formatErrorTooManyArguments(function, args_size);
2272
+ #endif
2273
+ return false;
2274
+ }
2275
+ }
2276
+ #endif
2277
+
2278
+ #if PYTHON_VERSION >= 0x300
2279
+ bool parameter_error = false;
2280
+ #endif
2281
+
2282
+ Py_ssize_t defaults_given = function->m_defaults_given;
2283
+
2284
+ if (args_size + defaults_given < arg_count) {
2285
+ #if PYTHON_VERSION < 0x270
2286
+ formatErrorTooFewArguments(tstate, function, 0, args_size);
2287
+ return false;
2288
+ #elif PYTHON_VERSION < 0x300
2289
+ formatErrorTooFewArguments(tstate, function, args_size);
2290
+ return false;
2291
+ #else
2292
+ parameter_error = true;
2293
+ #endif
2294
+ }
2295
+
2296
+ for (Py_ssize_t i = 0; i < args_size; i++) {
2297
+ if (i >= arg_count)
2298
+ break;
2299
+
2300
+ assert(python_pars[i] == NULL);
2301
+
2302
+ python_pars[i] = args[i];
2303
+ Py_INCREF(python_pars[i]);
2304
+ }
2305
+
2306
+ #if PYTHON_VERSION >= 0x300
2307
+ if (parameter_error == false) {
2308
+ #endif
2309
+ PyObject *source = function->m_defaults;
2310
+
2311
+ for (Py_ssize_t i = args_size; i < arg_count; i++) {
2312
+ assert(python_pars[i] == NULL);
2313
+ assert(i + defaults_given >= arg_count);
2314
+
2315
+ python_pars[i] = PyTuple_GET_ITEM(source, defaults_given + i - arg_count);
2316
+ Py_INCREF(python_pars[i]);
2317
+ }
2318
+ #if PYTHON_VERSION >= 0x300
2319
+ }
2320
+ #endif
2321
+
2322
+ #if PYTHON_VERSION >= 0x300
2323
+ if (unlikely(parameter_error)) {
2324
+ formatErrorTooFewArguments(tstate, function, python_pars);
2325
+ return false;
2326
+ }
2327
+
2328
+ if (function->m_args_star_list_index == -1) {
2329
+ // Check if too many arguments were given in case of non list star arg
2330
+ if (unlikely(args_size > arg_count)) {
2331
+ formatErrorTooManyArguments(function, args_size, 0);
2332
+ return false;
2333
+ }
2334
+ }
2335
+ #endif
2336
+
2337
+ if (function->m_args_star_list_index != -1) {
2338
+ makeStarListTupleCopy(tstate, function, python_pars, args, args_size);
2339
+ }
2340
+
2341
+ return true;
2342
+ }
2343
+
2344
+ static bool handleMethodArgumentsPlainOnly(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2345
+ PyObject **python_pars, PyObject *object, PyObject *const *args,
2346
+ Py_ssize_t args_size) {
2347
+ Py_ssize_t arg_count = function->m_args_positional_count;
2348
+
2349
+ // There may be no self, otherwise we can directly assign it.
2350
+ if (arg_count >= 1) {
2351
+ python_pars[0] = object;
2352
+ Py_INCREF(object);
2353
+ } else {
2354
+ // Without self, there can only be star list to get the object as its
2355
+ // first element. Or we complain about illegal arguments.
2356
+ if (function->m_args_star_list_index == 0) {
2357
+ python_pars[0] = MAKE_TUPLE_EMPTY(tstate, args_size + 1);
2358
+ PyTuple_SET_ITEM0(python_pars[0], 0, object);
2359
+
2360
+ for (Py_ssize_t i = 0; i < args_size; i++) {
2361
+ PyTuple_SET_ITEM0(python_pars[0], i + 1, args[i]);
2362
+ }
2363
+
2364
+ return true;
2365
+ }
2366
+ }
2367
+
2368
+ // Check if too many arguments were given in case of non list star arg.
2369
+ // For Python3 it's done only later, when more knowledge has
2370
+ // been gained.
2371
+ #if PYTHON_VERSION < 0x300
2372
+ if (function->m_args_star_list_index == -1) {
2373
+ if (unlikely(args_size + 1 > arg_count)) {
2374
+ #if PYTHON_VERSION < 0x270
2375
+ formatErrorTooManyArguments(function, args_size + 1, 0);
2376
+ #else
2377
+ formatErrorTooManyArguments(function, args_size + 1);
2378
+ #endif
2379
+ return false;
2380
+ }
2381
+ }
2382
+ #endif
2383
+
2384
+ #if PYTHON_VERSION >= 0x300
2385
+ bool parameter_error = false;
2386
+ #endif
2387
+ Py_ssize_t defaults_given = function->m_defaults_given;
2388
+
2389
+ if (args_size + 1 + defaults_given < arg_count) {
2390
+ #if PYTHON_VERSION < 0x270
2391
+ formatErrorTooFewArguments(tstate, function, 0, args_size + 1);
2392
+ return false;
2393
+ #elif PYTHON_VERSION < 0x300
2394
+ formatErrorTooFewArguments(tstate, function, args_size + 1);
2395
+ return false;
2396
+ #else
2397
+ parameter_error = true;
2398
+ #endif
2399
+ }
2400
+
2401
+ for (Py_ssize_t i = 0; i < args_size; i++) {
2402
+ if (i + 1 >= arg_count)
2403
+ break;
2404
+
2405
+ assert(python_pars[i + 1] == NULL);
2406
+
2407
+ python_pars[i + 1] = args[i];
2408
+ Py_INCREF(python_pars[i + 1]);
2409
+ }
2410
+
2411
+ #if PYTHON_VERSION >= 0x300
2412
+ if (parameter_error == false) {
2413
+ #endif
2414
+ for (Py_ssize_t i = args_size + 1; i < arg_count; i++) {
2415
+ assert(python_pars[i] == NULL);
2416
+ assert(i + defaults_given >= arg_count);
2417
+
2418
+ python_pars[i] = PyTuple_GET_ITEM(function->m_defaults, defaults_given + i - arg_count);
2419
+ Py_INCREF(python_pars[i]);
2420
+ }
2421
+ #if PYTHON_VERSION >= 0x300
2422
+ }
2423
+ #endif
2424
+
2425
+ #if PYTHON_VERSION >= 0x300
2426
+ if (unlikely(parameter_error)) {
2427
+ formatErrorTooFewArguments(tstate, function, python_pars);
2428
+ return false;
2429
+ }
2430
+
2431
+ if (function->m_args_star_list_index == -1) {
2432
+ // Check if too many arguments were given in case of non list star arg
2433
+ if (unlikely(args_size + 1 > arg_count)) {
2434
+ formatErrorTooManyArguments(function, args_size + 1, 0);
2435
+ return false;
2436
+ }
2437
+ }
2438
+ #endif
2439
+
2440
+ if (function->m_args_star_list_index != -1) {
2441
+ makeStarListTupleCopyMethod(tstate, function, python_pars, args, args_size);
2442
+ }
2443
+
2444
+ return true;
2445
+ }
2446
+
2447
+ #if PYTHON_VERSION < 0x270
2448
+ static bool _handleArgumentsPlain(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2449
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size,
2450
+ Py_ssize_t kw_found, Py_ssize_t kw_size)
2451
+ #elif PYTHON_VERSION < 0x300
2452
+ static bool _handleArgumentsPlain(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2453
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size,
2454
+ Py_ssize_t kw_found)
2455
+ #else
2456
+ static bool _handleArgumentsPlain(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2457
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size,
2458
+ Py_ssize_t kw_found, Py_ssize_t kw_only_found)
2459
+ #endif
2460
+ {
2461
+ Py_ssize_t arg_count = function->m_args_positional_count;
2462
+
2463
+ // Check if too many arguments were given in case of non list star arg.
2464
+ // For Python3 it's done only later, when more knowledge has
2465
+ // been gained.
2466
+ #if PYTHON_VERSION < 0x300
2467
+ if (function->m_args_star_list_index == -1) {
2468
+ if (unlikely(args_size > arg_count)) {
2469
+ #if PYTHON_VERSION < 0x270
2470
+ formatErrorTooManyArguments(function, args_size, kw_size);
2471
+ #else
2472
+ formatErrorTooManyArguments(function, args_size + kw_found);
2473
+ #endif
2474
+ return false;
2475
+ }
2476
+ }
2477
+ #endif
2478
+
2479
+ #if PYTHON_VERSION >= 0x300
2480
+ bool parameter_error = false;
2481
+ #endif
2482
+
2483
+ if (kw_found > 0) {
2484
+ Py_ssize_t i;
2485
+ for (i = 0; i < (args_size < arg_count ? args_size : arg_count); i++) {
2486
+ if (unlikely(python_pars[i] != NULL)) {
2487
+ formatErrorMultipleValuesGiven(function, i);
2488
+ return false;
2489
+ }
2490
+
2491
+ python_pars[i] = args[i];
2492
+ Py_INCREF(python_pars[i]);
2493
+ }
2494
+
2495
+ Py_ssize_t defaults_given = function->m_defaults_given;
2496
+
2497
+ for (; i < arg_count; i++) {
2498
+ if (python_pars[i] == NULL) {
2499
+
2500
+ if (i + defaults_given >= arg_count) {
2501
+ python_pars[i] = PyTuple_GET_ITEM(function->m_defaults, defaults_given + i - arg_count);
2502
+ Py_INCREF(python_pars[i]);
2503
+ } else {
2504
+ #if PYTHON_VERSION < 0x270
2505
+ formatErrorTooFewArguments(tstate, function, kw_size, args_size + kw_found);
2506
+ return false;
2507
+ #elif PYTHON_VERSION < 0x300
2508
+ formatErrorTooFewArguments(tstate, function, args_size + kw_found);
2509
+ return false;
2510
+ #else
2511
+ parameter_error = true;
2512
+ #endif
2513
+ }
2514
+ }
2515
+ }
2516
+ } else {
2517
+ Py_ssize_t usable = (args_size < arg_count ? args_size : arg_count);
2518
+ Py_ssize_t defaults_given = function->m_defaults_given;
2519
+
2520
+ if (defaults_given < arg_count - usable) {
2521
+ #if PYTHON_VERSION < 0x270
2522
+ formatErrorTooFewArguments(tstate, function, kw_size, args_size + kw_found);
2523
+ return false;
2524
+ #elif PYTHON_VERSION < 0x300
2525
+ formatErrorTooFewArguments(tstate, function, args_size + kw_found);
2526
+ return false;
2527
+ #else
2528
+ parameter_error = true;
2529
+ #endif
2530
+ }
2531
+
2532
+ for (Py_ssize_t i = 0; i < usable; i++) {
2533
+ assert(python_pars[i] == NULL);
2534
+
2535
+ python_pars[i] = args[i];
2536
+ Py_INCREF(python_pars[i]);
2537
+ }
2538
+
2539
+ #if PYTHON_VERSION >= 0x300
2540
+ if (parameter_error == false) {
2541
+ #endif
2542
+ for (Py_ssize_t i = usable; i < arg_count; i++) {
2543
+ assert(python_pars[i] == NULL);
2544
+ assert(i + defaults_given >= arg_count);
2545
+
2546
+ python_pars[i] = PyTuple_GET_ITEM(function->m_defaults, defaults_given + i - arg_count);
2547
+ Py_INCREF(python_pars[i]);
2548
+ }
2549
+ #if PYTHON_VERSION >= 0x300
2550
+ }
2551
+ #endif
2552
+ }
2553
+
2554
+ #if PYTHON_VERSION >= 0x300
2555
+ if (unlikely(parameter_error)) {
2556
+ formatErrorTooFewArguments(tstate, function, python_pars);
2557
+ return false;
2558
+ }
2559
+
2560
+ if (function->m_args_star_list_index == -1) {
2561
+ // Check if too many arguments were given in case of non list star arg
2562
+ if (unlikely(args_size > arg_count)) {
2563
+ formatErrorTooManyArguments(function, args_size, kw_only_found);
2564
+ return false;
2565
+ }
2566
+ }
2567
+ #endif
2568
+
2569
+ if (function->m_args_star_list_index != -1) {
2570
+ makeStarListTupleCopy(tstate, function, python_pars, args, args_size);
2571
+ }
2572
+
2573
+ return true;
2574
+ }
2575
+
2576
+ // Release them all in case of an error.
2577
+ static void releaseParameters(struct Nuitka_FunctionObject const *function, PyObject *const *python_pars) {
2578
+ Py_ssize_t arg_count = function->m_args_overall_count;
2579
+
2580
+ for (Py_ssize_t i = 0; i < arg_count; i++) {
2581
+ Py_XDECREF(python_pars[i]);
2582
+ }
2583
+ }
2584
+
2585
+ static bool parseArgumentsPos(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2586
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size) {
2587
+ bool result;
2588
+
2589
+ Py_ssize_t arg_count = function->m_args_positional_count;
2590
+
2591
+ if (unlikely(arg_count == 0 && function->m_args_simple && args_size != 0)) {
2592
+ #if PYTHON_VERSION < 0x300
2593
+ formatErrorNoArgumentAllowed(function, args_size);
2594
+ #else
2595
+ formatErrorNoArgumentAllowed(function, NULL, args_size);
2596
+ #endif
2597
+
2598
+ releaseParameters(function, python_pars);
2599
+ return false;
2600
+ }
2601
+
2602
+ result = _handleArgumentsPlainOnly(tstate, function, python_pars, args, args_size);
2603
+
2604
+ if (result == false) {
2605
+ releaseParameters(function, python_pars);
2606
+ return false;
2607
+ }
2608
+
2609
+ #if PYTHON_VERSION >= 0x300
2610
+ // For Python3 the keyword only errors are all reported at once.
2611
+ bool kw_only_error = false;
2612
+
2613
+ for (Py_ssize_t i = function->m_args_positional_count; i < function->m_args_keywords_count; i++) {
2614
+ if (python_pars[i] == NULL) {
2615
+ PyObject *arg_name = function->m_varnames[i];
2616
+
2617
+ if (function->m_kwdefaults != NULL) {
2618
+ python_pars[i] = DICT_GET_ITEM1(tstate, function->m_kwdefaults, arg_name);
2619
+ }
2620
+
2621
+ if (unlikely(python_pars[i] == NULL)) {
2622
+ kw_only_error = true;
2623
+ }
2624
+ }
2625
+ }
2626
+
2627
+ if (unlikely(kw_only_error)) {
2628
+ formatErrorTooFewKwOnlyArguments(tstate, function, &python_pars[function->m_args_positional_count]);
2629
+
2630
+ releaseParameters(function, python_pars);
2631
+ return false;
2632
+ }
2633
+
2634
+ #endif
2635
+
2636
+ if (function->m_args_star_dict_index != -1) {
2637
+ python_pars[function->m_args_star_dict_index] = MAKE_DICT_EMPTY(tstate);
2638
+ }
2639
+
2640
+ return true;
2641
+ }
2642
+
2643
+ // We leave it to partial inlining to specialize this.
2644
+ static bool parseArgumentsEmpty(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2645
+ PyObject **python_pars) {
2646
+ return parseArgumentsPos(tstate, function, python_pars, NULL, 0);
2647
+ }
2648
+
2649
+ static bool parseArgumentsMethodPos(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2650
+ PyObject **python_pars, PyObject *object, PyObject *const *args,
2651
+ Py_ssize_t args_size) {
2652
+ bool result;
2653
+
2654
+ result = handleMethodArgumentsPlainOnly(tstate, function, python_pars, object, args, args_size);
2655
+
2656
+ if (result == false) {
2657
+ releaseParameters(function, python_pars);
2658
+ return false;
2659
+ }
2660
+
2661
+ #if PYTHON_VERSION >= 0x300
2662
+ // For Python3 the keyword only errors are all reported at once.
2663
+ bool kw_only_error = false;
2664
+
2665
+ for (Py_ssize_t i = function->m_args_positional_count; i < function->m_args_keywords_count; i++) {
2666
+ if (python_pars[i] == NULL) {
2667
+ PyObject *arg_name = function->m_varnames[i];
2668
+
2669
+ if (function->m_kwdefaults != NULL) {
2670
+ python_pars[i] = DICT_GET_ITEM1(tstate, function->m_kwdefaults, arg_name);
2671
+ }
2672
+
2673
+ if (unlikely(python_pars[i] == NULL)) {
2674
+ kw_only_error = true;
2675
+ }
2676
+ }
2677
+ }
2678
+
2679
+ if (unlikely(kw_only_error)) {
2680
+ formatErrorTooFewKwOnlyArguments(tstate, function, &python_pars[function->m_args_positional_count]);
2681
+
2682
+ releaseParameters(function, python_pars);
2683
+ return false;
2684
+ }
2685
+
2686
+ #endif
2687
+
2688
+ if (function->m_args_star_dict_index != -1) {
2689
+ python_pars[function->m_args_star_dict_index] = MAKE_DICT_EMPTY(tstate);
2690
+ }
2691
+
2692
+ return true;
2693
+ }
2694
+
2695
+ static bool parseArgumentsFullKwSplit(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2696
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size,
2697
+ PyObject *const *kw_values, PyObject *kw_names) {
2698
+ Py_ssize_t kw_size = PyTuple_GET_SIZE(kw_names);
2699
+ Py_ssize_t kw_found;
2700
+ bool result;
2701
+
2702
+ Py_ssize_t arg_count = function->m_args_keywords_count;
2703
+
2704
+ if (unlikely(arg_count == 0 && function->m_args_simple && args_size + kw_size > 0)) {
2705
+ #if PYTHON_VERSION < 0x300
2706
+ formatErrorNoArgumentAllowed(function, args_size + kw_size);
2707
+ #else
2708
+ formatErrorNoArgumentAllowedKwSplit(function, PyTuple_GET_ITEM(kw_names, 0), args_size);
2709
+ #endif
2710
+
2711
+ releaseParameters(function, python_pars);
2712
+ return false;
2713
+ }
2714
+
2715
+ #if PYTHON_VERSION >= 0x300
2716
+ Py_ssize_t kw_only_found = 0;
2717
+ #endif
2718
+ if (function->m_args_star_dict_index != -1) {
2719
+ #if PYTHON_VERSION < 0x300
2720
+ kw_found = handleKeywordArgsSplitWithStarDict(tstate, function, python_pars, kw_values, kw_names);
2721
+ #else
2722
+ kw_found =
2723
+ handleKeywordArgsSplitWithStarDict(tstate, function, python_pars, &kw_only_found, kw_values, kw_names);
2724
+ #endif
2725
+ if (unlikely(kw_found == -1)) {
2726
+ releaseParameters(function, python_pars);
2727
+ return false;
2728
+ }
2729
+ } else {
2730
+ #if PYTHON_VERSION < 0x300
2731
+ kw_found = handleKeywordArgsSplit(function, python_pars, kw_values, kw_names);
2732
+ #else
2733
+ kw_found = handleKeywordArgsSplit(function, python_pars, &kw_only_found, kw_values, kw_names);
2734
+ #endif
2735
+ if (unlikely(kw_found == -1)) {
2736
+ releaseParameters(function, python_pars);
2737
+ return false;
2738
+ }
2739
+ }
2740
+
2741
+ #if PYTHON_VERSION < 0x270
2742
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found, kw_size);
2743
+ #elif PYTHON_VERSION < 0x300
2744
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found);
2745
+ #else
2746
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found, kw_only_found);
2747
+ #endif
2748
+
2749
+ if (result == false) {
2750
+ releaseParameters(function, python_pars);
2751
+ return false;
2752
+ }
2753
+
2754
+ #if PYTHON_VERSION >= 0x300
2755
+ // For Python3 the keyword only errors are all reported at once.
2756
+ bool kw_only_error = false;
2757
+
2758
+ for (Py_ssize_t i = function->m_args_positional_count; i < function->m_args_keywords_count; i++) {
2759
+ if (python_pars[i] == NULL) {
2760
+ PyObject *arg_name = function->m_varnames[i];
2761
+
2762
+ if (function->m_kwdefaults != NULL) {
2763
+ python_pars[i] = DICT_GET_ITEM1(tstate, function->m_kwdefaults, arg_name);
2764
+ }
2765
+
2766
+ if (unlikely(python_pars[i] == NULL)) {
2767
+ kw_only_error = true;
2768
+ }
2769
+ }
2770
+ }
2771
+
2772
+ if (unlikely(kw_only_error)) {
2773
+ formatErrorTooFewKwOnlyArguments(tstate, function, &python_pars[function->m_args_positional_count]);
2774
+
2775
+ releaseParameters(function, python_pars);
2776
+ return false;
2777
+ }
2778
+
2779
+ #endif
2780
+
2781
+ return true;
2782
+ }
2783
+
2784
+ static bool parseArgumentsFull(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2785
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size, PyObject *kw) {
2786
+ Py_ssize_t kw_size = kw ? DICT_SIZE(kw) : 0;
2787
+ Py_ssize_t kw_found;
2788
+ bool result;
2789
+
2790
+ Py_ssize_t arg_count = function->m_args_keywords_count;
2791
+
2792
+ assert(kw == NULL || PyDict_CheckExact(kw));
2793
+
2794
+ if (unlikely(arg_count == 0 && function->m_args_simple && args_size + kw_size > 0)) {
2795
+ #if PYTHON_VERSION < 0x300
2796
+ formatErrorNoArgumentAllowed(function, args_size + kw_size);
2797
+ #else
2798
+ formatErrorNoArgumentAllowed(function, kw_size > 0 ? kw : NULL, args_size);
2799
+ #endif
2800
+
2801
+ releaseParameters(function, python_pars);
2802
+ return false;
2803
+ }
2804
+
2805
+ #if PYTHON_VERSION >= 0x300
2806
+ Py_ssize_t kw_only_found = 0;
2807
+ #endif
2808
+ if (function->m_args_star_dict_index != -1) {
2809
+ #if PYTHON_VERSION < 0x300
2810
+ kw_found = handleKeywordArgsWithStarDict(tstate, function, python_pars, kw);
2811
+ #else
2812
+ kw_found = handleKeywordArgsWithStarDict(tstate, function, python_pars, &kw_only_found, kw);
2813
+ #endif
2814
+ if (unlikely(kw_found == -1)) {
2815
+ releaseParameters(function, python_pars);
2816
+ return false;
2817
+ }
2818
+ } else if (kw == NULL || DICT_SIZE(kw) == 0) {
2819
+ kw_found = 0;
2820
+ } else {
2821
+ #if PYTHON_VERSION < 0x300
2822
+ kw_found = handleKeywordArgs(tstate, function, python_pars, kw);
2823
+ #else
2824
+ kw_found = handleKeywordArgs(tstate, function, python_pars, &kw_only_found, kw);
2825
+ #endif
2826
+ if (unlikely(kw_found == -1)) {
2827
+ releaseParameters(function, python_pars);
2828
+ return false;
2829
+ }
2830
+ }
2831
+
2832
+ #if PYTHON_VERSION < 0x270
2833
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found, kw_size);
2834
+ #elif PYTHON_VERSION < 0x300
2835
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found);
2836
+ #else
2837
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found, kw_only_found);
2838
+ #endif
2839
+
2840
+ if (result == false) {
2841
+ releaseParameters(function, python_pars);
2842
+ return false;
2843
+ }
2844
+
2845
+ #if PYTHON_VERSION >= 0x300
2846
+ // For Python3 the keyword only errors are all reported at once.
2847
+ bool kw_only_error = false;
2848
+
2849
+ for (Py_ssize_t i = function->m_args_positional_count; i < function->m_args_keywords_count; i++) {
2850
+ if (python_pars[i] == NULL) {
2851
+ PyObject *arg_name = function->m_varnames[i];
2852
+
2853
+ if (function->m_kwdefaults != NULL) {
2854
+ python_pars[i] = DICT_GET_ITEM1(tstate, function->m_kwdefaults, arg_name);
2855
+ }
2856
+
2857
+ if (unlikely(python_pars[i] == NULL)) {
2858
+ kw_only_error = true;
2859
+ }
2860
+ }
2861
+ }
2862
+
2863
+ if (unlikely(kw_only_error)) {
2864
+ formatErrorTooFewKwOnlyArguments(tstate, function, &python_pars[function->m_args_positional_count]);
2865
+
2866
+ releaseParameters(function, python_pars);
2867
+ return false;
2868
+ }
2869
+
2870
+ #endif
2871
+
2872
+ return true;
2873
+ }
2874
+
2875
+ PyObject *Nuitka_CallFunctionNoArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function) {
2876
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
2877
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
2878
+
2879
+ if (unlikely(!parseArgumentsEmpty(tstate, function, python_pars))) {
2880
+ return NULL;
2881
+ }
2882
+
2883
+ return function->m_c_code(tstate, function, python_pars);
2884
+ }
2885
+
2886
+ PyObject *Nuitka_CallFunctionPosArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2887
+ PyObject *const *args, Py_ssize_t args_size) {
2888
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
2889
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
2890
+
2891
+ if (unlikely(!parseArgumentsPos(tstate, function, python_pars, args, args_size))) {
2892
+ return NULL;
2893
+ }
2894
+
2895
+ return function->m_c_code(tstate, function, python_pars);
2896
+ }
2897
+
2898
+ PyObject *Nuitka_CallFunctionPosArgsKwArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2899
+ PyObject *const *args, Py_ssize_t args_size, PyObject *kw) {
2900
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
2901
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
2902
+
2903
+ if (unlikely(!parseArgumentsFull(tstate, function, python_pars, args, args_size, kw))) {
2904
+ return NULL;
2905
+ }
2906
+
2907
+ return function->m_c_code(tstate, function, python_pars);
2908
+ }
2909
+
2910
+ PyObject *Nuitka_CallFunctionPosArgsKwSplit(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2911
+ PyObject *const *args, Py_ssize_t args_size, PyObject *const *kw_values,
2912
+ PyObject *kw_names) {
2913
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
2914
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
2915
+
2916
+ if (unlikely(!parseArgumentsFullKwSplit(tstate, function, python_pars, args, args_size, kw_values, kw_names))) {
2917
+ return NULL;
2918
+ }
2919
+
2920
+ return function->m_c_code(tstate, function, python_pars);
2921
+ }
2922
+
2923
+ PyObject *Nuitka_CallMethodFunctionNoArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2924
+ PyObject *object) {
2925
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
2926
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
2927
+
2928
+ if (unlikely(!parseArgumentsMethodPos(tstate, function, python_pars, object, NULL, 0))) {
2929
+ return NULL;
2930
+ }
2931
+
2932
+ return function->m_c_code(tstate, function, python_pars);
2933
+ }
2934
+
2935
+ PyObject *Nuitka_CallMethodFunctionPosArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2936
+ PyObject *object, PyObject *const *args, Py_ssize_t args_size) {
2937
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
2938
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
2939
+
2940
+ if (unlikely(!parseArgumentsMethodPos(tstate, function, python_pars, object, args, args_size))) {
2941
+ return NULL;
2942
+ }
2943
+
2944
+ return function->m_c_code(tstate, function, python_pars);
2945
+ }
2946
+
2947
+ PyObject *Nuitka_CallMethodFunctionPosArgsKwArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2948
+ PyObject *object, PyObject *const *args, Py_ssize_t args_size,
2949
+ PyObject *kw) {
2950
+ NUITKA_DYNAMIC_ARRAY_DECL(new_args, PyObject *, args_size + 1);
2951
+
2952
+ new_args[0] = object;
2953
+ memcpy(new_args + 1, args, args_size * sizeof(PyObject *));
2954
+
2955
+ // TODO: Specialize implementation for massive gains.
2956
+ return Nuitka_CallFunctionPosArgsKwArgs(tstate, function, new_args, args_size + 1, kw);
2957
+ }
2958
+
2959
+ static Py_ssize_t _handleVectorcallKeywordArgs(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
2960
+ PyObject **python_pars, Py_ssize_t *kw_only_found,
2961
+ PyObject *const *kw_names, PyObject *const *kw_values,
2962
+ Py_ssize_t kw_size) {
2963
+ Py_ssize_t keywords_count = function->m_args_keywords_count;
2964
+
2965
+ Py_ssize_t keyword_after_index = function->m_args_positional_count;
2966
+
2967
+ assert(function->m_args_star_dict_index == -1);
2968
+
2969
+ Py_ssize_t kw_found = 0;
2970
+
2971
+ for (Py_ssize_t pos = 0; pos < kw_size; pos++) {
2972
+ PyObject *key = kw_names[pos];
2973
+
2974
+ if (unlikely(!checkKeywordType(key))) {
2975
+ formatErrorKeywordsMustBeString(tstate, function);
2976
+ return -1;
2977
+ }
2978
+
2979
+ NUITKA_MAY_BE_UNUSED bool found = false;
2980
+
2981
+ #if PYTHON_VERSION < 0x380
2982
+ Py_ssize_t kw_arg_start = 0;
2983
+ #else
2984
+ Py_ssize_t kw_arg_start = function->m_args_pos_only_count;
2985
+ #endif
2986
+
2987
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
2988
+ if (function->m_varnames[i] == key) {
2989
+ assert(python_pars[i] == NULL);
2990
+ python_pars[i] = kw_values[pos];
2991
+ Py_INCREF(python_pars[i]);
2992
+
2993
+ if (i >= keyword_after_index) {
2994
+ *kw_only_found += 1;
2995
+ }
2996
+
2997
+ found = true;
2998
+ break;
2999
+ }
3000
+ }
3001
+
3002
+ if (found == false) {
3003
+ PyObject **var_names = function->m_varnames;
3004
+
3005
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
3006
+ if (RICH_COMPARE_EQ_CBOOL_ARG_NAMES(var_names[i], key)) {
3007
+ assert(python_pars[i] == NULL);
3008
+ python_pars[i] = kw_values[pos];
3009
+ Py_INCREF(python_pars[i]);
3010
+
3011
+ if (i >= keyword_after_index) {
3012
+ *kw_only_found += 1;
3013
+ }
3014
+
3015
+ found = true;
3016
+ break;
3017
+ }
3018
+ }
3019
+ }
3020
+
3021
+ if (unlikely(found == false)) {
3022
+ bool pos_only_error = false;
3023
+
3024
+ for (Py_ssize_t i = 0; i < kw_arg_start; i++) {
3025
+ PyObject **var_names = function->m_varnames;
3026
+
3027
+ if (RICH_COMPARE_EQ_CBOOL_ARG_NAMES(var_names[i], key)) {
3028
+ pos_only_error = true;
3029
+ break;
3030
+ }
3031
+ }
3032
+
3033
+ #if PYTHON_VERSION < 0x3a0
3034
+ char const *function_name = Nuitka_String_AsString(function->m_name);
3035
+ #else
3036
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
3037
+ #endif
3038
+
3039
+ if (pos_only_error == true) {
3040
+ PyErr_Format(PyExc_TypeError,
3041
+ "%s() got some positional-only arguments passed as keyword arguments: '%s'", function_name,
3042
+ Nuitka_String_Check(key) ? Nuitka_String_AsString(key) : "<non-string>");
3043
+
3044
+ } else {
3045
+ PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%s'", function_name,
3046
+ Nuitka_String_Check(key) ? Nuitka_String_AsString(key) : "<non-string>");
3047
+ }
3048
+
3049
+ return -1;
3050
+ }
3051
+
3052
+ kw_found += 1;
3053
+ }
3054
+
3055
+ return kw_found;
3056
+ }
3057
+
3058
+ static bool MAKE_STAR_DICT_DICTIONARY_COPY38(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
3059
+ PyObject **python_pars, PyObject *const *kw_names,
3060
+ PyObject *const *kw_values, Py_ssize_t kw_size) {
3061
+ Py_ssize_t star_dict_index = function->m_args_star_dict_index;
3062
+ assert(star_dict_index != -1);
3063
+
3064
+ python_pars[star_dict_index] = _PyDict_NewPresized(kw_size);
3065
+
3066
+ for (int i = 0; i < kw_size; i++) {
3067
+ PyObject *key = kw_names[i];
3068
+
3069
+ if (unlikely(!checkKeywordType(key))) {
3070
+ formatErrorKeywordsMustBeString(tstate, function);
3071
+ return false;
3072
+ }
3073
+
3074
+ bool result = DICT_SET_ITEM(python_pars[star_dict_index], key, kw_values[i]);
3075
+
3076
+ if (unlikely(result == false)) {
3077
+ return false;
3078
+ }
3079
+ }
3080
+
3081
+ return true;
3082
+ }
3083
+
3084
+ static Py_ssize_t handleVectorcallKeywordArgsWithStarDict(PyThreadState *tstate,
3085
+ struct Nuitka_FunctionObject const *function,
3086
+ PyObject **python_pars, Py_ssize_t *kw_only_found,
3087
+ PyObject *const *kw_names, PyObject *const *kw_values,
3088
+ Py_ssize_t kw_size) {
3089
+ assert(function->m_args_star_dict_index != -1);
3090
+
3091
+ if (unlikely(MAKE_STAR_DICT_DICTIONARY_COPY38(tstate, function, python_pars, kw_names, kw_values, kw_size) ==
3092
+ false)) {
3093
+ return -1;
3094
+ }
3095
+
3096
+ Py_ssize_t kw_found = 0;
3097
+ Py_ssize_t keywords_count = function->m_args_keywords_count;
3098
+ Py_ssize_t keyword_after_index = function->m_args_positional_count;
3099
+
3100
+ Py_ssize_t star_dict_index = function->m_args_star_dict_index;
3101
+
3102
+ PyObject **var_names = function->m_varnames;
3103
+
3104
+ #if PYTHON_VERSION < 0x380
3105
+ Py_ssize_t kw_arg_start = 0;
3106
+ #else
3107
+ Py_ssize_t kw_arg_start = function->m_args_pos_only_count;
3108
+ #endif
3109
+
3110
+ for (Py_ssize_t i = kw_arg_start; i < keywords_count; i++) {
3111
+ PyObject *arg_name = var_names[i];
3112
+
3113
+ PyObject *kw_arg_value = DICT_GET_ITEM1(tstate, python_pars[star_dict_index], arg_name);
3114
+
3115
+ if (kw_arg_value != NULL) {
3116
+ assert(python_pars[i] == NULL);
3117
+
3118
+ python_pars[i] = kw_arg_value;
3119
+
3120
+ DICT_REMOVE_ITEM(python_pars[star_dict_index], arg_name);
3121
+
3122
+ kw_found += 1;
3123
+
3124
+ if (i >= keyword_after_index) {
3125
+ *kw_only_found += 1;
3126
+ }
3127
+ }
3128
+ }
3129
+
3130
+ return kw_found;
3131
+ }
3132
+
3133
+ static bool parseArgumentsVectorcall(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
3134
+ PyObject **python_pars, PyObject *const *args, Py_ssize_t args_size,
3135
+ PyObject *const *kw_names, Py_ssize_t kw_size) {
3136
+ Py_ssize_t kw_found;
3137
+ bool result;
3138
+ Py_ssize_t kw_only_found;
3139
+
3140
+ Py_ssize_t arg_count = function->m_args_keywords_count;
3141
+
3142
+ // TODO: Create different the vector call slot entries for different function types for extra
3143
+ // performance.
3144
+
3145
+ if (unlikely(arg_count == 0 && function->m_args_simple && args_size + kw_size > 0)) {
3146
+ #if PYTHON_VERSION < 0x3a0
3147
+ char const *function_name = Nuitka_String_AsString(function->m_name);
3148
+ #else
3149
+ char const *function_name = Nuitka_String_AsString(function->m_qualname);
3150
+ #endif
3151
+
3152
+ if (kw_size == 0) {
3153
+ PyErr_Format(PyExc_TypeError, "%s() takes 0 positional arguments but %zd was given", function_name,
3154
+ args_size);
3155
+ } else {
3156
+ PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%s'", function_name,
3157
+ Nuitka_String_AsString(kw_names[0]));
3158
+ }
3159
+
3160
+ releaseParameters(function, python_pars);
3161
+ return false;
3162
+ }
3163
+
3164
+ kw_only_found = 0;
3165
+ if (function->m_args_star_dict_index != -1) {
3166
+ kw_found = handleVectorcallKeywordArgsWithStarDict(tstate, function, python_pars, &kw_only_found, kw_names,
3167
+ &args[args_size], kw_size);
3168
+ if (unlikely(kw_found == -1)) {
3169
+ releaseParameters(function, python_pars);
3170
+ return false;
3171
+ }
3172
+ } else if (kw_size == 0) {
3173
+ kw_found = 0;
3174
+ } else {
3175
+ kw_found = _handleVectorcallKeywordArgs(tstate, function, python_pars, &kw_only_found, kw_names,
3176
+ &args[args_size], kw_size);
3177
+
3178
+ if (unlikely(kw_found == -1)) {
3179
+ releaseParameters(function, python_pars);
3180
+ return false;
3181
+ }
3182
+ }
3183
+
3184
+ #if PYTHON_VERSION < 0x270
3185
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found, kw_size);
3186
+ #elif PYTHON_VERSION < 0x300
3187
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found);
3188
+ #else
3189
+ result = _handleArgumentsPlain(tstate, function, python_pars, args, args_size, kw_found, kw_only_found);
3190
+ #endif
3191
+
3192
+ if (result == false) {
3193
+ releaseParameters(function, python_pars);
3194
+ return false;
3195
+ }
3196
+
3197
+ #if PYTHON_VERSION >= 0x300
3198
+ // For Python3 the keyword only errors are all reported at once.
3199
+ bool kw_only_error = false;
3200
+
3201
+ for (Py_ssize_t i = function->m_args_positional_count; i < function->m_args_keywords_count; i++) {
3202
+ if (python_pars[i] == NULL) {
3203
+ PyObject *arg_name = function->m_varnames[i];
3204
+
3205
+ if (function->m_kwdefaults != NULL) {
3206
+ python_pars[i] = DICT_GET_ITEM1(tstate, function->m_kwdefaults, arg_name);
3207
+ }
3208
+
3209
+ if (unlikely(python_pars[i] == NULL)) {
3210
+ kw_only_error = true;
3211
+ }
3212
+ }
3213
+ }
3214
+
3215
+ if (unlikely(kw_only_error)) {
3216
+ formatErrorTooFewKwOnlyArguments(tstate, function, &python_pars[function->m_args_positional_count]);
3217
+
3218
+ releaseParameters(function, python_pars);
3219
+ return false;
3220
+ }
3221
+ #endif
3222
+
3223
+ return true;
3224
+ }
3225
+
3226
+ PyObject *Nuitka_CallFunctionVectorcall(PyThreadState *tstate, struct Nuitka_FunctionObject const *function,
3227
+ PyObject *const *args, Py_ssize_t args_size, PyObject *const *kw_names,
3228
+ Py_ssize_t kw_size) {
3229
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
3230
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
3231
+
3232
+ if (unlikely(!parseArgumentsVectorcall(tstate, function, python_pars, args, args_size, kw_names, kw_size))) {
3233
+ return NULL;
3234
+ }
3235
+ return function->m_c_code(tstate, function, python_pars);
3236
+ }
3237
+
3238
+ static PyObject *Nuitka_Function_tp_call(struct Nuitka_FunctionObject *function, PyObject *tuple_args, PyObject *kw) {
3239
+ CHECK_OBJECT(tuple_args);
3240
+ assert(PyTuple_CheckExact(tuple_args));
3241
+
3242
+ PyThreadState *tstate = PyThreadState_GET();
3243
+
3244
+ if (kw == NULL) {
3245
+ PyObject **args = &PyTuple_GET_ITEM(tuple_args, 0);
3246
+ Py_ssize_t args_size = PyTuple_GET_SIZE(tuple_args);
3247
+
3248
+ if (function->m_args_simple && args_size == function->m_args_positional_count) {
3249
+ for (Py_ssize_t i = 0; i < args_size; i++) {
3250
+ Py_INCREF(args[i]);
3251
+ }
3252
+
3253
+ return function->m_c_code(tstate, function, args);
3254
+ } else if (function->m_args_simple &&
3255
+ args_size + function->m_defaults_given == function->m_args_positional_count) {
3256
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
3257
+ memcpy(python_pars, args, args_size * sizeof(PyObject *));
3258
+ memcpy(python_pars + args_size, &PyTuple_GET_ITEM(function->m_defaults, 0),
3259
+ function->m_defaults_given * sizeof(PyObject *));
3260
+
3261
+ for (Py_ssize_t i = 0; i < function->m_args_overall_count; i++) {
3262
+ Py_INCREF(python_pars[i]);
3263
+ }
3264
+
3265
+ return function->m_c_code(tstate, function, python_pars);
3266
+ } else {
3267
+ NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_overall_count);
3268
+ memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *));
3269
+
3270
+ if (parseArgumentsPos(tstate, function, python_pars, args, args_size)) {
3271
+ return function->m_c_code(tstate, function, python_pars);
3272
+ } else {
3273
+ return NULL;
3274
+ }
3275
+ }
3276
+ } else {
3277
+ return Nuitka_CallFunctionPosArgsKwArgs(tstate, function, &PyTuple_GET_ITEM(tuple_args, 0),
3278
+ PyTuple_GET_SIZE(tuple_args), kw);
3279
+ }
3280
+ }
3281
+
3282
+ #if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_SLOT)
3283
+ static PyObject *Nuitka_Function_tp_vectorcall(struct Nuitka_FunctionObject *function, PyObject *const *stack,
3284
+ size_t nargsf, PyObject *kw_names) {
3285
+ assert(kw_names == NULL || PyTuple_CheckExact(kw_names));
3286
+ Py_ssize_t kwargs_count = (kw_names == NULL) ? 0 : PyTuple_GET_SIZE(kw_names);
3287
+
3288
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
3289
+ assert(nargs >= 0);
3290
+ assert((nargs == 0 && kwargs_count == 0) || stack != NULL);
3291
+
3292
+ PyThreadState *tstate = PyThreadState_GET();
3293
+ return Nuitka_CallFunctionVectorcall(tstate, function, stack, nargs,
3294
+ kw_names ? &PyTuple_GET_ITEM(kw_names, 0) : NULL, kwargs_count);
3295
+ }
3296
+ #endif
3297
+
3298
+ #include "CompiledMethodType.c"
3299
+
3300
+ #include "CompiledGeneratorType.c"
3301
+
3302
+ #include "CompiledCellType.c"
3303
+
3304
+ #include "CompiledCodeHelpers.c"
3305
+
3306
+ #include "InspectPatcher.c"
3307
+ // Part of "Nuitka", an optimizing Python compiler that is compatible and
3308
+ // integrates with CPython, but also works on its own.
3309
+ //
3310
+ // Licensed under the Apache License, Version 2.0 (the "License");
3311
+ // you may not use this file except in compliance with the License.
3312
+ // You may obtain a copy of the License at
3313
+ //
3314
+ // http://www.apache.org/licenses/LICENSE-2.0
3315
+ //
3316
+ // Unless required by applicable law or agreed to in writing, software
3317
+ // distributed under the License is distributed on an "AS IS" BASIS,
3318
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3319
+ // See the License for the specific language governing permissions and
3320
+ // limitations under the License.