summaryrefslogtreecommitdiff
path: root/Modules/_cursesmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-09-01 15:00:34 +0200
committerVictor Stinner <victor.stinner@gmail.com>2012-09-01 15:00:34 +0200
commit9f16e44a479d9efdfd4315df93a9e83901ef96b5 (patch)
tree378517003ed38549a8f431c1e0e09de928ad745f /Modules/_cursesmodule.c
parentdbf56c2ef396311e4997e4631ce9a701b0f151f2 (diff)
downloadcpython-git-9f16e44a479d9efdfd4315df93a9e83901ef96b5.tar.gz
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.
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r--Modules/_cursesmodule.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 0436e7fec8..3f9ca1313d 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -280,7 +280,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
#endif
)
{
- int ret = 0;
long value;
#ifdef HAVE_NCURSESW
wchar_t buffer[2];
@@ -304,7 +303,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
}
else if(PyBytes_Check(obj) && PyBytes_Size(obj) == 1) {
value = (unsigned char)PyBytes_AsString(obj)[0];
- ret = 1;
}
else if (PyLong_CheckExact(obj)) {
int overflow;
@@ -314,11 +312,6 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
"int doesn't fit in long");
return 0;
}
-#ifdef HAVE_NCURSESW
- ret = 2;
-#else
- ret = 1;
-#endif
}
else {
PyErr_Format(PyExc_TypeError,
@@ -326,27 +319,14 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
Py_TYPE(obj)->tp_name);
return 0;
}
-#ifdef HAVE_NCURSESW
- if (ret == 2) {
- memset(wch->chars, 0, sizeof(wch->chars));
- wch->chars[0] = (wchar_t)value;
- if ((long)wch->chars[0] != value) {
- PyErr_Format(PyExc_OverflowError,
- "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;
- }
+
+ *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