[Python-checkins] cpython (merge 3.5 -> default): merge 3.5

benjamin.peterson python-checkins at python.org
Tue Aug 16 00:44:20 EDT 2016


https://hg.python.org/cpython/rev/0052694ec55d
changeset:   102685:0052694ec55d
parent:      102681:4f69626fd923
parent:      102684:096e800e6834
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon Aug 15 21:44:06 2016 -0700
summary:
  merge 3.5

files:
  Lib/test/test_curses.py |  2 ++
  Misc/NEWS               |  4 ++--
  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
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -190,6 +190,8 @@
 
         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):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -102,8 +102,8 @@
 
 - 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
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -1393,6 +1393,10 @@
     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 @@
     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:

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list