diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-08-16 04:44:06 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-08-16 04:44:06 (GMT) |
commit | cc2e80be641238f48bdc6d53f09666c904fd17f7 (patch) | |
tree | db234f5d55d9ccfa22bd9bd5b811ccac319774f5 | |
parent | 939231be0e4662154838414934bf0d759d6f45cb (diff) | |
parent | b1c6bdc76a1ac7bc40850f75dbc2dff0b361ee3d (diff) | |
download | cpython-cc2e80be641238f48bdc6d53f09666c904fd17f7.zip cpython-cc2e80be641238f48bdc6d53f09666c904fd17f7.tar.gz cpython-cc2e80be641238f48bdc6d53f09666c904fd17f7.tar.bz2 |
merge 3.5
-rw-r--r-- | Lib/test/test_curses.py | 2 | ||||
-rw-r--r-- | Misc/NEWS | 4 | ||||
-rw-r--r-- | Modules/_cursesmodule.c | 8 |
3 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 6bbb3fc..87c536f 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -190,6 +190,8 @@ class TestCurses(unittest.TestCase): self.assertRaises(ValueError, stdscr.getstr, -400) self.assertRaises(ValueError, stdscr.getstr, 2, 3, -400) + self.assertRaises(ValueError, stdscr.instr, -2) + self.assertRaises(ValueError, stdscr.instr, 2, 3, -2) def test_module_funcs(self): @@ -102,8 +102,8 @@ Library - Issue #27661: Added tzinfo keyword argument to datetime.combine. -- In the curses module, raise an error if window.getstr() is passed a negative - value. +- In the curses module, raise an error if window.getstr() or window.instr() is + passed a negative value. - Issue #27760: Fix possible integer overflow in binascii.b2a_qp. diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 06aa46c..960752c 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1393,6 +1393,10 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) case 1: if (!PyArg_ParseTuple(args,"i;n", &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative"); + return NULL; + } rtn2 = winnstr(self->win, rtn, Py_MIN(n, 1023)); break; case 2: @@ -1403,6 +1407,10 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) case 3: if (!PyArg_ParseTuple(args, "iii;y,x,n", &y, &x, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative"); + return NULL; + } rtn2 = mvwinnstr(self->win, y, x, rtn, Py_MIN(n,1023)); break; default: |