%paste throws an exception with empty clipboard #2252

Closed
dandavison opened this Issue Aug 4, 2012 · 2 comments

Comments

Projects
None yet
2 participants
  1. ipython --quick on 0.14dev 079f8ed, OS X (bug also at rel-0.13 but not rel-0.12)
  2. Empty system clipboard
  3. %paste
lib/python/ipython ipython --quick                                           ()
Python 2.7.2 (default, Aug  4 2011, 16:59:19) 
Type "copyright", "credits" or "license" for more information.

IPython 0.14.dev -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import IPython ; IPython.__version__
Out[1]: '0.14.dev'

In [2]: %paste


## -- End pasted text --
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-2-da94f22893b1> in <module>()
----> 1 get_ipython().magic(u'paste')

/Users/davison/lib/python/ipython/IPython/core/interactiveshell.py in magic(self, arg_s)
   2167         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2168         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2169         return self.run_line_magic(magic_name, magic_arg_s)
   2170 
   2171     #-------------------------------------------------------------------------

/Users/davison/lib/python/ipython/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
   2093                 args.append(sys._getframe(stack_depth).f_locals)
   2094             with self.builtin_trap:
-> 2095                 result = fn(*args)
   2096             return result
   2097 

/Users/davison/lib/python/ipython/IPython/frontend/terminal/interactiveshell.py in paste(self, parameter_s)

/Users/davison/lib/python/ipython/IPython/core/magic.py in <lambda>(f, *a, **k)
    189     # but it's overkill for just that one bit of state.
    190     def magic_deco(arg):
--> 191         call = lambda f, *a, **k: f(*a, **k)
    192 
    193         if callable(arg):

/Users/davison/lib/python/ipython/IPython/frontend/terminal/interactiveshell.py in paste(self, parameter_s)
    288             write("## -- End pasted text --\n")
    289 
--> 290         self.store_or_execute(block, name)
    291 
    292     # Class-level: add a '%cls' magic only on Windows

/Users/davison/lib/python/ipython/IPython/frontend/terminal/interactiveshell.py in store_or_execute(self, block, name)
    151         """ Execute a block, or store it in a variable, per the user's request.
    152         """
--> 153         b = self.cleanup_input(block)
    154         if name:
    155             # If storing it for further editing

/Users/davison/lib/python/ipython/IPython/frontend/terminal/interactiveshell.py in cleanup_input(self, block)
    117         # Remove email quotes first.  These must be consistently applied to
    118         # *all* lines to be removed
--> 119         b = strip_email_quotes(b)
    120 
    121         # Split the input into independent sub-blocks so we can later do

/Users/davison/lib/python/ipython/IPython/utils/text.py in strip_email_quotes(text)
    600             break
    601     else:
--> 602         prefix = long_substr(list(matches))
    603         if prefix:
    604             strip = len(prefix)

/Users/davison/lib/python/ipython/IPython/utils/text.py in long_substr(data)
    555                     substr = data[0][i:i+j]
    556     else:
--> 557         substr = data[0]
    558     return substr
    559 

IndexError: list index out of range
Owner

takluyver commented Aug 6, 2012

Should be fixed by #2261 - can someone with OS X confirm that and close this if so?

Confirmed on OSX.

dandavison closed this Aug 6, 2012

@minrk minrk added a commit that referenced this issue Aug 9, 2012

@minrk minrk Backport PR #2261: Fix: longest_substr([]) -> ''
Previously the algorithm used to find the longest common starting substring
unintentionally raised an error when it was called on an empty list.

This should fix the issue of an error being raised when running %paste
on an empty clipboard (#2252).
f043b4f

@minrk minrk added a commit that referenced this issue Sep 1, 2012

@minrk minrk Backport PR #2261: Fix: longest_substr([]) -> ''
Previously the algorithm used to find the longest common starting substring
unintentionally raised an error when it was called on an empty list.

This should fix the issue of an error being raised when running %paste
on an empty clipboard (#2252).
c166aa0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment