This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hagen
Recipients hagen
Date 2009-01-02.12:46:01
SpamBayes Score 2.8092462e-10
Marked as misclassified No
Message-id <1230900364.95.0.0532833034138.issue4806@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-01-02 12:46:05hagensetrecipients: + hagen
2009-01-02 12:46:04hagensetmessageid: <1230900364.95.0.0532833034138.issue4806@psf.upfronthosting.co.za>
2009-01-02 12:46:02hagenlinkissue4806 messages
2009-01-02 12:46:01hagencreate