Skip to content

Commit 920beab

Browse files
committed
Merge pull request ipython#1396 from takluyver/magic_tb_fix
In order for the %tb magic to work as expected, no other error can be raised by invoking it. Even if an error is caught immediately, it affects the 'last error' values in sys. This cuts a try/except block out of ip.magic(). Happily, in this case there was a simpler way to do the same thing using `str.partition`
2 parents f77a23d + e14a39d commit 920beab

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

IPython/core/interactiveshell.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -2005,14 +2005,9 @@ def magic(self, arg_s, next_input=None):
20052005
if next_input:
20062006
self.set_next_input(next_input)
20072007

2008-
args = arg_s.split(' ',1)
2009-
magic_name = args[0]
2008+
magic_name, _, magic_args = arg_s.partition(' ')
20102009
magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
20112010

2012-
try:
2013-
magic_args = args[1]
2014-
except IndexError:
2015-
magic_args = ''
20162011
fn = getattr(self,'magic_'+magic_name,None)
20172012
if fn is None:
20182013
error("Magic function `%s` not found." % magic_name)

0 commit comments

Comments
 (0)