diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-09-21 21:49:01 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-09-21 21:49:01 (GMT) |
commit | d0db98fcd869605f28dc600bfeba032565e31855 (patch) | |
tree | 53f5bf2a39d7c68972cb106bde9768375178fc63 /Python | |
parent | 956ffd75af881353fd59d61eb787df1512f0b59e (diff) | |
download | cpython-d0db98fcd869605f28dc600bfeba032565e31855.zip cpython-d0db98fcd869605f28dc600bfeba032565e31855.tar.gz cpython-d0db98fcd869605f28dc600bfeba032565e31855.tar.bz2 |
#1688: On Windows, the input() prompt was not correctly displayed if it
contains non-ascii characters.
Reviewed by Benjamin Peterson.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 7c08765..0b96dc1 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1597,12 +1597,29 @@ builtin_input(PyObject *self, PyObject *args) else Py_DECREF(tmp); if (promptarg != NULL) { - po = PyObject_Str(promptarg); + PyObject *stringpo; + PyObject *stdout_encoding; + stdout_encoding = PyObject_GetAttrString(fout, + "encoding"); + if (stdout_encoding == NULL) { + Py_DECREF(stdin_encoding); + return NULL; + } + stringpo = PyObject_Str(promptarg); + if (stringpo == NULL) { + Py_DECREF(stdin_encoding); + Py_DECREF(stdout_encoding); + return NULL; + } + po = PyUnicode_AsEncodedString(stringpo, + _PyUnicode_AsString(stdout_encoding), NULL); + Py_DECREF(stdout_encoding); + Py_DECREF(stringpo); if (po == NULL) { Py_DECREF(stdin_encoding); return NULL; } - prompt = _PyUnicode_AsString(po); + prompt = PyBytes_AsString(po); if (prompt == NULL) { Py_DECREF(stdin_encoding); Py_DECREF(po); |