diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 3484cba..a8376ac 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2419,9 +2419,9 @@ class InteractiveShell(SingletonConfigurable): dname = os.path.dirname(fname) with prepended_to_syspath(dname): - # Ensure that __file__ is always defined to match Python behavior - save_fname = self.user_ns.get('__file__',None) - self.user_ns['__file__'] = fname + # Ensure that __file__ is always defined to match Python behavior + save_fname = self.user_ns.get('__file__',None) + self.user_ns['__file__'] = fname try: py3compat.execfile(fname,*where) except SystemExit, status: @@ -2470,9 +2470,9 @@ class InteractiveShell(SingletonConfigurable): dname = os.path.dirname(fname) with prepended_to_syspath(dname): - # Ensure that __file__ is always defined to match Python behavior - save_fname = self.user_ns.get('__file__',None) - self.user_ns['__file__'] = fname + # Ensure that __file__ is always defined to match Python behavior + save_fname = self.user_ns.get('__file__',None) + self.user_ns['__file__'] = fname try: with open(fname) as thefile: # self.run_cell currently captures all exceptions diff --git a/IPython/core/shellapp.py b/IPython/core/shellapp.py index 7f3f0df..7414e6a 100644 --- a/IPython/core/shellapp.py +++ b/IPython/core/shellapp.py @@ -278,11 +278,11 @@ class InteractiveShellApp(Configurable): try: if os.path.isfile(full_filename): self.log.info("Running file in user namespace: %s" % full_filename) - if full_filename.endswith('.ipy'): - self.shell.safe_execfile_ipy(full_filename) - else: - # default to python, even without extension - self.shell.safe_execfile(full_filename, self.shell.user_ns) + if full_filename.endswith('.ipy'): + self.shell.safe_execfile_ipy(full_filename) + else: + # default to python, even without extension + self.shell.safe_execfile(full_filename, self.shell.user_ns) finally: sys.argv = save_argv