summaryrefslogtreecommitdiffstats
path: root/Modules/getpath.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2018-01-15 09:45:49 (GMT)
committerGitHub <noreply@github.com>2018-01-15 09:45:49 (GMT)
commit7ed7aead9503102d2ed316175f198104e0cd674c (patch)
tree0b70b3b7d2eed5ea92552c1b93953d0333f5a869 /Modules/getpath.c
parentee3b83547c6b0cac1da2cb44aaaea533a1d1bbc8 (diff)
downloadcpython-7ed7aead9503102d2ed316175f198104e0cd674c.zip
cpython-7ed7aead9503102d2ed316175f198104e0cd674c.tar.gz
cpython-7ed7aead9503102d2ed316175f198104e0cd674c.tar.bz2
bpo-29240: Fix locale encodings in UTF-8 Mode (#5170)
Modify locale.localeconv(), time.tzname, os.strerror() and other functions to ignore the UTF-8 Mode: always use the current locale encoding. Changes: * Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or encoding error, they return the position of the error and an error message which are used to raise Unicode errors in PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale(). * Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx(). * PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all cases, especially for the strict error handler. * Add _Py_DecodeUTF8Ex(): return more information on decoding error and supports the strict error handler. * Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex(). * Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx(). * Ignore the UTF-8 mode to encode/decode localeconv(), strerror() and time zone name. * Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize() and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use the "current" locale. * Remove _PyUnicode_DecodeCurrentLocale(), _PyUnicode_DecodeCurrentLocaleAndSize() and _PyUnicode_EncodeCurrentLocale().
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r--Modules/getpath.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 85e737b..e6a3e8e 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -449,8 +449,8 @@ search_for_exec_prefix(const _PyCoreConfig *core_config,
n = fread(buf, 1, MAXPATHLEN, f);
buf[n] = '\0';
fclose(f);
- rel_builddir_path = _Py_DecodeUTF8_surrogateescape(buf, n, NULL);
- if (rel_builddir_path != NULL) {
+ rel_builddir_path = _Py_DecodeUTF8_surrogateescape(buf, n);
+ if (rel_builddir_path) {
wcsncpy(exec_prefix, calculate->argv0_path, MAXPATHLEN);
exec_prefix[MAXPATHLEN] = L'\0';
joinpath(exec_prefix, rel_builddir_path);