Skip to content
This repository

Fix for issue #56 #861

Merged
merged 3 commits into from over 2 years ago

2 participants

Daniel Velkov Fernando Perez
Daniel Velkov
djv commented October 12, 2011

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.

Fernando Perez fperez merged commit db84fc9 into from October 13, 2011
Fernando Perez fperez closed this October 13, 2011
Fernando Perez
Owner

Thanks a lot, @djv!

Fernando Perez fperez referenced this pull request from a commit January 10, 2012
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

Showing 3 unique commits by 1 author.

Oct 12, 2011
fixing issue #56 609d83e
Merge remote-tracking branch 'upstream/master' 01fe623
add feedback that ctrl-d was pressed 2b7a228
This page is out of date. Refresh to see the latest.
12  IPython/core/magic.py
@@ -3187,11 +3187,15 @@ def _get_pasted_lines(self, sentinel):
3187 3187
         from IPython.core import interactiveshell
3188 3188
         print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3189 3189
         while True:
3190  
-            l = self.shell.raw_input_original(':')
3191  
-            if l == sentinel:
  3190
+            try:
  3191
+                l = self.shell.raw_input_original(':')
  3192
+                if l == sentinel:
  3193
+                    return
  3194
+                else:
  3195
+                    yield l
  3196
+            except EOFError:
  3197
+                print '<EOF>'
3192 3198
                 return
3193  
-            else:
3194  
-                yield l
3195 3199
 
3196 3200
     def _strip_pasted_lines_for_code(self, raw_lines):
3197 3201
         """ Strip non-code parts of a sequence of lines to return a block of
2  IPython/frontend/terminal/interactiveshell.py
@@ -487,7 +487,7 @@ def magic_autoindent(self, parameter_s = ''):
487 487
     def magic_cpaste(self, parameter_s=''):
488 488
         """Paste & execute a pre-formatted code block from clipboard.
489 489
 
490  
-        You must terminate the block with '--' (two minus-signs) alone on the
  490
+        You must terminate the block with '--' (two minus-signs) or Ctrl-D alone on the
491 491
         line. You can also provide your own sentinel with '%paste -s %%' ('%%'
492 492
         is the new sentinel for this operation)
493 493
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.