bpo-34207: Fix pymain_init_cmdline_argv() by vstinner · Pull Request #8867 · python/cpython (original) (raw)
bpo-34170, bpo-34207: Fix pymain_init_cmdline_argv()
- Add _Py_DecodeUTF8()
- pymain_init_cmdline_argv() now calls directly _Py_DecodeUTF8() if
the UTF-8 mode is enabled
Previously, pymain_init_cmdline_argv() always called
Py_DecodeLocale() which depends on Py_UTF8Mode, whereas this variable
is no longer modified when reading the current configuration.
bpo-34170, bpo-34207: Fix pymain_init_cmdline_argv()
- Add _Py_DecodeUTF8()
- pymain_init_cmdline_argv() now calls directly _Py_DecodeUTF8() if the UTF-8 mode is enabled
Previously, pymain_init_cmdline_argv() always called Py_DecodeLocale() which depends on Py_UTF8Mode, whereas this variable is no longer modified when reading the current configuration.
I tested manually that this change fix test_cmd_line on FreeBSD when run in an empty environment:
vstinner@freebsd$ env -i ./python -m test test_cmd_line
Run tests sequentially
0:00:00 load avg: 0.41 [1/1] test_cmd_line
== Tests result: SUCCESS ==
1 test OK.
Total duration: 5 sec 600 ms
Tests result: SUCCESS
I'm not sure that this change is enough: _PyCoreConfig_Read() calls _PyCoreConfig_InitPathConfig() which later indirectly calls _Py_EncodeLocaleRaw() which also depends on Py_UTF8Mode.
Hum, this PR is incomplete because of Py_EncodeLocale() and similar functions. I wrote PR #8868 which is more generic and so safer.