diff options
author | Raymond Hettinger <python@rcn.com> | 2005-08-21 11:09:58 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-08-21 11:09:58 (GMT) |
commit | 9314d3261d5b81dca1a997a698b5d01f6a04299e (patch) | |
tree | 544513d5922d720bb9afa394fe94c17647707297 /Python/bltinmodule.c | |
parent | 8c86f88af8321fea0ab581b36e03e6acd4d1bc41 (diff) | |
download | cpython-9314d3261d5b81dca1a997a698b5d01f6a04299e.zip cpython-9314d3261d5b81dca1a997a698b5d01f6a04299e.tar.gz cpython-9314d3261d5b81dca1a997a698b5d01f6a04299e.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 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 8dd3f1c..9466cca 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -160,6 +160,10 @@ builtin_filter(PyObject *self, PyObject *args) /* Guess a result list size. */ len = PyObject_Size(seq); if (len < 0) { + if (!PyErr_ExceptionMatches(PyExc_TypeError) && + !PyErr_ExceptionMatches(PyExc_AttributeError)) { + goto Fail_it; + } PyErr_Clear(); len = 8; /* arbitrary */ } @@ -801,6 +805,10 @@ builtin_map(PyObject *self, PyObject *args) /* Update len. */ curlen = PyObject_Size(curseq); if (curlen < 0) { + if (!PyErr_ExceptionMatches(PyExc_TypeError) && + !PyErr_ExceptionMatches(PyExc_AttributeError)) { + goto Fail_2; + } PyErr_Clear(); curlen = 8; /* arbitrary */ } @@ -2002,6 +2010,10 @@ builtin_zip(PyObject *self, PyObject *args) PyObject *item = PyTuple_GET_ITEM(args, i); int thislen = PyObject_Size(item); if (thislen < 0) { + if (!PyErr_ExceptionMatches(PyExc_TypeError) && + !PyErr_ExceptionMatches(PyExc_AttributeError)) { + return NULL; + } PyErr_Clear(); len = -1; break; |