Nuitka-winsvc 2.2.3__cp311-cp311-win_amd64.whl → 2.3.2__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of Nuitka-winsvc might be problematic. Click here for more details.

Files changed (201) hide show
  1. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/METADATA +2 -1
  2. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/RECORD +201 -200
  3. nuitka/Bytecodes.py +4 -2
  4. nuitka/HardImportRegistry.py +1 -0
  5. nuitka/MainControl.py +16 -10
  6. nuitka/ModuleRegistry.py +15 -0
  7. nuitka/OptionParsing.py +30 -8
  8. nuitka/Options.py +106 -45
  9. nuitka/PostProcessing.py +9 -8
  10. nuitka/PythonVersions.py +2 -1
  11. nuitka/Serialization.py +47 -30
  12. nuitka/Version.py +1 -1
  13. nuitka/build/Backend.scons +46 -19
  14. nuitka/build/CCompilerVersion.scons +3 -3
  15. nuitka/build/Onefile.scons +4 -4
  16. nuitka/build/SconsCaching.py +3 -2
  17. nuitka/build/SconsCompilerSettings.py +18 -6
  18. nuitka/build/SconsInterface.py +28 -8
  19. nuitka/build/SconsUtils.py +9 -1
  20. nuitka/build/include/nuitka/allocator.h +58 -2
  21. nuitka/build/include/nuitka/compiled_frame.h +48 -13
  22. nuitka/build/include/nuitka/compiled_function.h +4 -0
  23. nuitka/build/include/nuitka/constants.h +6 -0
  24. nuitka/build/include/nuitka/exception_groups.h +6 -6
  25. nuitka/build/include/nuitka/exceptions.h +3 -3
  26. nuitka/build/include/nuitka/freelists.h +11 -0
  27. nuitka/build/include/nuitka/helper/dictionaries.h +5 -4
  28. nuitka/build/include/nuitka/helper/lists.h +5 -5
  29. nuitka/build/include/nuitka/helper/lists_generated.h +12 -12
  30. nuitka/build/include/nuitka/helper/sequences.h +6 -0
  31. nuitka/build/include/nuitka/helper/slices.h +14 -8
  32. nuitka/build/include/nuitka/helper/subscripts.h +1 -184
  33. nuitka/build/include/nuitka/helper/tuples.h +42 -33
  34. nuitka/build/include/nuitka/importing.h +5 -0
  35. nuitka/build/include/nuitka/prelude.h +49 -5
  36. nuitka/build/include/nuitka/safe_string_ops.h +1 -0
  37. nuitka/build/include/nuitka/threading.h +13 -10
  38. nuitka/build/static_src/CompiledAsyncgenType.c +19 -8
  39. nuitka/build/static_src/CompiledCellType.c +1 -1
  40. nuitka/build/static_src/CompiledCodeHelpers.c +18 -16
  41. nuitka/build/static_src/CompiledCoroutineType.c +23 -19
  42. nuitka/build/static_src/CompiledFrameType.c +46 -34
  43. nuitka/build/static_src/CompiledFunctionType.c +55 -34
  44. nuitka/build/static_src/CompiledGeneratorType.c +21 -19
  45. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +127 -130
  46. nuitka/build/static_src/CompiledMethodType.c +15 -17
  47. nuitka/build/static_src/HelpersAllocator.c +71 -0
  48. nuitka/build/static_src/HelpersAttributes.c +1 -1
  49. nuitka/build/static_src/HelpersBuiltin.c +5 -5
  50. nuitka/build/static_src/HelpersBytes.c +2 -2
  51. nuitka/build/static_src/HelpersCalling.c +3 -0
  52. nuitka/build/static_src/HelpersCallingGenerated.c +952 -133
  53. nuitka/build/static_src/HelpersComparisonEq.c +329 -329
  54. nuitka/build/static_src/HelpersComparisonEqUtils.c +3 -1
  55. nuitka/build/static_src/HelpersComparisonGe.c +322 -322
  56. nuitka/build/static_src/HelpersComparisonGt.c +321 -321
  57. nuitka/build/static_src/HelpersComparisonLe.c +322 -322
  58. nuitka/build/static_src/HelpersComparisonLt.c +321 -321
  59. nuitka/build/static_src/HelpersComparisonNe.c +329 -329
  60. nuitka/build/static_src/HelpersConsole.c +96 -0
  61. nuitka/build/static_src/HelpersConstantsBlob.c +10 -6
  62. nuitka/build/static_src/HelpersDeepcopy.c +10 -8
  63. nuitka/build/static_src/HelpersDictionaries.c +17 -11
  64. nuitka/build/static_src/HelpersDictionariesGenerated.c +65 -29
  65. nuitka/build/static_src/HelpersExceptions.c +107 -9
  66. nuitka/build/static_src/HelpersFilesystemPaths.c +64 -4
  67. nuitka/build/static_src/HelpersFloats.c +20 -14
  68. nuitka/build/static_src/HelpersImport.c +1 -1
  69. nuitka/build/static_src/HelpersJitSources.c +1 -1
  70. nuitka/build/static_src/HelpersLists.c +29 -19
  71. nuitka/build/static_src/HelpersListsGenerated.c +24 -24
  72. nuitka/build/static_src/HelpersMatching.c +32 -5
  73. nuitka/build/static_src/HelpersOperationBinaryAdd.c +90 -63
  74. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +4 -4
  75. nuitka/build/static_src/HelpersOperationBinaryBitand.c +33 -33
  76. nuitka/build/static_src/HelpersOperationBinaryBitor.c +33 -33
  77. nuitka/build/static_src/HelpersOperationBinaryBitxor.c +33 -33
  78. nuitka/build/static_src/HelpersOperationBinaryDivmod.c +24 -24
  79. nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +24 -24
  80. nuitka/build/static_src/HelpersOperationBinaryLshift.c +30 -30
  81. nuitka/build/static_src/HelpersOperationBinaryMatmult.c +7 -7
  82. nuitka/build/static_src/HelpersOperationBinaryMod.c +90 -90
  83. nuitka/build/static_src/HelpersOperationBinaryMult.c +64 -58
  84. nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +24 -24
  85. nuitka/build/static_src/HelpersOperationBinaryPow.c +27 -27
  86. nuitka/build/static_src/HelpersOperationBinaryRshift.c +30 -30
  87. nuitka/build/static_src/HelpersOperationBinarySub.c +24 -24
  88. nuitka/build/static_src/HelpersOperationBinaryTruediv.c +24 -24
  89. nuitka/build/static_src/HelpersOperationInplaceAdd.c +67 -49
  90. nuitka/build/static_src/HelpersOperationInplaceBitand.c +25 -25
  91. nuitka/build/static_src/HelpersOperationInplaceBitor.c +25 -25
  92. nuitka/build/static_src/HelpersOperationInplaceBitxor.c +25 -25
  93. nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +28 -28
  94. nuitka/build/static_src/HelpersOperationInplaceLshift.c +18 -18
  95. nuitka/build/static_src/HelpersOperationInplaceMatmult.c +10 -10
  96. nuitka/build/static_src/HelpersOperationInplaceMod.c +70 -70
  97. nuitka/build/static_src/HelpersOperationInplaceMult.c +33 -33
  98. nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +28 -28
  99. nuitka/build/static_src/HelpersOperationInplacePow.c +28 -28
  100. nuitka/build/static_src/HelpersOperationInplaceRshift.c +18 -18
  101. nuitka/build/static_src/HelpersOperationInplaceSub.c +28 -28
  102. nuitka/build/static_src/HelpersOperationInplaceTruediv.c +28 -28
  103. nuitka/build/static_src/HelpersRaising.c +10 -3
  104. nuitka/build/static_src/HelpersSafeStrings.c +14 -4
  105. nuitka/build/static_src/HelpersSlices.c +12 -5
  106. nuitka/build/static_src/HelpersStrings.c +1 -1
  107. nuitka/build/static_src/HelpersTuples.c +20 -15
  108. nuitka/build/static_src/InspectPatcher.c +74 -6
  109. nuitka/build/static_src/MainProgram.c +90 -25
  110. nuitka/build/static_src/MetaPathBasedLoader.c +81 -45
  111. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +2 -2
  112. nuitka/build/static_src/OnefileBootstrap.c +16 -17
  113. nuitka/code_generation/CodeGeneration.py +5 -2
  114. nuitka/code_generation/ConstantCodes.py +2 -2
  115. nuitka/code_generation/DictCodes.py +2 -2
  116. nuitka/code_generation/GlobalConstants.py +5 -0
  117. nuitka/code_generation/GlobalsLocalsCodes.py +2 -2
  118. nuitka/code_generation/ListCodes.py +2 -2
  119. nuitka/code_generation/LocalsDictCodes.py +1 -1
  120. nuitka/code_generation/ModuleCodes.py +19 -0
  121. nuitka/code_generation/PackageResourceCodes.py +14 -0
  122. nuitka/code_generation/SliceCodes.py +3 -3
  123. nuitka/code_generation/SubscriptCodes.py +5 -13
  124. nuitka/code_generation/TupleCodes.py +1 -1
  125. nuitka/code_generation/c_types/CTypePyObjectPointers.py +7 -7
  126. nuitka/code_generation/templates/CodeTemplatesConstants.py +7 -5
  127. nuitka/code_generation/templates/CodeTemplatesLoader.py +2 -0
  128. nuitka/code_generation/templates/CodeTemplatesModules.py +80 -54
  129. nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +1 -1
  130. nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +59 -8
  131. nuitka/code_generation/templates_c/CodeTemplateCallsPositionalMethodDescr.c.j2 +5 -5
  132. nuitka/code_generation/templates_c/CodeTemplateMakeListHinted.c.j2 +2 -2
  133. nuitka/code_generation/templates_c/CodeTemplateMakeListSmall.c.j2 +2 -2
  134. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +57 -21
  135. nuitka/code_generation/templates_c/HelperImportHard.c.j2 +1 -1
  136. nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +5 -5
  137. nuitka/code_generation/templates_c/HelperOperationComparison.c.j2 +18 -18
  138. nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +11 -11
  139. nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +3 -3
  140. nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +3 -3
  141. nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +7 -7
  142. nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +3 -3
  143. nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +11 -11
  144. nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +7 -7
  145. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +10 -10
  146. nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
  147. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +3 -3
  148. nuitka/code_generation/templates_c/HelperSlotsList.c.j2 +4 -1
  149. nuitka/code_generation/templates_c/HelperSlotsTuple.c.j2 +4 -1
  150. nuitka/finalizations/FinalizeMarkups.py +0 -18
  151. nuitka/freezer/DependsExe.py +9 -4
  152. nuitka/freezer/DllDependenciesMacOS.py +1 -1
  153. nuitka/freezer/DllDependenciesWin32.py +1 -1
  154. nuitka/freezer/ImportDetection.py +1 -0
  155. nuitka/freezer/IncludedDataFiles.py +13 -4
  156. nuitka/freezer/IncludedEntryPoints.py +16 -0
  157. nuitka/freezer/Onefile.py +0 -1
  158. nuitka/freezer/Standalone.py +38 -21
  159. nuitka/importing/ImportCache.py +3 -2
  160. nuitka/importing/Importing.py +16 -3
  161. nuitka/importing/StandardLibrary.py +4 -0
  162. nuitka/nodes/ChildrenHavingMixins.py +2 -0
  163. nuitka/nodes/ExpressionBasesGenerated.py +4 -0
  164. nuitka/nodes/HardImportNodesGenerated.py +83 -0
  165. nuitka/nodes/ModuleNodes.py +10 -2
  166. nuitka/nodes/OsSysNodes.py +16 -0
  167. nuitka/nodes/SubscriptNodes.py +3 -3
  168. nuitka/plugins/PluginBase.py +2 -0
  169. nuitka/plugins/standard/DataFilesPlugin.py +22 -1
  170. nuitka/plugins/standard/DillPlugin/DillPlugin.c +3 -3
  171. nuitka/plugins/standard/ImplicitImports.py +3 -0
  172. nuitka/plugins/standard/OptionsNannyPlugin.py +9 -41
  173. nuitka/plugins/standard/PkgResourcesPlugin.py +8 -2
  174. nuitka/plugins/standard/PySidePyQtPlugin.py +3 -0
  175. nuitka/plugins/standard/standard.nuitka-package.config.yml +28 -13
  176. nuitka/plugins/standard/stdlib2.nuitka-package.config.yml +2 -2
  177. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +7 -2
  178. nuitka/specs/HardImportSpecs.py +3 -0
  179. nuitka/specs/ParameterSpecs.py +26 -15
  180. nuitka/tools/general/find_module/FindModuleCode.py +3 -2
  181. nuitka/tools/specialize/CTypeDescriptions.py +11 -9
  182. nuitka/tools/testing/Common.py +12 -5
  183. nuitka/tools/testing/SearchModes.py +5 -1
  184. nuitka/tools/testing/run_nuitka_tests/__main__.py +37 -0
  185. nuitka/tools/watch/GitHub.py +1 -7
  186. nuitka/tree/Building.py +9 -6
  187. nuitka/tree/ReformulationMatchStatements.py +51 -14
  188. nuitka/tree/TreeHelpers.py +8 -0
  189. nuitka/utils/CStrings.py +7 -0
  190. nuitka/utils/Execution.py +10 -1
  191. nuitka/utils/FileOperations.py +21 -13
  192. nuitka/utils/Importing.py +24 -0
  193. nuitka/utils/ReExecute.py +12 -3
  194. nuitka/utils/SharedLibraries.py +26 -1
  195. nuitka/utils/Yaml.py +9 -1
  196. {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.2.data}/scripts/nuitka-run.bat +0 -0
  197. {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.2.data}/scripts/nuitka.bat +0 -0
  198. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/LICENSE.txt +0 -0
  199. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/WHEEL +0 -0
  200. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/entry_points.txt +0 -0
  201. {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.2.dist-info}/top_level.txt +0 -0
@@ -34,6 +34,7 @@
34
34
  #define SYSFLAG_UNBUFFERED 0
35
35
  #define NUITKA_MAIN_MODULE_NAME "__main__"
36
36
  #define NUITKA_MAIN_IS_PACKAGE_BOOL false
37
+ #define _NUITKA_ATTACH_CONSOLE_WINDOW 1
37
38
  #endif
38
39
 
39
40
  // It doesn't work for MinGW64 to update the standard output handles early on,
@@ -48,6 +49,10 @@
48
49
  #define NUITKA_STANDARD_HANDLES_EARLY 0
49
50
  #endif
50
51
 
52
+ #if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
53
+ #include "HelpersConsole.c"
54
+ #endif
55
+
51
56
  extern PyCodeObject *codeobj_main;
52
57
 
53
58
  /* For later use in "Py_GetArgcArgv" we expose the needed value */
@@ -328,20 +333,23 @@ static PyObject *EXECUTE_MAIN_MODULE(PyThreadState *tstate, char const *module_n
328
333
  return IMPORT_EMBEDDED_MODULE(tstate, module_name);
329
334
  }
330
335
 
331
- #ifdef _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
336
+ #if _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
332
337
  #include "nuitka_windows_service.h"
333
338
 
334
339
  // Callback from Windows Service logic.
335
- bool SvcStartPython(void) {
340
+ void SvcStartPython(void) {
336
341
  PyThreadState *tstate = PyThreadState_GET();
337
342
 
338
343
  EXECUTE_MAIN_MODULE(tstate, NUITKA_MAIN_MODULE_NAME, NUITKA_MAIN_IS_PACKAGE_BOOL);
339
344
 
340
- if (HAS_ERROR_OCCURRED(tstate)) {
341
- return true;
342
- } else {
343
- return false;
344
- }
345
+ NUITKA_PRINT_TIMING("SvcStartPython() Python exited.")
346
+
347
+ int exit_code = HANDLE_PROGRAM_EXIT(tstate);
348
+
349
+ // TODO: Log exception and call ReportSvcStatus
350
+
351
+ NUITKA_PRINT_TIMING("SvcStartPython(): Calling Py_Exit.");
352
+ Py_Exit(exit_code);
345
353
  }
346
354
 
347
355
  void SvcStopPython(void) { PyErr_SetInterrupt(); }
@@ -409,12 +417,12 @@ static void setCommandLineParameters(int argc, wchar_t **argv) {
409
417
  }
410
418
 
411
419
  if (i == 1) {
412
- #ifdef _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
420
+ #if _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
413
421
  if (strcmpFilename(argv[i], FILENAME_EMPTY_STR "install") == 0) {
414
422
  NUITKA_PRINT_TRACE("main(): Calling plugin SvcInstall().");
415
423
 
416
424
  SvcInstall();
417
- NUITKA_CANNOT_GET_HERE("SvcInstall must not return");
425
+ NUITKA_CANNOT_GET_HERE("main(): SvcInstall must not return");
418
426
  }
419
427
  #endif
420
428
  }
@@ -801,7 +809,7 @@ static void setInputOutputHandles(PyThreadState *tstate) {
801
809
  // reason.
802
810
  #if NUITKA_STANDARD_HANDLES_EARLY == 1 && PYTHON_VERSION >= 0x370
803
811
  #if defined(NUITKA_FORCED_STDOUT_PATH) || defined(NUITKA_FORCED_STDERR_PATH)
804
- PyObject *args = MAKE_DICT_EMPTY();
812
+ PyObject *args = MAKE_DICT_EMPTY(tstate);
805
813
 
806
814
  DICT_SET_ITEM(args, const_str_plain_encoding, Nuitka_String_FromString("utf-8"));
807
815
  DICT_SET_ITEM(args, const_str_plain_line_buffering, Py_True);
@@ -837,7 +845,7 @@ static void setInputOutputHandles(PyThreadState *tstate) {
837
845
  #if NUITKA_STANDARD_HANDLES_EARLY == 0
838
846
  #if defined(NUITKA_FORCED_STDOUT_PATH)
839
847
  {
840
- #ifdef _WIN32
848
+ #if defined(_WIN32)
841
849
  PyObject *filename = getExpandedTemplatePath(L"" NUITKA_FORCED_STDOUT_PATH);
842
850
  #else
843
851
  PyObject *filename = getExpandedTemplatePath(NUITKA_FORCED_STDOUT_PATH);
@@ -912,15 +920,23 @@ static void setInputOutputHandles(PyThreadState *tstate) {
912
920
  }
913
921
 
914
922
  static void Nuitka_Py_Initialize(void) {
923
+ #if PYTHON_VERSION > 0x350 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_ALLOCATORS)
924
+ initNuitkaAllocators();
925
+ #endif
926
+
915
927
  #if PYTHON_VERSION < 0x380 || defined(_NUITKA_EXPERIMENTAL_OLD_PY_INITIALIZE)
916
928
  Py_Initialize();
917
929
  #else
930
+ #if PYTHON_VERSION < 0x3d0
918
931
  PyStatus status = _PyRuntime_Initialize();
919
932
  if (unlikely(status._type != 0)) {
920
933
  Py_ExitStatusException(status);
921
934
  }
922
935
  NUITKA_MAY_BE_UNUSED _PyRuntimeState *runtime = &_PyRuntime;
923
936
  assert(!runtime->initialized);
937
+ #else
938
+ PyStatus status;
939
+ #endif
924
940
 
925
941
  PyConfig config;
926
942
  _PyConfig_InitCompatConfig(&config);
@@ -998,23 +1014,13 @@ static void Nuitka_Py_Initialize(void) {
998
1014
  static void changeStandardHandleTarget(int std_handle_id, FILE *std_handle, filename_char_t const *template_path) {
999
1015
  filename_char_t filename_buffer[1024];
1000
1016
 
1001
- // TODO: We should only have one that works with filename_char_t rather than having
1002
- // to make a difference here.
1003
- #ifdef _WIN32
1004
- bool res = expandTemplatePathW(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(filename_char_t));
1005
-
1006
- if (res == false) {
1007
- wprintf(L"Error, couldn't expand pattern '%lS'\n", template_path);
1008
- abort();
1009
- }
1010
- #else
1011
- bool res = expandTemplatePath(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(filename_char_t));
1017
+ bool res =
1018
+ expandTemplatePathFilename(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(filename_char_t));
1012
1019
 
1013
1020
  if (res == false) {
1014
- printf("Error, couldn't expand pattern: '%s'\n", template_path);
1021
+ printf("Error, couldn't expand pattern '" FILENAME_FORMAT_STR "'\n", template_path);
1015
1022
  abort();
1016
1023
  }
1017
- #endif
1018
1024
 
1019
1025
  if (GetStdHandle(std_handle_id) == 0) {
1020
1026
  FILE *file_handle;
@@ -1129,7 +1135,13 @@ int main(int argc, char **argv) {
1129
1135
  atexit(Nuitka_at_exit);
1130
1136
  #endif
1131
1137
 
1132
- // First things, set up stdout/stderr according to user specification.
1138
+ // Attach to the parent console respecting redirection only, otherwise we
1139
+ // cannot even output traces.
1140
+ #if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
1141
+ inheritAttachedConsole();
1142
+ #endif
1143
+
1144
+ // Set up stdout/stderr according to user specification.
1133
1145
  #if NUITKA_STANDARD_HANDLES_EARLY == 1
1134
1146
  #if defined(NUITKA_FORCED_STDOUT_PATH)
1135
1147
  #ifdef _WIN32
@@ -1416,6 +1428,57 @@ orig_argv = argv;
1416
1428
  }
1417
1429
  #endif
1418
1430
 
1431
+ #if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
1432
+ if (needs_stdout_attaching) {
1433
+ PyObject *filename = Nuitka_String_FromString("CONOUT$");
1434
+ // This defaults to "utf-8" internally. We may add an argument of use
1435
+ // platform ones in the future.
1436
+ PyObject *encoding = NULL;
1437
+
1438
+ PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding);
1439
+ if (unlikely(stdout_file == NULL)) {
1440
+ PyErr_PrintEx(1);
1441
+ Py_Exit(1);
1442
+ }
1443
+
1444
+ Py_DECREF(filename);
1445
+
1446
+ Nuitka_SysSetObject("stdout", stdout_file);
1447
+ }
1448
+
1449
+ if (needs_stderr_attaching) {
1450
+ PyObject *filename = Nuitka_String_FromString("CONOUT$");
1451
+ // This defaults to "utf-8" internally. We may add an argument of use
1452
+ // platform ones in the future.
1453
+ PyObject *encoding = NULL;
1454
+
1455
+ PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding);
1456
+ if (unlikely(stderr_file == NULL)) {
1457
+ PyErr_PrintEx(1);
1458
+ Py_Exit(1);
1459
+ }
1460
+
1461
+ Py_DECREF(filename);
1462
+
1463
+ Nuitka_SysSetObject("stderr", stderr_file);
1464
+ }
1465
+
1466
+ if (needs_stdin_attaching) {
1467
+ PyObject *filename = Nuitka_String_FromString("CONIN$");
1468
+ // This defaults to "utf-8" internally. We may add an argument of use
1469
+ // platform ones in the future.
1470
+ PyObject *encoding = NULL;
1471
+
1472
+ // CPython core requires stdin to be buffered due to methods usage, and it won't matter
1473
+ // here much.
1474
+ PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "r", true, encoding);
1475
+
1476
+ Py_DECREF(filename);
1477
+
1478
+ Nuitka_SysSetObject("stdin", stdin_file);
1479
+ }
1480
+ #endif
1481
+
1419
1482
  NUITKA_PRINT_TRACE("main(): Setting Python input/output handles.");
1420
1483
  setInputOutputHandles(tstate);
1421
1484
 
@@ -1444,8 +1507,10 @@ orig_argv = argv;
1444
1507
  /* Enable meta path based loader. */
1445
1508
  setupMetaPathBasedLoader(tstate);
1446
1509
 
1510
+ #if PYTHON_VERSION < 0x3d0
1447
1511
  /* Initialize warnings module. */
1448
1512
  _PyWarnings_Init();
1513
+ #endif
1449
1514
 
1450
1515
  #if NO_PYTHON_WARNINGS && PYTHON_VERSION >= 0x342 && PYTHON_VERSION < 0x3a0 && defined(_NUITKA_FULL_COMPAT)
1451
1516
  // For full compatibility bump the warnings registry version,
@@ -22,6 +22,9 @@
22
22
  #ifdef _WIN32
23
23
  #undef SEP
24
24
  #define SEP '\\'
25
+ #define SEP_L L'\\'
26
+ #else
27
+ #define SEP_L SEP
25
28
  #endif
26
29
 
27
30
  #ifdef _WIN32
@@ -66,6 +69,7 @@ static char *appendModuleNameAsPath(char *buffer, char const *module_name, size_
66
69
  // Skip to the end
67
70
  while (*buffer != 0) {
68
71
  buffer++;
72
+ buffer_size -= 1;
69
73
  }
70
74
 
71
75
  while (*module_name) {
@@ -90,20 +94,17 @@ static char *appendModuleNameAsPath(char *buffer, char const *module_name, size_
90
94
 
91
95
  #if defined(_WIN32) && defined(_NUITKA_STANDALONE)
92
96
 
93
- static void appendModuleNameAsPathW(wchar_t *buffer, char const *module_name, size_t buffer_size) {
94
- // Skip to the end
95
- while (*buffer != 0) {
96
- buffer++;
97
- }
97
+ static void appendModuleNameAsPathW(wchar_t *buffer, PyObject *module_name, size_t buffer_size) {
98
+ wchar_t const *module_name_wstr = PyUnicode_AsWideCharString(module_name, NULL);
98
99
 
99
- while (*module_name) {
100
- char c = *module_name++;
100
+ while (*module_name_wstr != 0) {
101
+ wchar_t c = *module_name_wstr++;
101
102
 
102
- if (c == '.') {
103
- c = SEP;
103
+ if (c == L'.') {
104
+ c = SEP_L;
104
105
  }
105
106
 
106
- appendCharSafeW(buffer, c, buffer_size);
107
+ appendWCharSafeW(buffer, c, buffer_size);
107
108
  }
108
109
  }
109
110
  #endif
@@ -199,7 +200,9 @@ static PyObject *loadModuleFromCodeObject(PyObject *module, PyCodeObject *code_o
199
200
 
200
201
  if (is_package) {
201
202
  /* Set __path__ properly, unlike frozen module importer does. */
202
- PyObject *path_list = MAKE_LIST_EMPTY(1);
203
+ NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
204
+
205
+ PyObject *path_list = MAKE_LIST_EMPTY(tstate, 1);
203
206
  if (unlikely(path_list == NULL)) {
204
207
  return NULL;
205
208
  }
@@ -313,7 +316,7 @@ static PyObject *_getImportingSuffixesByPriority(PyThreadState *tstate, int kind
313
316
  static PyObject *result = NULL;
314
317
 
315
318
  if (result == NULL) {
316
- result = MAKE_LIST_EMPTY(0);
319
+ result = MAKE_LIST_EMPTY(tstate, 0);
317
320
 
318
321
  PyObject *imp_module = PyImport_ImportModule("imp");
319
322
  PyObject *get_suffixes_func = PyObject_GetAttrString(imp_module, "get_suffixes");
@@ -371,7 +374,7 @@ static bool scanModuleInPackagePath(PyThreadState *tstate, PyObject *module_name
371
374
  return false;
372
375
  }
373
376
 
374
- PyObject *candidates = MAKE_LIST_EMPTY(0);
377
+ PyObject *candidates = MAKE_LIST_EMPTY(tstate, 0);
375
378
 
376
379
  // Search only relative to the parent name of course.
377
380
  char const *module_relative_name_str = Nuitka_String_AsString(module_name) + strlen(parent_module_name) + 1;
@@ -434,7 +437,7 @@ static bool scanModuleInPackagePath(PyThreadState *tstate, PyObject *module_name
434
437
  PyObject *fullpath = JOIN_PATH2(directory, candidate);
435
438
 
436
439
  if (installed_extension_modules == NULL) {
437
- installed_extension_modules = MAKE_DICT_EMPTY();
440
+ installed_extension_modules = MAKE_DICT_EMPTY(tstate);
438
441
  }
439
442
 
440
443
  // Force path to unicode, to have easier consumption, as we need a wchar_t or char *
@@ -458,11 +461,7 @@ static bool scanModuleInPackagePath(PyThreadState *tstate, PyObject *module_name
458
461
  return result;
459
462
  }
460
463
 
461
- #ifdef _WIN32
462
- static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const wchar_t *filename);
463
- #else
464
- static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const char *filename);
465
- #endif
464
+ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const filename_char_t *filename);
466
465
 
467
466
  static PyObject *callIntoInstalledExtensionModule(PyThreadState *tstate, PyObject *module_name,
468
467
  PyObject *extension_module_filename) {
@@ -561,7 +560,7 @@ static PyObject *_nuitka_loader_find_module(PyObject *self, PyObject *args, PyOb
561
560
  PySys_WriteStderr("import %s # denied responsibility\n", name);
562
561
  }
563
562
 
564
- Py_INCREF(Py_None);
563
+ Py_INCREF_IMMORTAL(Py_None);
565
564
  return Py_None;
566
565
  }
567
566
 
@@ -638,11 +637,46 @@ typedef PyObject *(*entrypoint_t)(void);
638
637
  static PyObject *createModuleSpec(PyThreadState *tstate, PyObject *module_name, PyObject *origin, bool is_package);
639
638
  #endif
640
639
 
641
- #ifdef _WIN32
642
- static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const wchar_t *filename) {
640
+ static void _fillExtensionModuleDllEntryFunctionName(PyThreadState *tstate, char *buffer, size_t buffer_size,
641
+ char const *name) {
642
+
643
+ #if PYTHON_VERSION >= 0x350
644
+ PyObject *name_bytes_obj = PyBytes_FromString(name);
645
+ PyObject *name_obj = BYTES_DECODE2(tstate, name_bytes_obj, Nuitka_String_FromString("utf8"));
646
+ Py_DECREF(name_bytes_obj);
647
+
648
+ PyObject *name_ascii = UNICODE_ENCODE2(tstate, name_obj, const_str_plain_ascii);
649
+
650
+ if (name_ascii == NULL) {
651
+ DROP_ERROR_OCCURRED(tstate);
652
+
653
+ PyObject *name_punycode = UNICODE_ENCODE2(tstate, name_obj, const_str_plain_punycode);
654
+
655
+ CHECK_OBJECT(name_punycode);
656
+
657
+ snprintf(buffer, buffer_size, "PyInitU_%s", PyBytes_AsString(name_punycode));
658
+
659
+ Py_DECREF(name_punycode);
660
+ } else {
661
+ Py_DECREF(name_ascii);
662
+
663
+ snprintf(buffer, buffer_size, "PyInit_%s", name);
664
+ }
665
+ Py_DECREF(name_obj);
666
+ #else
667
+
668
+ snprintf(buffer, buffer_size,
669
+ #if PYTHON_VERSION < 0x300
670
+ "init%s",
643
671
  #else
644
- static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const char *filename) {
672
+ "PyInit_%s",
673
+ #endif
674
+ name);
645
675
  #endif
676
+ }
677
+
678
+ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name,
679
+ const filename_char_t *filename) {
646
680
  // Determine the package name and basename of the module to load.
647
681
  char const *dot = strrchr(full_name, '.');
648
682
  char const *name;
@@ -658,13 +692,7 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
658
692
  }
659
693
 
660
694
  char entry_function_name[1024];
661
- snprintf(entry_function_name, sizeof(entry_function_name),
662
- #if PYTHON_VERSION < 0x300
663
- "init%s",
664
- #else
665
- "PyInit_%s",
666
- #endif
667
- name);
695
+ _fillExtensionModuleDllEntryFunctionName(tstate, entry_function_name, sizeof(entry_function_name), name);
668
696
 
669
697
  #ifdef _WIN32
670
698
  if (isVerbose()) {
@@ -701,15 +729,18 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
701
729
 
702
730
  // Report either way even if failed to get error message.
703
731
  if (size == 0) {
704
- PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed with error code %d", filename,
705
- error_code);
732
+ int ret = PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed with error code %d", filename,
733
+ error_code);
734
+
735
+ assert(ret >= 0);
706
736
  } else {
707
737
  // Strip trailing newline.
708
738
  if (size >= 2 && error_message[size - 2] == '\r' && error_message[size - 1] == '\n') {
709
739
  size -= 2;
710
740
  error_message[size] = '\0';
711
741
  }
712
- PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed: %s", filename, error_message);
742
+ int ret = PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed: %s", filename, error_message);
743
+ assert(ret >= 0);
713
744
  }
714
745
 
715
746
  SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ImportError, buffer);
@@ -911,20 +942,23 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
911
942
  #endif
912
943
  CHECK_OBJECT(filename_obj);
913
944
 
945
+ #if PYTHON_VERSION < 0x3d0
914
946
  int res = _PyImport_FixupExtensionObject(module, full_name_obj, filename_obj
915
947
  #if PYTHON_VERSION >= 0x370
916
948
  ,
917
949
  Nuitka_GetSysModules()
918
950
  #endif
919
-
920
951
  );
952
+ #endif
921
953
 
922
954
  Py_DECREF(full_name_obj);
923
955
  Py_DECREF(filename_obj);
924
956
 
957
+ #if PYTHON_VERSION < 0x3d0
925
958
  if (unlikely(res == -1)) {
926
959
  return NULL;
927
960
  }
961
+ #endif
928
962
  #endif
929
963
 
930
964
  return module;
@@ -984,7 +1018,7 @@ static PyObject *loadModule(PyThreadState *tstate, PyObject *module, PyObject *m
984
1018
 
985
1019
  appendWStringSafeW(filename, getBinaryDirectoryWideChars(true), sizeof(filename) / sizeof(wchar_t));
986
1020
  appendCharSafeW(filename, SEP, sizeof(filename) / sizeof(wchar_t));
987
- appendModuleNameAsPathW(filename, entry->name, sizeof(filename) / sizeof(wchar_t));
1021
+ appendModuleNameAsPathW(filename, module_name, sizeof(filename) / sizeof(wchar_t));
988
1022
  appendStringSafeW(filename, ".pyd", sizeof(filename) / sizeof(wchar_t));
989
1023
  #else
990
1024
  char filename[MAXPATHLEN + 1] = {0};
@@ -1114,7 +1148,7 @@ static PyObject *_EXECUTE_EMBEDDED_MODULE(PyThreadState *tstate, PyObject *modul
1114
1148
  return result;
1115
1149
  }
1116
1150
 
1117
- Py_INCREF(Py_None);
1151
+ Py_INCREF_IMMORTAL(Py_None);
1118
1152
  return Py_None;
1119
1153
  }
1120
1154
 
@@ -1222,7 +1256,7 @@ static PyObject *_nuitka_loader_is_package(PyObject *self, PyObject *args, PyObj
1222
1256
  result = Py_None;
1223
1257
  }
1224
1258
 
1225
- Py_INCREF(result);
1259
+ Py_INCREF_IMMORTAL(result);
1226
1260
  return result;
1227
1261
  }
1228
1262
 
@@ -1237,7 +1271,9 @@ static PyObject *_nuitka_loader_iter_modules(struct Nuitka_LoaderObject *self, P
1237
1271
  return NULL;
1238
1272
  }
1239
1273
 
1240
- PyObject *result = MAKE_LIST_EMPTY(0);
1274
+ NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
1275
+
1276
+ PyObject *result = MAKE_LIST_EMPTY(tstate, 0);
1241
1277
 
1242
1278
  struct Nuitka_MetaPathBasedLoaderEntry *current = loader_entries;
1243
1279
  assert(current);
@@ -1293,9 +1329,9 @@ static PyObject *_nuitka_loader_iter_modules(struct Nuitka_LoaderObject *self, P
1293
1329
  Py_DECREF(old);
1294
1330
  }
1295
1331
 
1296
- PyObject *r = MAKE_TUPLE_EMPTY(2);
1332
+ PyObject *r = MAKE_TUPLE_EMPTY(tstate, 2);
1297
1333
  PyTuple_SET_ITEM(r, 0, name);
1298
- PyTuple_SET_ITEM0(r, 1, BOOL_FROM((current->flags & NUITKA_PACKAGE_FLAG) != 0));
1334
+ PyTuple_SET_ITEM_IMMORTAL(r, 1, BOOL_FROM((current->flags & NUITKA_PACKAGE_FLAG) != 0));
1299
1335
 
1300
1336
  LIST_APPEND1(result, r);
1301
1337
 
@@ -1448,7 +1484,7 @@ static PyObject *createModuleSpec(PyThreadState *tstate, PyObject *module_name,
1448
1484
  return NULL;
1449
1485
  }
1450
1486
 
1451
- PyObject *args = MAKE_TUPLE2(module_name, (PyObject *)&Nuitka_Loader_Type);
1487
+ PyObject *args = MAKE_TUPLE2(tstate, module_name, (PyObject *)&Nuitka_Loader_Type);
1452
1488
 
1453
1489
  PyObject *kw_values[] = {is_package ? Py_True : Py_False, origin};
1454
1490
 
@@ -1534,7 +1570,7 @@ static PyObject *_nuitka_loader_find_spec(PyObject *self, PyObject *args, PyObje
1534
1570
  PySys_WriteStderr("import %s # denied responsibility\n", full_name);
1535
1571
  }
1536
1572
 
1537
- Py_INCREF(Py_None);
1573
+ Py_INCREF_IMMORTAL(Py_None);
1538
1574
  return Py_None;
1539
1575
  }
1540
1576
 
@@ -1674,13 +1710,13 @@ static PyObject *_nuitka_loader_find_distributions(PyObject *self, PyObject *arg
1674
1710
  return NULL;
1675
1711
  }
1676
1712
 
1677
- PyObject *temp = MAKE_LIST_EMPTY(0);
1713
+ PyThreadState *tstate = PyThreadState_GET();
1714
+
1715
+ PyObject *temp = MAKE_LIST_EMPTY(tstate, 0);
1678
1716
 
1679
1717
  Py_ssize_t pos = 0;
1680
1718
  PyObject *distribution_name;
1681
1719
 
1682
- PyThreadState *tstate = PyThreadState_GET();
1683
-
1684
1720
  while (Nuitka_DistributionNext(&pos, &distribution_name)) {
1685
1721
  bool include = false;
1686
1722
  if (name == Py_None) {
@@ -111,7 +111,7 @@ static PyObject *Nuitka_ResourceReaderFiles_iterdir(struct Nuitka_ResourceReader
111
111
  return NULL;
112
112
  }
113
113
 
114
- PyObject *files_objects = MAKE_LIST_EMPTY(0);
114
+ PyObject *files_objects = MAKE_LIST_EMPTY(tstate, 0);
115
115
 
116
116
  Py_ssize_t n = PyList_GET_SIZE(file_names);
117
117
  for (Py_ssize_t i = 0; i < n; i++) {
@@ -418,7 +418,7 @@ static PyObject *Nuitka_ResourceReaderFiles_enter(struct Nuitka_ResourceReaderFi
418
418
  static PyObject *Nuitka_ResourceReaderFiles_exit(struct Nuitka_ResourceReaderFilesObject *files) {
419
419
  CHECK_OBJECT(files);
420
420
 
421
- Py_INCREF(Py_None);
421
+ Py_INCREF_IMMORTAL(Py_None);
422
422
  return Py_None;
423
423
  }
424
424
 
@@ -67,6 +67,7 @@
67
67
  #define _NUITKA_AUTO_UPDATE_DEBUG_BOOL 1
68
68
  #define _NUITKA_AUTO_UPDATE_URL_SPEC "https://..."
69
69
 
70
+ #define _NUITKA_ATTACH_CONSOLE_WINDOW 1
70
71
  #endif
71
72
 
72
73
  #if _NUITKA_ONEFILE_COMPRESSION_BOOL == 1
@@ -105,6 +106,10 @@
105
106
  #include "HelpersFilesystemPaths.c"
106
107
  #include "HelpersSafeStrings.c"
107
108
 
109
+ #if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
110
+ #include "HelpersConsole.c"
111
+ #endif
112
+
108
113
  // For tracing outputs if enabled at compile time.
109
114
  #include "nuitka/tracing.h"
110
115
 
@@ -137,22 +142,6 @@ static void fatalErrorMemory(void) { fatalError("Error, couldn't allocate memory
137
142
  // Could not launch child process.
138
143
  static void fatalErrorChild(char const *message, error_code_t error_code) { fatalIOError(message, error_code); }
139
144
 
140
- #if defined(_WIN32)
141
- static void appendWCharSafeW(wchar_t *target, wchar_t c, size_t buffer_size) {
142
- while (*target != 0) {
143
- target++;
144
- buffer_size -= 1;
145
- }
146
-
147
- if (buffer_size < 1) {
148
- abort();
149
- }
150
-
151
- *target++ = c;
152
- *target = 0;
153
- }
154
- #endif
155
-
156
145
  static void fatalErrorTempFileCreate(filename_char_t const *filename) {
157
146
  fprintf(stderr, "Error, failed to open '" FILENAME_FORMAT_STR "' for writing.\n", filename);
158
147
  exit(2);
@@ -993,6 +982,12 @@ int wmain(int argc, wchar_t **argv) {
993
982
  int main(int argc, char **argv) {
994
983
  #endif
995
984
  #endif
985
+ // Attach to the parent console respecting redirection only, otherwise we cannot
986
+ // even output traces.
987
+ #if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
988
+ inheritAttachedConsole();
989
+ #endif
990
+
996
991
  NUITKA_PRINT_TIMING("ONEFILE: Entered main().");
997
992
 
998
993
  filename_char_t const *pattern = FILENAME_EMPTY_STR _NUITKA_ONEFILE_TEMP_SPEC;
@@ -1240,6 +1235,10 @@ int main(int argc, char **argv) {
1240
1235
 
1241
1236
  STARTUPINFOW si;
1242
1237
  memset(&si, 0, sizeof(si));
1238
+ si.dwFlags = STARTF_USESTDHANDLES;
1239
+ si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
1240
+ si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
1241
+ si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
1243
1242
  si.cb = sizeof(si);
1244
1243
 
1245
1244
  PROCESS_INFORMATION pi;
@@ -1248,7 +1247,7 @@ int main(int argc, char **argv) {
1248
1247
  GetCommandLineW(), // command line
1249
1248
  NULL, // process attributes
1250
1249
  NULL, // thread attributes
1251
- FALSE, // inherit handles
1250
+ TRUE, // inherit handles
1252
1251
  NORMAL_PRIORITY_CLASS, // creation flags
1253
1252
  NULL, NULL, &si, &pi);
1254
1253
 
@@ -283,6 +283,7 @@ from .PackageResourceCodes import (
283
283
  generateOsPathIsabsCallCode,
284
284
  generateOsPathIsdirCallCode,
285
285
  generateOsPathIsfileCallCode,
286
+ generateOsPathNormpathCallCode,
286
287
  generateOsUnameCallCode,
287
288
  generatePkglibGetDataCallCode,
288
289
  generatePkgResourcesDistributionValueCode,
@@ -339,7 +340,7 @@ from .StringCodes import (
339
340
  from .SubscriptCodes import (
340
341
  generateAssignmentSubscriptCode,
341
342
  generateDelSubscriptCode,
342
- generateSubscriptCheckCode,
343
+ generateMatchSubscriptCheckCode,
343
344
  generateSubscriptLookupCode,
344
345
  )
345
346
  from .TensorflowCodes import generateTensorflowFunctionCallCode
@@ -847,7 +848,7 @@ addExpressionDispatchDict(
847
848
  "EXPRESSION_CLASS_BODY_P3": generateFunctionOutlineCode,
848
849
  "EXPRESSION_SUBSCRIPT_LOOKUP": generateSubscriptLookupCode,
849
850
  "EXPRESSION_SUBSCRIPT_LOOKUP_FOR_UNPACK": generateSubscriptLookupCode,
850
- "EXPRESSION_SUBSCRIPT_CHECK": generateSubscriptCheckCode,
851
+ "EXPRESSION_MATCH_SUBSCRIPT_CHECK": generateMatchSubscriptCheckCode,
851
852
  "EXPRESSION_SLICE_LOOKUP": generateSliceLookupCode,
852
853
  "EXPRESSION_SET_OPERATION_UPDATE": generateSetOperationUpdateCode,
853
854
  "EXPRESSION_SIDE_EFFECTS": generateSideEffectsCode,
@@ -911,6 +912,7 @@ addExpressionDispatchDict(
911
912
  "EXPRESSION_OS_PATH_DIRNAME_REF": generateImportModuleNameHardCode,
912
913
  "EXPRESSION_OS_PATH_BASENAME_REF": generateImportModuleNameHardCode,
913
914
  "EXPRESSION_OS_PATH_ABSPATH_REF": generateImportModuleNameHardCode,
915
+ "EXPRESSION_OS_PATH_NORMPATH_REF": generateImportModuleNameHardCode,
914
916
  "EXPRESSION_BUILTINS_OPEN_REF": generateImportModuleNameHardCode,
915
917
  "EXPRESSION_CTYPES_CDLL_REF": generateImportModuleNameHardCode,
916
918
  "EXPRESSION_CTYPES_CDLL_SINCE38_CALL": generateCtypesCdllCallCode,
@@ -940,6 +942,7 @@ addExpressionDispatchDict(
940
942
  "EXPRESSION_OS_PATH_BASENAME_CALL": generateOsPathBasenameCallCode,
941
943
  "EXPRESSION_OS_PATH_DIRNAME_CALL": generateOsPathDirnameCallCode,
942
944
  "EXPRESSION_OS_PATH_ABSPATH_CALL": generateOsPathAbspathCallCode,
945
+ "EXPRESSION_OS_PATH_NORMPATH_CALL": generateOsPathNormpathCallCode,
943
946
  "EXPRESSION_OS_PATH_ISABS_CALL": generateOsPathIsabsCallCode,
944
947
  "EXPRESSION_OS_LISTDIR_CALL": generateOsListdirCallCode,
945
948
  "EXPRESSION_MATCH_ARGS": generateMatchArgsCode,
@@ -19,7 +19,7 @@ import sys
19
19
  from nuitka import Options
20
20
  from nuitka.ModuleRegistry import getRootTopModule
21
21
  from nuitka.PythonVersions import python_version
22
- from nuitka.Serialization import ConstantAccessor
22
+ from nuitka.Serialization import GlobalConstantAccessor
23
23
  from nuitka.utils.CStrings import encodePythonStringToC
24
24
  from nuitka.utils.Distributions import getDistributionTopLevelPackageNames
25
25
  from nuitka.Version import getNuitkaVersionTuple
@@ -86,7 +86,7 @@ def getConstantsDefinitionCode():
86
86
  """
87
87
  # Somewhat detail rich, pylint: disable=too-many-locals
88
88
 
89
- constant_accessor = ConstantAccessor(
89
+ constant_accessor = GlobalConstantAccessor(
90
90
  data_filename="__constants.const", top_level_name="global_constants"
91
91
  )
92
92
 
@@ -272,7 +272,7 @@ if (%(value_name)s == NULL) {
272
272
  if (%(value_name)s == NULL && !HAS_ERROR_OCCURRED(tstate)) {
273
273
  {% endif %}
274
274
  %(value_name)s = Py_None;
275
- Py_INCREF(%(value_name)s);
275
+ Py_INCREF_IMMORTAL(%(value_name)s);
276
276
  }
277
277
  """,
278
278
  expression=expression,
@@ -541,7 +541,7 @@ def generateDictOperationCopyCode(to_name, expression, emit, context):
541
541
  generateCAPIObjectCode(
542
542
  to_name=to_name,
543
543
  capi="DICT_COPY",
544
- tstate=False,
544
+ tstate=True,
545
545
  arg_desc=(("dict_arg", expression.subnode_dict_arg),),
546
546
  may_raise=False,
547
547
  conversion_check=decideConversionCheckNeeded(to_name, expression),