diff --git a/IPython/core/magic.py b/IPython/core/magic.py index ba8bf82..32ec4b0 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -3207,11 +3207,15 @@ Defaulting color scheme to 'NoColor'""" from IPython.core import interactiveshell print "Pasting code; enter '%s' alone on the line to stop." % sentinel while True: - l = self.shell.raw_input_original(':') - if l == sentinel: + try: + l = self.shell.raw_input_original(':') + if l == sentinel: + return + else: + yield l + except EOFError: + print '' return - else: - yield l def _strip_pasted_lines_for_code(self, raw_lines): """ Strip non-code parts of a sequence of lines to return a block of diff --git a/IPython/frontend/terminal/interactiveshell.py b/IPython/frontend/terminal/interactiveshell.py index 74f88c9..411ed2f 100644 --- a/IPython/frontend/terminal/interactiveshell.py +++ b/IPython/frontend/terminal/interactiveshell.py @@ -487,7 +487,7 @@ class TerminalInteractiveShell(InteractiveShell): def magic_cpaste(self, parameter_s=''): """Paste & execute a pre-formatted code block from clipboard. - You must terminate the block with '--' (two minus-signs) alone on the + You must terminate the block with '--' (two minus-signs) or Ctrl-D alone on the line. You can also provide your own sentinel with '%paste -s %%' ('%%' is the new sentinel for this operation)