##// END OF EJS Templates
Backport PR #2924: safe_run_module: Silence SystemExit codes 0 and None....
MinRK -
Show More
@@ -2445,7 +2445,7 b' class InteractiveShell(SingletonConfigurable):'
2445 # explicitly silenced, but only in short form.
2445 # explicitly silenced, but only in short form.
2446 if kw['raise_exceptions']:
2446 if kw['raise_exceptions']:
2447 raise
2447 raise
2448 if status.code not in (0, None) and not kw['exit_ignore']:
2448 if status.code and not kw['exit_ignore']:
2449 self.showtraceback(exception_only=True)
2449 self.showtraceback(exception_only=True)
2450 except:
2450 except:
2451 if kw['raise_exceptions']:
2451 if kw['raise_exceptions']:
@@ -2494,6 +2494,8 b' class InteractiveShell(SingletonConfigurable):'
2494 This version will never throw an exception, but instead print
2494 This version will never throw an exception, but instead print
2495 helpful error messages to the screen.
2495 helpful error messages to the screen.
2496
2496
2497 `SystemExit` exceptions with status code 0 or None are ignored.
2498
2497 Parameters
2499 Parameters
2498 ----------
2500 ----------
2499 mod_name : string
2501 mod_name : string
@@ -2502,10 +2504,14 b' class InteractiveShell(SingletonConfigurable):'
2502 The globals namespace.
2504 The globals namespace.
2503 """
2505 """
2504 try:
2506 try:
2507 try:
2505 where.update(
2508 where.update(
2506 runpy.run_module(str(mod_name), run_name="__main__",
2509 runpy.run_module(str(mod_name), run_name="__main__",
2507 alter_sys=True)
2510 alter_sys=True)
2508 )
2511 )
2512 except SystemExit as status:
2513 if status.code:
2514 raise
2509 except:
2515 except:
2510 self.showtraceback()
2516 self.showtraceback()
2511 warn('Unknown failure executing module: <%s>' % mod_name)
2517 warn('Unknown failure executing module: <%s>' % mod_name)
General Comments 0
You need to be logged in to leave comments. Login now