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 july
Recipients july
Date 2012-01-29.16:38:39
SpamBayes Score 2.921154e-10
Marked as misclassified No
Message-id <1327855120.91.0.5569840716.issue13904@psf.upfronthosting.co.za>
In-reply-to
Content
>>> set().union(*(None[k] for k in range(5)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: union() argument after * must be a sequence, not generator

Clearly, exception in not relevant, since next line works:

>>> set().union(*([k] for k in range(5)))
{0, 1, 2, 3, 4}

Correct exception would be

>>> None[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not subscriptable

Problem is in python function call mechanics.
set().union can be replaced by any callable;
Generator can be replaced by any TypeError-raising iterable. Exceptions other then TypeError are handled correctly.

Python/ceval.c:4322
ext_do_call() converts stararg to tuple.
If any TypeError is raised, it is replaced with
TypeError("%s argument after * must be a sequence, not %s")


Proposed solution:

Probably, we can avoid replacing TypeError. Exceptions in the above cases would become relevant, and

>>> int(*None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type object argument after * must be a sequence, not NoneType

would become

>>> int(*None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable

so exception is still recognizable (and, may be, even more relevant, since we don't actually need _sequence_ as stararg, _iterable_ would be enough).
History
Date User Action Args
2012-01-29 16:38:41julysetrecipients: + july
2012-01-29 16:38:40julysetmessageid: <1327855120.91.0.5569840716.issue13904@psf.upfronthosting.co.za>
2012-01-29 16:38:40julylinkissue13904 messages
2012-01-29 16:38:40julycreate