ipython/ipython — Issue #1027: ipython does not like white space at end of file
Author: jstenar
Created: 2011-11-22 07:54:49+00:00
State: open

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:

C:\python\bugreports\ipython> python .\whitespace_at_eof.py
hello world!

ipython from commandline:

C:\python\bugreports\ipython> ipython .\whitespace_at_eof.py
---------------------------------------------------------------------------
IndentationError Traceback (most recent call last)
c:\python26\external\ipython\IPython\utils\py3compat.pyc in execfile(fname, glob, loc)
163 else:
164 filename = fname
--> 165 exec compile(scripttext, filename, 'exec') in glob, loc
166 else:
167 def execfile(fname, *where):

IndentationError: unexpected indent (whitespace_at_eof.py, line 2)

ipython %run:

In [1]: %run whitespace_at_eof.py
---------------------------------------------------------------------------
IndentationError Traceback (most recent call last)
c:\python26\external\ipython\IPython\utils\py3compat.pyc in execfile(fname, glob, loc)
163 else:
164 filename = fname
--> 165 exec compile(scripttext, filename, 'exec') in glob, loc
166 else:
167 def execfile(fname, *where):

IndentationError: unexpected indent (whitespace_at_eof.py, line 2)

This was tested on windows 7 python2.6 ipython master 30385c4