diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-01-31 06:30:56 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-01-31 06:30:56 (GMT) |
commit | b5944220abaa525d326b6054b213adcdb26e7fda (patch) | |
tree | bab490dd879944ecb7e4a555a549a3e54c64f5d9 /Python | |
parent | 4c5ad9452b171acb15e8b8a2277cceb1c363db47 (diff) | |
download | cpython-b5944220abaa525d326b6054b213adcdb26e7fda.zip cpython-b5944220abaa525d326b6054b213adcdb26e7fda.tar.gz cpython-b5944220abaa525d326b6054b213adcdb26e7fda.tar.bz2 |
Issue #4806: Avoid masking original TypeError in call with * unpacking
Based on patch by Hagen Fürstenau and Daniel Urban.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 786adbf..aee0e6b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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); |