diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-09-23 13:59:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-23 13:59:00 (GMT) |
commit | c5c642565e260477ae2fb29d0c86a91e19702ae3 (patch) | |
tree | b0ff8adcdf73332394a51288b3c9cef7373a9117 /Objects | |
parent | fe9089a08b6dd6dd1ba8b238afc2fc4dfaac689e (diff) | |
download | cpython-c5c642565e260477ae2fb29d0c86a91e19702ae3.zip cpython-c5c642565e260477ae2fb29d0c86a91e19702ae3.tar.gz cpython-c5c642565e260477ae2fb29d0c86a91e19702ae3.tar.bz2 |
bpo-38236: Dump path config at first import error (GH-16300) (GH-16332)
Python now dumps path configuration if it fails to import the Python
codecs of the filesystem and stdio encodings.
(cherry picked from commit fcdb027234566c4d506d6d753c7d5638490fb088)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 2afc28d..1466e8a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -15727,13 +15727,13 @@ error: static PyStatus -init_stdio_encoding(PyInterpreterState *interp) +init_stdio_encoding(PyThreadState *tstate) { /* Update the stdio encoding to the normalized Python codec name. */ - PyConfig *config = &interp->config; + PyConfig *config = &tstate->interp->config; if (config_get_codec_name(&config->stdio_encoding) < 0) { return _PyStatus_ERR("failed to get the Python codec name " - "of the stdio encoding"); + "of the stdio encoding"); } return _PyStatus_OK(); } @@ -15787,15 +15787,18 @@ init_fs_codec(PyInterpreterState *interp) static PyStatus -init_fs_encoding(PyInterpreterState *interp) +init_fs_encoding(PyThreadState *tstate) { + PyInterpreterState *interp = tstate->interp; + /* Update the filesystem encoding to the normalized Python codec name. For example, replace "ANSI_X3.4-1968" (locale encoding) with "ascii" (Python codec name). */ PyConfig *config = &interp->config; if (config_get_codec_name(&config->filesystem_encoding) < 0) { + _Py_DumpPathConfig(tstate); return _PyStatus_ERR("failed to get the Python codec " - "of the filesystem encoding"); + "of the filesystem encoding"); } if (init_fs_codec(interp) < 0) { @@ -15806,14 +15809,14 @@ init_fs_encoding(PyInterpreterState *interp) PyStatus -_PyUnicode_InitEncodings(PyInterpreterState *interp) +_PyUnicode_InitEncodings(PyThreadState *tstate) { - PyStatus status = init_fs_encoding(interp); + PyStatus status = init_fs_encoding(tstate); if (_PyStatus_EXCEPTION(status)) { return status; } - return init_stdio_encoding(interp); + return init_stdio_encoding(tstate); } |