##// END OF EJS Templates
better UsageError for cell magic with no body...
MinRK -
Show More
@@ -2111,13 +2111,15 b' class InteractiveShell(SingletonConfigurable):'
2111 fn = self.find_cell_magic(magic_name)
2111 fn = self.find_cell_magic(magic_name)
2112 if fn is None:
2112 if fn is None:
2113 lm = self.find_line_magic(magic_name)
2113 lm = self.find_line_magic(magic_name)
2114 etpl = "Cell magic function `%%{0}` not found{1}."
2114 etpl = "Cell magic `%%{0}` not found{1}."
2115 extra = '' if lm is None else (' (But line magic `%{0}` exists, '
2115 extra = '' if lm is None else (' (But line magic `%{0}` exists, '
2116 'did you mean that instead?)'.format(magic_name))
2116 'did you mean that instead?)'.format(magic_name))
2117 error(etpl.format(magic_name, extra))
2117 error(etpl.format(magic_name, extra))
2118 elif cell == '':
2118 elif cell == '':
2119 raise UsageError('%%{0} (with double %) expects code beneath it. '
2119 message = '%%{0} is a cell magic, but the cell body is empty.'.format(magic_name)
2120 'Did you mean %{0} (single %)?'.format(magic_name))
2120 if self.find_line_magic(magic_name) is not None:
2121 message += ' Did you mean the line magic %{0} (single %)?'.format(magic_name)
2122 raise UsageError(message)
2121 else:
2123 else:
2122 # Note: this is the distance in the stack to the user's frame.
2124 # Note: this is the distance in the stack to the user's frame.
2123 # This will need to be updated if the internal calling logic gets
2125 # This will need to be updated if the internal calling logic gets
General Comments 0
You need to be logged in to leave comments. Login now