diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2005-02-27 20:33:25 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2005-02-27 20:33:25 (GMT) |
commit | 9533e3402433245489bcf55adf1e134ca71b4798 (patch) | |
tree | 427fbe693b3d74a49c2d008be604ff974ca346fd | |
parent | c2a0ac20b7ba3c740f21607c4c8bc706f5d7b7c5 (diff) | |
download | cpython-9533e3402433245489bcf55adf1e134ca71b4798.zip cpython-9533e3402433245489bcf55adf1e134ca71b4798.tar.gz cpython-9533e3402433245489bcf55adf1e134ca71b4798.tar.bz2 |
Patch #1093585: raise a ValueError for negative history items in
remove_history and replace_history. Will backport to 2.4.
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/readline.c | 10 |
2 files changed, 13 insertions, 0 deletions
@@ -34,6 +34,9 @@ Core and builtins Extension Modules ----------------- +- Patch #1093585: raise a ValueError for negative history items in readline. + {remove_history,replace_history} + - The spwd module has been added, allowing access to the shadow password database. diff --git a/Modules/readline.c b/Modules/readline.c index 9d5a6be..706eb7a 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -303,6 +303,11 @@ py_remove_history(PyObject *self, PyObject *args) 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 @@ py_replace_history(PyObject *self, PyObject *args) 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, |