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

Crash on the correct Python 3 script with Syntax error #22

Closed
pepr opened this issue Sep 18, 2015 · 3 comments
Closed

Crash on the correct Python 3 script with Syntax error #22

pepr opened this issue Sep 18, 2015 · 3 comments

Comments

@pepr
Copy link

pepr commented Sep 18, 2015

Hi and thanks for the filter. I have started the asciidoc porting to Python 3, and I have used Doxygen to get a big picture. The script was converted with 2to3. The syntax error is reported for the print(line, file=f) (which is not what is normally used, in my opinion, anyway):

Generating code for file asciidoc3.py...
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\lib\site-packages\doxypypy-0.8.8.6-py2.7.egg\doxypypy\doxypy
py.py", line 836, in <module>
    main()
  File "C:\Python27\lib\site-packages\doxypypy-0.8.8.6-py2.7.egg\doxypypy\doxypy
py.py", line 830, in main
    astWalker.parseLines()
  File "C:\Python27\lib\site-packages\doxypypy-0.8.8.6-py2.7.egg\doxypypy\doxypy
py.py", line 741, in parseLines
    inAst = parse(''.join(self.lines), self.inFilename)
  File "C:\Python27\lib\ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "D:/Software/asciidoc/asciidoc3.py", line 6061
    print(line, file=f)
                    ^
SyntaxError: invalid syntax

The problem can be manifested at the sources from https://github.com/pepr/asciidoc/tree/py3dev, commit point a1799470619. The last official Doxygen and graphviz were installed. When the line is replaced by f.write(line + '\n'), the filter works fine -- see commit d64db2f9bed.

@Feneric
Copy link
Owner

Feneric commented Sep 18, 2015

It looks like you were running doxypypy under Python 2 for Python 3 code. Please try it again running doxypypy under Python 3. Just use your favorite Python package manager to install it for Python 3 and tell Doxygen to use that version.

Since doxypypy uses the Python interpreter to figure out Python code, running it under Python 2 for Python 3 code isn't supported.

@pepr
Copy link
Author

pepr commented Sep 18, 2015

You are right. I am using it on Windows (that is clear from the error message). When installing doxypypy (and using the Python Launcher for Windows), I just typed setup install. Because of the #!/usr/bin/env python inside, Python 2 was lauched and it was installed (in my case) into C:\Python27. My second mistake was to use to use py -m doxypypy.doxypypy -a -c %1 in my doxypy_filter.bat. This way, the launcher also calls Python 2 by default.

So, I did install doxypypy via py -3 setup.py install (it went to my C:\Python35 directory), and later also via py -3.4 setup.py install (it went to my older C:\Python34 directory).

Then, when changing the doxypy_filter.bat to py -3 -m doxypypy.doxypypy -a -c %1, Python 3 is used and everything works perfectly. It works perfectly also for py -3.4 -m doxypypy.doxypypy -a -c %1.

To summarize, I can confirm it works fine on Windows for Python 2.7 (32 bit), Python 3.4 (32 bit), and also for Python 3.5 (64 bit).

Thanks a lot,
Petr

@Feneric
Copy link
Owner

Feneric commented Sep 18, 2015

Excellent news, thank you. It's probably something we should add to the documentation. It's important to run doxypypy with the version of Python used by the source being analyzed.

@Feneric Feneric closed this as completed Sep 18, 2015
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

2 participants