bpo-34207: Fix pymain_init_cmdline_argv() by vstinner · Pull Request #8867 · python/cpython (original) (raw)

vstinner

bpo-34170, bpo-34207: Fix pymain_init_cmdline_argv()

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.

@vstinner

bpo-34170, bpo-34207: Fix pymain_init_cmdline_argv()

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.

@vstinner

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

@vstinner

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.

@vstinner

Hum, this PR is incomplete because of Py_EncodeLocale() and similar functions. I wrote PR #8868 which is more generic and so safer.