diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-04-16 18:34:01 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-04-16 18:34:01 +0200 |
commit | dc8a29d38b13f96d6e61aef115f511b78df7f313 (patch) | |
tree | 3210bc0e0f1d10d37b9b4df22f96ebc11dbaf3b5 /Python/pythonrun.c | |
parent | 3e82548ad7ca38a76cf4983b64bc4cd7f019bda2 (diff) | |
parent | 0d35e22fe449f9b3dd6a5ef09f2ce98aeb3f6fdc (diff) | |
download | cpython-dc8a29d38b13f96d6e61aef115f511b78df7f313.tar.gz |
Try to fix buildbot failures on old OpenSSLs (< 1.0.0) - followup to issue #21015
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 e9947e9ff6..3f460562c0 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 @@ -1156,6 +1156,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; @@ -1168,7 +1177,7 @@ initstdio(void) if (err) { *err = '\0'; err++; - if (*err && !errors) { + if (*err && !_Py_StandardStreamErrors) { errors = err; } } |