Skip to content

Commit b1c6bdc

Browse files
committed
merge 3.4
2 parents aa9560c + 432ea4f commit b1c6bdc

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎Lib/test/test_curses.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ def test_window_funcs(self):
190190

191191
self.assertRaises(ValueError, stdscr.getstr, -400)
192192
self.assertRaises(ValueError, stdscr.getstr, 2, 3, -400)
193+
self.assertRaises(ValueError, stdscr.instr, -2)
194+
self.assertRaises(ValueError, stdscr.instr, 2, 3, -2)
193195

194196

195197
def test_module_funcs(self):

‎Misc/NEWS‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Library
3737
- Issue #26750: unittest.mock.create_autospec() now works properly for
3838
subclasses of property() and other data descriptors.
3939

40-
- In the curses module, raise an error if window.getstr() is passed a negative
41-
value.
40+
- In the curses module, raise an error if window.getstr() or window.instr() is
41+
passed a negative value.
4242

4343
- Issue #27760: Fix possible integer overflow in binascii.b2a_qp.
4444

‎Modules/_cursesmodule.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,10 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args)
13931393
case 1:
13941394
if (!PyArg_ParseTuple(args,"i;n", &n))
13951395
return NULL;
1396+
if (n < 0) {
1397+
PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative");
1398+
return NULL;
1399+
}
13961400
rtn2 = winnstr(self->win, rtn, Py_MIN(n, 1023));
13971401
break;
13981402
case 2:
@@ -1403,6 +1407,10 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args)
14031407
case 3:
14041408
if (!PyArg_ParseTuple(args, "iii;y,x,n", &y, &x, &n))
14051409
return NULL;
1410+
if (n < 0) {
1411+
PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative");
1412+
return NULL;
1413+
}
14061414
rtn2 = mvwinnstr(self->win, y, x, rtn, Py_MIN(n,1023));
14071415
break;
14081416
default:

0 commit comments

Comments
 (0)