Skip to content

Commit

Permalink
Only tell the user about %paste in the terminal shell.
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Jul 13, 2011
1 parent 1848240 commit 441946f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions IPython/core/interactiveshell.py
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions IPython/frontend/terminal/interactiveshell.py
Expand Up @@ -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.