[Python-checkins] python/dist/src/Modules readline.c,2.79,2.79.2.1

loewis at users.sourceforge.net loewis at users.sourceforge.net
Sun Feb 27 21:34:04 CET 2005


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16157/Modules

Modified Files:
      Tag: release24-maint
	readline.c 
Log Message:
Patch #1093585: raise a ValueError for negative history items in 
remove_history and replace_history.


Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.79
retrieving revision 2.79.2.1
diff -u -d -r2.79 -r2.79.2.1
--- readline.c	25 Nov 2004 04:04:20 -0000	2.79
+++ readline.c	27 Feb 2005 20:34:01 -0000	2.79.2.1
@@ -303,6 +303,11 @@
 
         if (!PyArg_ParseTuple(args, "i:remove_history", &entry_number))
                 return NULL;
+        if (entry_number < 0) {
+                PyErr_SetString(PyExc_ValueError,
+                                "History index cannot be negative");
+                return NULL;
+        }
         entry = remove_history(entry_number);
         if (!entry) {
                 PyErr_Format(PyExc_ValueError,
@@ -335,6 +340,11 @@
         if (!PyArg_ParseTuple(args, "is:replace_history", &entry_number, &line)) {
                 return NULL;
         }
+        if (entry_number < 0) {
+                PyErr_SetString(PyExc_ValueError,
+                                "History index cannot be negative");
+                return NULL;
+        }
         old_entry = replace_history_entry(entry_number, line, (void *)NULL);
         if (!old_entry) {
                 PyErr_Format(PyExc_ValueError,



More information about the Python-checkins mailing list