Kaydet (Commit) 9f16e44a authored tarafından Victor Stinner's avatar Victor Stinner

Close #14223: Fix window.addch(curses.ACS_HLINE)

Fix window.addch() of the curses module for special characters like
curses.ACS_HLINE: the Python function addch(int) and addch(bytes) is now
calling the C function waddch()/mvwaddch() (as it was done in Python 3.2),
instead of wadd_wch()/mvwadd_wch(). The Python function addch(str) is still
calling the C function wadd_wch()/mvwadd_wch() if the Python curses is linked
to libncursesw.
üst dbf56c2e
...@@ -73,6 +73,13 @@ Library ...@@ -73,6 +73,13 @@ Library
always returning an integer. So it is now possible to distinguish special always returning an integer. So it is now possible to distinguish special
keys like keypad keys. keys like keypad keys.
- Issue #14223: Fix window.addch() of the curses module for special characters
like curses.ACS_HLINE: the Python function addch(int) and addch(bytes) is now
calling the C function waddch()/mvwaddch() (as it was done in Python 3.2),
instead of wadd_wch()/mvwadd_wch(). The Python function addch(str) is still
calling the C function wadd_wch()/mvwadd_wch() if the Python curses is linked
to libncursesw.
What's New in Python 3.3.0 Release Candidate 1? What's New in Python 3.3.0 Release Candidate 1?
=============================================== ===============================================
......
...@@ -280,7 +280,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj, ...@@ -280,7 +280,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
#endif #endif
) )
{ {
int ret = 0;
long value; long value;
#ifdef HAVE_NCURSESW #ifdef HAVE_NCURSESW
wchar_t buffer[2]; wchar_t buffer[2];
...@@ -304,7 +303,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj, ...@@ -304,7 +303,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
} }
else if(PyBytes_Check(obj) && PyBytes_Size(obj) == 1) { else if(PyBytes_Check(obj) && PyBytes_Size(obj) == 1) {
value = (unsigned char)PyBytes_AsString(obj)[0]; value = (unsigned char)PyBytes_AsString(obj)[0];
ret = 1;
} }
else if (PyLong_CheckExact(obj)) { else if (PyLong_CheckExact(obj)) {
int overflow; int overflow;
...@@ -314,11 +312,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj, ...@@ -314,11 +312,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
"int doesn't fit in long"); "int doesn't fit in long");
return 0; return 0;
} }
#ifdef HAVE_NCURSESW
ret = 2;
#else
ret = 1;
#endif
} }
else { else {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
...@@ -326,27 +319,14 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj, ...@@ -326,27 +319,14 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
Py_TYPE(obj)->tp_name); Py_TYPE(obj)->tp_name);
return 0; return 0;
} }
#ifdef HAVE_NCURSESW
if (ret == 2) { *ch = (chtype)value;
memset(wch->chars, 0, sizeof(wch->chars)); if ((long)*ch != value) {
wch->chars[0] = (wchar_t)value; PyErr_Format(PyExc_OverflowError,
if ((long)wch->chars[0] != value) { "byte doesn't fit in chtype");
PyErr_Format(PyExc_OverflowError, return 0;
"character doesn't fit in wchar_t");
return 0;
}
}
else
#endif
{
*ch = (chtype)value;
if ((long)*ch != value) {
PyErr_Format(PyExc_OverflowError,
"byte doesn't fit in chtype");
return 0;
}
} }
return ret; return 1;
} }
/* Convert an object to a byte string (char*) or a wide character string /* Convert an object to a byte string (char*) or a wide character string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment