diff --git a/IPython/utils/py3compat.py b/IPython/utils/py3compat.py index 68a8681..57eca72 100644 --- a/IPython/utils/py3compat.py +++ b/IPython/utils/py3compat.py @@ -155,7 +155,10 @@ else: if sys.platform == 'win32': def execfile(fname, glob=None, loc=None): loc = loc if (loc is not None) else glob - scripttext = __builtin__.open(fname).read() + # The rstrip() is necessary b/c trailing whitespace in files will + # cause an IndentationError in Python 2.6 (this was fixed in 2.7, + # but we still support 2.6). See issue 1027. + scripttext = __builtin__.open(fname).read().rstrip() # compile converts unicode filename to str assuming # ascii. Let's do the conversion before calling compile if isinstance(fname, unicode):