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
ipython does not like white space at end of file #1027
Comments
This is probably just a matter of doing |
@jstenar, on what version of python do you see this? On 2.6 it works fine for me, both at the cmd line and via |
Note that the error appears in a Windows specific branch - on Posix systems, we call the built in execfile instead of compile-ing the source ourselves. However, when I call compile manually on the equivalent text, it doesn't appear to raise any errors, so maybe it's a difference in Python on Windows. |
It was on python 2.6 |
Ah, thanks for the info @takluyver. Indeed, tailing whitespace is disallowed:
Fixing it now (I'll do only |
Note that the bug is only in python 2.6, I checked and both 2.7 and 3.x work ok with trailing whitespace. Fix pushed. |
It seems we should have added the "\n" at the end of the line, I guess things work differently when there is a comment at the end of the file. I get this error message now when starting ipython:
It goes away if I add +"\n" at the end of line 161 in py3compat.py.
|
Will fix now with the `\n' addition you suggest. |
Ensure that scripts are newline-terminated, apparently py3 complains when there's a missing newline and the last line ends in a comment. This is probably a python bug, but we should protect against it nonetheless.
ipython does not handle whitespace at end of files in the same way as python itself does.
Test file 'whitespace_at_eof.py at: https://gist.github.com/1385125
This file contains one print statement and on the last line there are four spaces.
Regular python:
ipython from commandline:
ipython %run:
This was tested on windows 7 python2.6 ipython master 30385c4
The text was updated successfully, but these errors were encountered: