From 745e56cd8f87f5cee7db8d1aa1a6adde3a24d14a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 18 Mar 2014 01:18:21 +0100 Subject: Issue #19977: When the ``LC_TYPE`` locale is the POSIX locale (``C`` locale), :py:data:`sys.stdin` and :py:data:`sys.stdout` are now using the ``surrogateescape`` error handler, instead of the ``strict`` error handler. --- Python/pythonrun.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index e9947e9ff6..bb9f425fb1 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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; } } -- cgit v1.2.1 From d0f76fb4b57137d676c1abd141e153b3ada84b43 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 18 Mar 2014 02:06:38 +0100 Subject: Issue #19977, #19036: Always include in pythonrun.c to get LC_CTYPE constant on Windows. --- Python/pythonrun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index bb9f425fb1..3f460562c0 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -15,6 +15,7 @@ #include "ast.h" #include "marshal.h" #include "osdefs.h" +#include #ifdef HAVE_SIGNAL_H #include @@ -25,7 +26,6 @@ #endif #ifdef HAVE_LANGINFO_H -#include #include #endif -- cgit v1.2.1 From e61cceeeacea42566240bc7635bc8cc2f4168cf1 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 15 Aug 2014 23:30:40 +0200 Subject: Issue #22156: Fix "comparison between signed and unsigned integers" compiler warnings in the Python/ subdirectory. --- Python/pythonrun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index b2d5464191..63d9eeb689 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1738,7 +1738,7 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj) return; if (offset >= 0) { - if (offset > 0 && offset == strlen(text) && text[offset - 1] == '\n') + if (offset > 0 && (size_t)offset == strlen(text) && text[offset - 1] == '\n') offset--; for (;;) { nl = strchr(text, '\n'); -- cgit v1.2.1