Failed to recognize comma on exec function on python2.7
See original GitHub issueHi,
The parser does not recognize the comma on exec function with python2.7
I did try to create a PR solving this issue, I was doing a function " in_or_comma() " but I realized that the problem would be deeper than this because the visit_exec
is treating the exec as a statement instead of function. Am I right?
Here it’s a small reproducible example of the error:
File:
exec('x = 10' , {} )
Script:
import pasta
from pasta.augment import rename
path = r'test.py'
with open(path) as file:
tree = pasta.parse(file.read())
Error:
pasta.base.annotate.AnnotationError: Expected 'in' but found ','
line 1: exec ('x = 10', {})
cc @nicoddemus
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Trailing comma added after *args · Issue #1356 · psf/black
Describe the bug If the definition of a function with *args in the signature is broken into multiple lines, a trailing comma is...
Read more >Getting SyntaxError for print with keyword argument end=' '
i.e. as a call to print with a tuple as argument. That's obviously bad syntax (literals don't take keyword arguments). In Python 3.x...
Read more >Invalid Syntax in Python: Common Reasons for SyntaxError
The problem, in this case, is that the code looks perfectly fine, but it was run with an older version of Python.
Read more >SyntaxError in Python: How to Handle Invalid Syntax in Python
According to Python's official documentation, a SyntaxError Exception is: exception SyntaxError Raised when the parser encounters a syntax error ...
Read more >What's New In Python 3.0 — Python 3.11.1 documentation
Author, Guido van Rossum,. This article explains the new features in Python 3.0, compared to 2.6. Python 3.0, also known as “Python 3000”...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just out of curiosity (I know it will not interfere with this problem), this different behavior occurred in the transition from Python 2.7.8 to 2.7.9
Checking the changelog I found this:
Yes, I see the problem. I’ll need a more generic solution for this, it might also affect a few other places.
Generally, there needs to be support for when multiple children of a node can be parenthesized. Thanks for following up on it. I’ll start working on this when I get a chance.