mirror of
https://github.com/python/cpython.git
synced 2025-12-08 18:32:16 +00:00
revert r74699 since it loses useful error information
This commit is contained in:
parent
23d925311d
commit
d692a71fdd
1 changed files with 13 additions and 2 deletions
|
|
@ -968,8 +968,14 @@ builtin_map(PyObject *self, PyObject *args)
|
||||||
/* Get iterator. */
|
/* Get iterator. */
|
||||||
curseq = PyTuple_GetItem(args, i+1);
|
curseq = PyTuple_GetItem(args, i+1);
|
||||||
sqp->it = PyObject_GetIter(curseq);
|
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;
|
goto Fail_2;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update len. */
|
/* Update len. */
|
||||||
curlen = _PyObject_LengthHint(curseq, 8);
|
curlen = _PyObject_LengthHint(curseq, 8);
|
||||||
|
|
@ -2457,8 +2463,13 @@ builtin_zip(PyObject *self, PyObject *args)
|
||||||
for (i = 0; i < itemsize; ++i) {
|
for (i = 0; i < itemsize; ++i) {
|
||||||
PyObject *item = PyTuple_GET_ITEM(args, i);
|
PyObject *item = PyTuple_GET_ITEM(args, i);
|
||||||
PyObject *it = PyObject_GetIter(item);
|
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;
|
goto Fail_ret_itlist;
|
||||||
|
}
|
||||||
PyTuple_SET_ITEM(itlist, i, it);
|
PyTuple_SET_ITEM(itlist, i, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue