diff options
author | Guido van Rossum <guido@python.org> | 1997-05-23 00:06:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-05-23 00:06:51 (GMT) |
commit | c8b6df90045a3f419e6fab272d93ad4159e54ccc (patch) | |
tree | 20cb4b6f0ba2718577079198780d5fc3852e4a70 /Objects/listobject.c | |
parent | 5b2121b25fc6a50fe229fe25ef6be8a2f883d1f4 (diff) | |
download | cpython-c8b6df90045a3f419e6fab272d93ad4159e54ccc.zip cpython-c8b6df90045a3f419e6fab272d93ad4159e54ccc.tar.gz cpython-c8b6df90045a3f419e6fab272d93ad4159e54ccc.tar.bz2 |
PyObject_Compare can raise an exception now.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index 16d63b8..588053c 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -580,8 +580,12 @@ docompare(x, y, compare) PyObject *args, *res; int i; - if (compare == NULL) - return PyObject_Compare(x, y); + if (compare == NULL) { + i = PyObject_Compare(x, y); + if (i && PyErr_Occurred()) + i = CMPERROR; + return i; + } args = Py_BuildValue("(OO)", x, y); if (args == NULL) @@ -955,6 +959,8 @@ listindex(self, args) for (i = 0; i < self->ob_size; i++) { if (PyObject_Compare(self->ob_item[i], args) == 0) return PyInt_FromLong((long)i); + if (PyErr_Occurred()) + return NULL; } PyErr_SetString(PyExc_ValueError, "list.index(x): x not in list"); return NULL; @@ -975,6 +981,8 @@ listcount(self, args) for (i = 0; i < self->ob_size; i++) { if (PyObject_Compare(self->ob_item[i], args) == 0) count++; + if (PyErr_Occurred()) + return NULL; } return PyInt_FromLong((long)count); } @@ -998,7 +1006,8 @@ listremove(self, args) Py_INCREF(Py_None); return Py_None; } - + if (PyErr_Occurred()) + return NULL; } PyErr_SetString(PyExc_ValueError, "list.remove(x): x not in list"); return NULL; |