diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-09-07 13:02:15 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-09-07 13:02:15 (GMT) |
commit | d692a71fddbbc8cebabf260e7d11e113cff4f73e (patch) | |
tree | 7069953e33ea83955d4de99ff08c1eb83356a122 | |
parent | 23d925311dafd2ec3885dfd158e7d3d10c9e08d0 (diff) | |
download | cpython-d692a71fddbbc8cebabf260e7d11e113cff4f73e.zip cpython-d692a71fddbbc8cebabf260e7d11e113cff4f73e.tar.gz cpython-d692a71fddbbc8cebabf260e7d11e113cff4f73e.tar.bz2 |
revert r74699 since it loses useful error information
-rw-r--r-- | Python/bltinmodule.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index b1b1e8e..1f25d5d 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -968,8 +968,14 @@ builtin_map(PyObject *self, PyObject *args) /* Get iterator. */ curseq = PyTuple_GetItem(args, i+1); sqp->it = PyObject_GetIter(curseq); - if (sqp->it == NULL) + if (sqp->it == NULL) { + static char errmsg[] = + "argument %d to map() must support iteration"; + char errbuf[sizeof(errmsg) + 25]; + PyOS_snprintf(errbuf, sizeof(errbuf), errmsg, i+2); + PyErr_SetString(PyExc_TypeError, errbuf); goto Fail_2; + } /* Update len. */ curlen = _PyObject_LengthHint(curseq, 8); @@ -2457,8 +2463,13 @@ builtin_zip(PyObject *self, PyObject *args) for (i = 0; i < itemsize; ++i) { PyObject *item = PyTuple_GET_ITEM(args, i); PyObject *it = PyObject_GetIter(item); - if (it == NULL) + if (it == NULL) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_Format(PyExc_TypeError, + "zip argument #%zd must support iteration", + i+1); goto Fail_ret_itlist; + } PyTuple_SET_ITEM(itlist, i, it); } |