[Python-checkins] r75249 - in python/branches/release31-maint: Lib/test/test_curses.py Modules/_cursesmodule.c
benjamin.peterson
python-checkins at python.org
Sun Oct 4 22:41:57 CEST 2009
Author: benjamin.peterson
Date: Sun Oct 4 22:41:56 2009
New Revision: 75249
Log:
Merged revisions 75248 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r75248 | benjamin.peterson | 2009-10-04 15:40:17 -0500 (Sun, 04 Oct 2009) | 11 lines
Merged revisions 75066 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75066 | andrew.kuchling | 2009-09-25 17:23:54 -0500 (Fri, 25 Sep 2009) | 4 lines
#6243: fix segfault when keyname() returns a NULL pointer.
Bug noted by Trundle, patched by Trundle and Jerry Chen.
........
................
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Lib/test/test_curses.py
python/branches/release31-maint/Modules/_cursesmodule.c
Modified: python/branches/release31-maint/Lib/test/test_curses.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_curses.py (original)
+++ python/branches/release31-maint/Lib/test/test_curses.py Sun Oct 4 22:41:56 2009
@@ -259,6 +259,10 @@
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
raise RuntimeError("Expected resizeterm to update LINES and COLS")
+def test_issue6243(stdscr):
+ curses.ungetch(1025)
+ stdscr.getkey()
+
def main(stdscr):
curses.savetty()
try:
@@ -266,6 +270,7 @@
window_funcs(stdscr)
test_userptr_without_set(stdscr)
test_resize_term(stdscr)
+ test_issue6243(stdscr)
finally:
curses.resetty()
Modified: python/branches/release31-maint/Modules/_cursesmodule.c
==============================================================================
--- python/branches/release31-maint/Modules/_cursesmodule.c (original)
+++ python/branches/release31-maint/Modules/_cursesmodule.c Sun Oct 4 22:41:56 2009
@@ -890,14 +890,17 @@
/* getch() returns ERR in nodelay mode */
PyErr_SetString(PyCursesError, "no input");
return NULL;
- } else if (rtn<=255)
+ } else if (rtn<=255) {
return Py_BuildValue("C", rtn);
- else
+ } else {
+ const char *knp;
#if defined(__NetBSD__)
- return PyUnicode_FromString(unctrl(rtn));
+ knp = unctrl(rtn);
#else
- return PyUnicode_FromString((const char *)keyname(rtn));
+ knp = keyname(rtn);
#endif
+ return PyUnicode_FromString((knp == NULL) ? "" : knp);
+ }
}
static PyObject *
More information about the Python-checkins
mailing list