Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix for issue #56 #861

merged 3 commits into from

2 participants


Used a try block to catch ctrl-d (EOFError) as a sentinel. Also added printing of "<EOF>" on the line where ctrl-d was pressed.

@fperez fperez merged commit db84fc9 into ipython:master

Thanks a lot, @djv!

@fperez fperez referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2011
  1. fixing issue #56

    Daniel Velkov authored
  2. Merge remote-tracking branch 'upstream/master'

    Daniel Velkov authored
  3. add feedback that ctrl-d was pressed

    Daniel Velkov authored
This page is out of date. Refresh to see the latest.
12 IPython/core/
@@ -3187,11 +3187,15 @@ def _get_pasted_lines(self, sentinel):
from IPython.core import interactiveshell
print "Pasting code; enter '%s' alone on the line to stop." % sentinel
while True:
- l =':')
- if l == sentinel:
+ try:
+ l =':')
+ if l == sentinel:
+ return
+ else:
+ yield l
+ except EOFError:
+ print '<EOF>'
- 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
2  IPython/frontend/terminal/
@@ -487,7 +487,7 @@ def magic_autoindent(self, parameter_s = ''):
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)
Something went wrong with that request. Please try again.