Discussion:
[Python-3000-checkins] r66545 - in python/branches/py3k: Misc/NEWS Python/bltinmodule.c
amaury.forgeotdarc
2008-09-21 21:49:01 UTC
Permalink
Author: amaury.forgeotdarc
Date: Sun Sep 21 23:49:01 2008
New Revision: 66545

Log:
#1688: On Windows, the input() prompt was not correctly displayed if it
contains non-ascii characters.

Reviewed by Benjamin Peterson.


Modified:
python/branches/py3k/Misc/NEWS
python/branches/py3k/Python/bltinmodule.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sun Sep 21 23:49:01 2008
@@ -12,6 +12,9 @@
Core and Builtins
-----------------

+- Issue #1688: On Windows, the input() prompt was not correctly displayed if it
+ contains non-ascii characters.
+
Library
-------


Modified: python/branches/py3k/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k/Python/bltinmodule.c (original)
+++ python/branches/py3k/Python/bltinmodule.c Sun Sep 21 23:49:01 2008
@@ -1597,12 +1597,29 @@
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);

Loading...