You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.
Issue #23 shows that evaluating the print function imported from __future__ breaks with a syntax error:
from __future__ importprint_functionprint('spam', file=sys.stderr)
Traceback (most recent call last):
File "/home/dosmo/repos/LightTable/builds/lighttable-0.8.0-linux/resources/app/plugins/Python/py-src/ltmain.py", line 199, in handleEval
code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'exec')
File "future-test.py", line 4
print('spam', file=sys.stdout)
^
SyntaxError: invalid syntax
This is different from the other problem printing to sys.stderr. It looks as if the compile function needs to receive the proper compiler flags for the syntax changes from __future__ in order for the plugin to operate correctly. Docs for the compile function and the future module.
From a Python2 interpreter this fails with the syntax error:
>>> compile("print('spam', file=sys.stdout)", "testname", "exec")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "testname", line 1
print('spam', file=sys.stdout)
^
SyntaxError: invalid syntax
Where using the compiler flag for the print_function does not:
>>> __future__.print_function.compiler_flag
65536
>>> compile("print('spam', file=sys.stdout)", "testname", "exec", flags=65536)
<code object <module> at 0x7fb50699ecb0, file "testname", line 1>
It may be possible to fix this by checking if any future statements are executed, obtaining the proper compiler flags from them, and feeding them to later calls to compile.
The text was updated successfully, but these errors were encountered:
Issue #23 shows that evaluating the print function imported from
__future__
breaks with a syntax error:This is different from the other problem printing to
sys.stderr
. It looks as if thecompile
function needs to receive the proper compiler flags for the syntax changes from__future__
in order for the plugin to operate correctly. Docs for the compile function and the future module.From a Python2 interpreter this fails with the syntax error:
Where using the compiler flag for the print_function does not:
It may be possible to fix this by checking if any future statements are executed, obtaining the proper compiler flags from them, and feeding them to later calls to compile.
The text was updated successfully, but these errors were encountered: