diff options
author | Tim Peters <tim@python.org> | 2014-05-08 17:43:25 -0500 |
---|---|---|
committer | Tim Peters <tim@python.org> | 2014-05-08 17:43:25 -0500 |
commit | 60e53efd0469216f6da024b116330ff008fb81ff (patch) | |
tree | 27ecf9fc560ccf370c7781709235c5397cc0d1a8 /Python/pythonrun.c | |
parent | 99c4936cf50197c654545b24fc625b7454ea42da (diff) | |
parent | 74339a075353dfb9256d2b746b4cd1daf78d2736 (diff) | |
download | cpython-60e53efd0469216f6da024b116330ff008fb81ff.tar.gz |
Merge from 3.4.
Issue #21435: Segfault in gc with cyclic trash
Changed the iteration logic in finalize_garbage() to tolerate objects vanishing
from the list as a side effect of executing a finalizer.
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 b3991ead91..4fd51499c7 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; } } |