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

loewis at users.sourceforge.net loewis at users.sourceforge.net
Sun Feb 27 21:33:29 CET 2005


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

Modified Files:
	readline.c 
Log Message:
Patch #1093585: raise a ValueError for negative history items in
remove_history and replace_history. Will backport to 2.4.


Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.79
retrieving revision 2.80
diff -u -d -r2.79 -r2.80
--- readline.c	25 Nov 2004 04:04:20 -0000	2.79
+++ readline.c	27 Feb 2005 20:33:25 -0000	2.80
@@ -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