New submission from Hagen Fürstenau <hfuerste...@gmx.net>: If we call some function f with a generator as star argument and this generator raises a TypeError, we get the following exception:
>>> def f(x): pass ... >>> def broken(): raise TypeError ... >>> f(*(broken() for x in (0,))) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: f() argument after * must be a sequence, not generator This is a misleading error message, as it's usually no problem to use a generator as a star argument. Even just replacing the TypeError by some other exception leads to the expected result, i.e. the exception gets correctly propagated. The problem seems to be around line 3710 of Python/ceval.c where the generator is converted to a tuple. If this conversion raises a TypeError, then the error message is replaced, which will mask any TypeError raised by the generator. I'm not sure how to solve this. We probably can't distinguish a "good" TypeError from a "bad" TypeError at this point, so we might have to make a special case for the conversion of generators. ---------- components: Interpreter Core messages: 78788 nosy: hagen severity: normal status: open title: Function calls taking a generator as star argument can mask TypeErrors in the generator type: behavior versions: Python 2.6, Python 3.0 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4806> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com