mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Patch #1093585: raise a ValueError for negative history items in
remove_history and replace_history. Will backport to 2.4.
This commit is contained in:
parent
c2a0ac20b7
commit
9533e34024
2 changed files with 13 additions and 0 deletions
|
@ -34,6 +34,9 @@ Core and builtins
|
||||||
Extension Modules
|
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
|
- The spwd module has been added, allowing access to the shadow password
|
||||||
database.
|
database.
|
||||||
|
|
||||||
|
|
|
@ -303,6 +303,11 @@ py_remove_history(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "i:remove_history", &entry_number))
|
if (!PyArg_ParseTuple(args, "i:remove_history", &entry_number))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (entry_number < 0) {
|
||||||
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
"History index cannot be negative");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
entry = remove_history(entry_number);
|
entry = remove_history(entry_number);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
PyErr_Format(PyExc_ValueError,
|
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)) {
|
if (!PyArg_ParseTuple(args, "is:replace_history", &entry_number, &line)) {
|
||||||
return NULL;
|
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);
|
old_entry = replace_history_entry(entry_number, line, (void *)NULL);
|
||||||
if (!old_entry) {
|
if (!old_entry) {
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue