Export to GitHub

editra-plugins - issue #219

Syntax errors not marked if python3 binary is selected


Posted on Sep 12, 2012 by Grumpy Rabbit

What Plugin does this relate to? What version of the Plugin? PyStudio

What steps will reproduce the problem? 1. Set the python binary to /usr/bin/python3, and enable marking syntax errors on save. 2. Add some nonsense characters -- eg ":4Pfp30952+40zed~@^" to an existing .py file 3. Save the file. (this is true no matter what kind of syntax error it is.)

I expect to see the line containing nonsense marked; but it is not marked. (note: it is correctly marked if /usr/bin/python2 is the selected binary instead)

I'm using Editra 0.7.12 on Arch Linux x86_64. PyStudio installed as of yesterday.

I've compared the output produced by invoking python2 and python3 on nonsense. It is character for character identical (ie. 'diff /tmp/py2 /tmp/py3' prints nothing), and the returnvalue is also the same (==1)

Comment #1

Posted on Sep 12, 2012 by Happy Monkey

Odd, will have to investigate but have a suspicion that Python 3 may be writing to a different output pipe or something.

Currently PyStudio checks stderr of the python process used to check for syntax errors. Maybe Python has started writing errors to stdout instead?

Comment #2

Posted on Sep 12, 2012 by Grumpy Rabbit

well, it isn't a matter of which pipe; they both use stderr. I had to use &> to redirect stderr instead of stdin in order to do the diff.

Comment #3

Posted on Sep 13, 2012 by Happy Monkey

Root cause:

py_compile module has changed its output reporting in python 3 parsing is failing to identify the error.

Python 2.x: SyntaxError: ('invalid syntax', ('test.py', 3, 1, '*(F$\n'))

Python 3.x: File "test.py", line 2 print "foo" ^ SyntaxError: invalid syntax

Comment #4

Posted on Sep 13, 2012 by Happy Monkey

fixed in svn for version 0.8 of PyStudio plugin

Status: Fixed

Labels:
Type-Defect Priority-Medium Plugin-PyStudio