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.
Created on 2012年01月29日 16:38 by july, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| typeerror-replaced-in-stararg.diff | july, 2012年01月29日 16:38 | patch | ||
| typeerror-replaced-in-stararg-test.diff | july, 2012年01月29日 16:39 | test | review | |
| Messages (2) | |||
|---|---|---|---|
| msg152243 - (view) | Author: July Tikhonov (july) * | Date: 2012年01月29日 16:38 | |
>>> 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).
|
|||
| msg152579 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年02月04日 02:12 | |
I unlinked to see if I could link it to 4806 instead. Did not work. Please nosy yourself there and upload your files to *that* issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:26 | admin | set | github: 58112 |
| 2012年02月04日 02:12:56 | terry.reedy | set | status: open -> closed superseder: Function calls taking a generator as star argument can mask TypeErrors in the generator versions: + Python 2.7, Python 3.2 nosy: + terry.reedy messages: + msg152579 resolution: duplicate |
| 2012年02月04日 02:10:01 | terry.reedy | set | files: + typeerror-replaced-in-stararg.diff |
| 2012年02月04日 02:08:31 | terry.reedy | set | files: - typeerror-replaced-in-stararg.diff |
| 2012年01月29日 16:39:09 | july | set | files: + typeerror-replaced-in-stararg-test.diff |
| 2012年01月29日 16:38:40 | july | create | |