Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/sage/repl/interface_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ def cell_magic_factory(self):
Traceback (most recent call last):
...
SyntaxError: Interface magics have no options, got "foo"
sage: try:
....: cell_magic('foo', '1+1;')
....: except SyntaxError as e:
....: print(f"text attribute: {e.text!r}")
text attribute: '%%gap foo'

This is how the built cell magic is used in practice::

Expand Down Expand Up @@ -289,7 +294,9 @@ def cell_magic(line, cell):
options.
"""
if line:
raise SyntaxError('Interface magics have no options, got "{0}"'.format(line))
err = SyntaxError('Interface magics have no options, got "{0}"'.format(line))
err.text = '%%{0} {1}'.format(self._name, line)
raise err
output = self._interface.eval(cell)
print(output)
cell_magic.__doc__ = CELL_DOCSTRING.format(name=self._name)
Expand Down
Loading