Index: Python/ceval.c =================================================================== --- Python/ceval.c (Revision 73165) +++ Python/ceval.c (Arbeitskopie) @@ -4012,7 +4012,8 @@ PyObject *t = NULL; t = PySequence_Tuple(stararg); if (t == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) { + if (PyErr_ExceptionMatches(PyExc_TypeError) + && (PyObject_GetIter(stararg) == NULL)) { PyErr_Format(PyExc_TypeError, "%.200s%.200s argument after * " "must be a sequence, not %200s", Index: Lib/test/test_extcall.py =================================================================== --- Lib/test/test_extcall.py (Revision 73165) +++ Lib/test/test_extcall.py (Arbeitskopie) @@ -126,6 +126,17 @@ >>> g(*Nothing()) 0 (1, 2, 3) {} +Check for issue #4806: Does a TypeError in a generator get propagated with the +right error message? + + >>> def broken(): raise TypeError("myerror") + ... + + >>> g(*(broken() for i in range(1))) + Traceback (most recent call last): + ... + TypeError: myerror + Make sure that the function doesn't stomp the dictionary >>> d = {'a': 1, 'b': 2, 'c': 3}