Permalink
Browse files

Only tell the user about %paste in the terminal shell.

  • Loading branch information...
1 parent 1848240 commit 441946f1b47462cb0827098e95a3d3d642941b11 @takluyver committed Jul 13, 2011
Showing with 9 additions and 2 deletions.
  1. +5 −2 IPython/core/interactiveshell.py
  2. +4 −0 IPython/frontend/terminal/interactiveshell.py
@@ -1605,6 +1605,10 @@ def showsyntaxerror(self, filename=None):
value = msg, (filename, lineno, offset, line)
stb = self.SyntaxTB.structured_traceback(etype, value, [])
self._showtraceback(etype, value, stb)
+
+ # This is overridden in TerminalInteractiveShell to show a message about
+ # the %paste magic.
+ showindentationerror = showsyntaxerror
#-------------------------------------------------------------------------
# Things related to readline
@@ -2274,8 +2278,7 @@ def run_cell(self, raw_cell, store_history=True):
try:
code_ast = ast.parse(cell, filename=cell_name)
except IndentationError:
- self.showsyntaxerror()
- print("If you want to paste code into IPython, try the %paste magic function.")
+ self.showindentationerror()
self.execution_count += 1
return None
except (OverflowError, SyntaxError, ValueError, TypeError,
@@ -588,6 +588,10 @@ def magic_paste(self, parameter_s=''):
write("## -- End pasted text --\n")
self._execute_block(block, par)
+
+ def showindentationerror(self):
+ super(TerminalInteractiveShell, self).showindentationerror()
+ print("If you want to paste code into IPython, try the %paste magic function.")
InteractiveShellABC.register(TerminalInteractiveShell)

0 comments on commit 441946f

Please sign in to comment.