summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2000-02-23 22:21:50 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2000-02-23 22:21:50 (GMT)
commit0f223d241854934cb0631e578381db59f6059af7 (patch)
treea628bc17f2907aac1febc4b3551b0743a4eb16f6 /Objects
parent2194b165db0e04a68acff21f3e873c376a7f4767 (diff)
downloadcpython-0f223d241854934cb0631e578381db59f6059af7.zip
cpython-0f223d241854934cb0631e578381db59f6059af7.tar.gz
cpython-0f223d241854934cb0631e578381db59f6059af7.tar.bz2
Allow using long integers as arguments to PyObject_GetItem(), _SetItem(),
and _DelItem(). In sequence multiplication by a long, only call PyErr_Occurred() when the value returned is -1.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 3fc312a..5ee53ee 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -122,6 +122,12 @@ PyObject_GetItem(o, key)
if (o->ob_type->tp_as_sequence) {
if (PyInt_Check(key))
return PySequence_GetItem(o, PyInt_AsLong(key));
+ else if (PyLong_Check(key)) {
+ long key_value = PyLong_AsLong(key);
+ if (key_value == -1 && PyErr_Occurred())
+ return NULL;
+ return PySequence_GetItem(o, key_value);
+ }
return type_error("sequence index must be integer");
}
@@ -147,6 +153,12 @@ PyObject_SetItem(o, key, value)
if (o->ob_type->tp_as_sequence) {
if (PyInt_Check(key))
return PySequence_SetItem(o, PyInt_AsLong(key), value);
+ else if (PyLong_Check(key)) {
+ long key_value = PyLong_AsLong(key);
+ if (key_value == -1 && PyErr_Occurred())
+ return -1;
+ return PySequence_SetItem(o, key_value, value);
+ }
type_error("sequence index must be integer");
return -1;
}
@@ -173,6 +185,12 @@ PyObject_DelItem(o, key)
if (o->ob_type->tp_as_sequence) {
if (PyInt_Check(key))
return PySequence_DelItem(o, PyInt_AsLong(key));
+ else if (PyLong_Check(key)) {
+ long key_value = PyLong_AsLong(key);
+ if (key_value == -1 && PyErr_Occurred())
+ return -1;
+ return PySequence_DelItem(o, key_value);
+ }
type_error("sequence index must be integer");
return -1;
}
@@ -391,7 +409,7 @@ PyNumber_Multiply(v, w)
}
else if (PyLong_Check(w)) {
mul_value = PyLong_AsLong(w);
- if (PyErr_Occurred())
+ if (mul_value == -1 && PyErr_Occurred())
return NULL;
}
else {