##// END OF EJS Templates
Revert "Merge pull request #1831 from steverweber/fix_1814"...
Bradley M. Froehle -
Show More
@@ -2455,9 +2455,6 b' class InteractiveShell(SingletonConfigurable):'
2455 2455 dname = os.path.dirname(fname)
2456 2456
2457 2457 with prepended_to_syspath(dname):
2458 # Ensure that __file__ is always defined to match Python behavior
2459 save_fname = self.user_ns.get('__file__',None)
2460 self.user_ns['__file__'] = fname
2461 2458 try:
2462 2459 py3compat.execfile(fname,*where)
2463 2460 except SystemExit as status:
@@ -2478,8 +2475,6 b' class InteractiveShell(SingletonConfigurable):'
2478 2475 if kw['raise_exceptions']:
2479 2476 raise
2480 2477 self.showtraceback()
2481 finally:
2482 self.user_ns['__file__'] = save_fname
2483 2478
2484 2479 def safe_execfile_ipy(self, fname):
2485 2480 """Like safe_execfile, but for .ipy files with IPython syntax.
@@ -2506,9 +2501,6 b' class InteractiveShell(SingletonConfigurable):'
2506 2501 dname = os.path.dirname(fname)
2507 2502
2508 2503 with prepended_to_syspath(dname):
2509 # Ensure that __file__ is always defined to match Python behavior
2510 save_fname = self.user_ns.get('__file__',None)
2511 self.user_ns['__file__'] = fname
2512 2504 try:
2513 2505 with open(fname) as thefile:
2514 2506 # self.run_cell currently captures all exceptions
@@ -2519,8 +2511,6 b' class InteractiveShell(SingletonConfigurable):'
2519 2511 except:
2520 2512 self.showtraceback()
2521 2513 warn('Unknown failure executing file: <%s>' % fname)
2522 finally:
2523 self.user_ns['__file__'] = save_fname
2524 2514
2525 2515 def safe_run_module(self, mod_name, where):
2526 2516 """A safe version of runpy.run_module().
@@ -277,13 +277,21 b' class InteractiveShellApp(Configurable):'
277 277 sys.argv = [ py3compat.cast_bytes(a) for a in sys.argv ]
278 278 try:
279 279 if os.path.isfile(full_filename):
280 self.log.info("Running file in user namespace: %s" % full_filename)
281 280 if full_filename.endswith('.ipy'):
281 self.log.info("Running file in user namespace: %s" %
282 full_filename)
282 283 self.shell.safe_execfile_ipy(full_filename)
283 284 else:
284 285 # default to python, even without extension
286 self.log.info("Running file in user namespace: %s" %
287 full_filename)
288 # Ensure that __file__ is always defined to match Python behavior
289 self.shell.user_ns['__file__'] = fname
290 try:
285 291 self.shell.safe_execfile(full_filename, self.shell.user_ns)
286 292 finally:
293 del self.shell.user_ns['__file__']
294 finally:
287 295 sys.argv = save_argv
288 296
289 297 def _run_startup_files(self):
General Comments 0
You need to be logged in to leave comments. Login now