Issue #4806: Avoid masking TypeError when *-unpacking a generator

Based on patch by Hagen Fürstenau.
This commit is contained in:
Martin Panter
2016-01-31 06:30:56 +00:00
parent 414f8b937f
commit 0bb165ecc1
3 changed files with 24 additions and 7 deletions

View File

@@ -4615,10 +4615,12 @@ ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk)
PyObject *t = NULL;
t = PySequence_Tuple(stararg);
if (t == NULL) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
if (PyErr_ExceptionMatches(PyExc_TypeError) &&
/* Don't mask TypeError raised from a generator */
!PyGen_Check(stararg)) {
PyErr_Format(PyExc_TypeError,
"%.200s%.200s argument after * "
"must be a sequence, not %200s",
"must be an iterable, not %200s",
PyEval_GetFuncName(func),
PyEval_GetFuncDesc(func),
stararg->ob_type->tp_name);