Skip to content
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

Python 'print' statements don't parse well #132

Open
driskille opened this issue Feb 23, 2018 · 0 comments
Open

Python 'print' statements don't parse well #132

driskille opened this issue Feb 23, 2018 · 0 comments

Comments

@driskille
Copy link

The error I got is below, it includes the bit of code that caused it. (qt_py_convert is our local tool for converting python code from using PyQt4 to QtPy.) I've gotten the same error for the following three types of Python print statements:

  1. print 'Some message'
  2. print 'Some message %s' % var
  3. msg = 'Some message'
    print msg

Putting parentheses around the item being printed makes the parsing error go away.

------- the error -------
Traceback (most recent call last):
File "/dd/tools/cent6_64/package/qt_py_convert/0.8.0/python/qt_py_convert/run.py", line 558, in run
red = redbaron.RedBaron(text)
File "/dd/tools/cent6_64/package/qt_py_convert/0.8.0/python/qt_py_convert/external/redbaron/redbaron.py", line 36, in init
self.node_list = base_nodes.NodeList.from_fst(baron.parse(source_code), parent=self, on_attribute="root")
File "/dd/tools/cent6_64/package/qt_py_convert/0.8.0/python/qt_py_convert/external/baron/baron.py", line 66, in parse
return _parse(tokens, print_function)
File "/dd/tools/cent6_64/package/qt_py_convert/0.8.0/python/qt_py_convert/external/baron/baron.py", line 26, in _parse
raise e
ParsingError: Error, got an unexpected token NAME here:

778
779 result = ngcmds.redo()
780
781 # update previous selection
782 try:
783 self.dag_viewer.updateSelection()
784 except RuntimeError, msg:
785 print msg<---- here

The token NAME should be one of those: AMPER_EQUAL, CIRCUMFLEX_EQUAL, COLON, COMMA, COMMENT, DOUBLE_SLASH_EQUAL, DOUBLE_STAR_EQUAL, ENDL, EQUAL, LEFT_SHIFT_EQUAL, MINUS_EQUAL, PERCENT_EQUAL, PLUS_EQUAL, RIGHT_PARENTHESIS, RIGHT_SHIFT_EQUAL, SEMICOLON, SLASH_EQUAL, STAR_EQUAL, VBAR_EQUAL

It is not normal that you see this error, it means that Baron has failed to parse valid Python code. It would be kind if you can extract the snippet of your code that makes Baron fail and open a bug here: https://github.com/Psycojoker/baron/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant