Issue #4806: Avoid masking original TypeError in call with * unpacking

Based on patch by Hagen Fürstenau and Daniel Urban.
This commit is contained in:
Martin Panter 2016-01-31 06:30:56 +00:00
parent 4c5ad9452b
commit b5944220ab
3 changed files with 58 additions and 13 deletions

View file

@ -4935,16 +4935,18 @@ ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk)
stararg = EXT_POP(*pp_stack);
if (!PyTuple_Check(stararg)) {
PyObject *t = NULL;
if (Py_TYPE(stararg)->tp_iter == NULL &&
!PySequence_Check(stararg)) {
PyErr_Format(PyExc_TypeError,
"%.200s%.200s argument after * "
"must be an iterable, not %.200s",
PyEval_GetFuncName(func),
PyEval_GetFuncDesc(func),
stararg->ob_type->tp_name);
goto ext_call_fail;
}
t = PySequence_Tuple(stararg);
if (t == NULL) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
PyErr_Format(PyExc_TypeError,
"%.200s%.200s argument after * "
"must be a sequence, not %.200s",
PyEval_GetFuncName(func),
PyEval_GetFuncDesc(func),
stararg->ob_type->tp_name);
}
goto ext_call_fail;
}
Py_DECREF(stararg);