diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-09-13 08:46:24 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-09-13 08:46:24 (GMT) |
commit | bf28d2dcadbc8fa331df37543b8b36a9cfc38f11 (patch) | |
tree | cb3d959e1cb2b610280b2d8fb23c2a7c538a9e51 /Python/pythonrun.c | |
parent | 187b06300518d35d04454238c240fdfd28864141 (diff) | |
download | cpython-bf28d2dcadbc8fa331df37543b8b36a9cfc38f11.zip cpython-bf28d2dcadbc8fa331df37543b8b36a9cfc38f11.tar.gz cpython-bf28d2dcadbc8fa331df37543b8b36a9cfc38f11.tar.bz2 |
Issue #18818: The "encodingname" part of PYTHONIOENCODING is now optional.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index cbd62aa..c2ca563 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1056,7 +1056,7 @@ initstdio(void) PyObject *std = NULL; int status = 0, fd; PyObject * encoding_attr; - char *encoding = NULL, *errors; + char *pythonioencoding = NULL, *encoding, *errors; /* Hack to avoid a nasty recursion issue when Python is invoked in verbose mode: pre-import the Latin-1 and UTF-8 codecs */ @@ -1088,19 +1088,23 @@ initstdio(void) } Py_DECREF(wrapper); - encoding = Py_GETENV("PYTHONIOENCODING"); - errors = NULL; - if (encoding) { - encoding = _PyMem_Strdup(encoding); - if (encoding == NULL) { + pythonioencoding = Py_GETENV("PYTHONIOENCODING"); + encoding = errors = NULL; + if (pythonioencoding) { + pythonioencoding = _PyMem_Strdup(pythonioencoding); + if (pythonioencoding == NULL) { PyErr_NoMemory(); goto error; } - errors = strchr(encoding, ':'); + errors = strchr(pythonioencoding, ':'); if (errors) { *errors = '\0'; errors++; + if (!*errors) + errors = NULL; } + if (*pythonioencoding) + encoding = pythonioencoding; } /* Set sys.stdin */ @@ -1180,7 +1184,7 @@ initstdio(void) status = -1; } - PyMem_Free(encoding); + PyMem_Free(pythonioencoding); Py_XDECREF(bimod); Py_XDECREF(iomod); return status; |