question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to recognize comma on exec function on python2.7

See original GitHub issue

Hi,

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:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
williamjamircommented, Jan 11, 2018

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:

  • Issue #21591: Correctly handle qualified exec statements in tuple form by moving compatibility layer from run-time to AST transformation.
0reactions
soupytwistcommented, Jan 16, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found