diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2014-08-14 08:35:15 +0300 |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2014-08-14 08:35:15 +0300 |
commit | 1abac40e0ead80734f2b1f7ecd5de0abd3a598aa (patch) | |
tree | 14c45ca016abf83c23315fabe344cd18495f29fa /Python/pythonrun.c | |
parent | 85b14a3c9a36f2581beaa6b4e9ab8b7b143322d0 (diff) | |
parent | 5be034cf6165724587beb18dca9e5b7682442a74 (diff) | |
download | cpython-1abac40e0ead80734f2b1f7ecd5de0abd3a598aa.tar.gz |
Issue #21445: Pass exception messages correctly to assertTrue in
the FileCompareTestCase.test_matching test.
Patch by Steven Barker.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 0327830247..b2d5464191 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -15,6 +15,7 @@ #include "ast.h" #include "marshal.h" #include "osdefs.h" +#include <locale.h> #ifdef HAVE_SIGNAL_H #include <signal.h> @@ -25,7 +26,6 @@ #endif #ifdef HAVE_LANGINFO_H -#include <locale.h> #include <langinfo.h> #endif @@ -1160,6 +1160,15 @@ initstdio(void) encoding = _Py_StandardStreamEncoding; errors = _Py_StandardStreamErrors; if (!encoding || !errors) { + if (!errors) { + /* When the LC_CTYPE locale is the POSIX locale ("C locale"), + stdin and stdout use the surrogateescape error handler by + default, instead of the strict error handler. */ + char *loc = setlocale(LC_CTYPE, NULL); + if (loc != NULL && strcmp(loc, "C") == 0) + errors = "surrogateescape"; + } + pythonioencoding = Py_GETENV("PYTHONIOENCODING"); if (pythonioencoding) { char *err; @@ -1172,7 +1181,7 @@ initstdio(void) if (err) { *err = '\0'; err++; - if (*err && !errors) { + if (*err && !_Py_StandardStreamErrors) { errors = err; } } |