New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError instead of SyntaxError for syntactically invalid gen exp #46491
Comments
I have a file f1.py $ cat f1.py
import os
(lambda **x:x)(**dict(y,y for y in ())) and when I run it $ python f1.py
Traceback (most recent call last):
File "f1.py", line 1, in <module>
import os
TypeError: 'int' object is not iterable Notice that the TypeError exception is from the import os on line 1. $ cat f2.py
#import os
dict(y,y for y in ()) then $ python f2.py
File "f2.py", line 2
dict(y,y for y in ())
SyntaxError: Generator expression must be parenthesized if not sole argument The mess (lambda **x:x)(**dict(y,y for y in ())) is a simplified version of something I had about 100 lines into a I'm using Python 2.5.2 (r252:60911, Mar 4 2008, 14:33:51) for python. ################################################################################ The above is probably a good enough description, but here's some more Some variations of f1.py cause the same error, but others don't. for c in [1]: pass
(lambda **x:x)(**dict(y,y for y in ())) I get Traceback (most recent call last):
File "f4.py", line 1, in <module>
for c in [1]: pass
TypeError: 'int' object is not iterable as before. But if f5.py is for c in "1": pass
(lambda **x:x)(**dict(y,y for y in ())) running the script results in no output and a successful run $ echo $?
0 Finally, if f6.py is just the single line (lambda **x:x)(**dict(y,y for y in ())) then my 2.5.2 python has the same successful with no output result as Python 2.5 (r25:51908, Oct 30 2006, 16:20:39) python I get Exception exceptions.SyntaxError: ('Generator expression must be The older 2.5 python runs f5.py successfully with no output like 2.5.2 does. I searched the bug tracker for "TypeError: 'int' object is not I'd guess the problem has to do with a bad parse. |
Interestingly, in debug mode, the message "XXX undetected error" is Committed revision 61240, will backport to 2.5. |
Back-ported to 2.5 and committed in rev 61675. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: