summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
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/abstract.c
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/abstract.c')
-rw-r--r--Objects/abstract.c5
1 files changed, 5 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 */
}