summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-08-21 11:03:59 (GMT)
committerRaymond Hettinger <python@rcn.com>2005-08-21 11:03:59 (GMT)
commita710b331daee9e79ca90395feb6ce8c552e00568 (patch)
treea00e825052dabf853c875136b3e1832742634879 /Objects
parentb285974c00fbf51af727d9330fa90443177390f4 (diff)
downloadcpython-a710b331daee9e79ca90395feb6ce8c552e00568.zip
cpython-a710b331daee9e79ca90395feb6ce8c552e00568.tar.gz
cpython-a710b331daee9e79ca90395feb6ce8c552e00568.tar.bz2
SF bug #1242657: list(obj) can swallow KeyboardInterrupt
Fix over-aggressive PyErr_Clear(). The same code fragment appears in various guises in list.extend(), map(), filter(), zip(), and internally in PySequence_Tuple().
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c5
-rw-r--r--Objects/listobject.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index cade2aa..94af3da 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1401,6 +1401,11 @@ PySequence_Tuple(PyObject *v)
/* Guess result size and allocate space. */
n = PyObject_Size(v);
if (n < 0) {
+ if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
+ !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ Py_DECREF(it);
+ return NULL;
+ }
PyErr_Clear();
n = 10; /* arbitrary */
}
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 08ab095..3b7358a 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -777,6 +777,11 @@ listextend(PyListObject *self, PyObject *b)
/* Guess a result list size. */
n = PyObject_Size(b);
if (n < 0) {
+ if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
+ !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ Py_DECREF(it);
+ return NULL;
+ }
PyErr_Clear();
n = 8; /* arbitrary */
}