[IPython-dev] paste magic command not working

Doug Blank doug.blank at gmail.com
Mon Jan 20 14:07:13 EST 2014


On Mon, Jan 20, 2014 at 1:47 PM, Julian Taylor
<jtaylor.debian at googlemail.com> wrote:
> On 20.01.2014 15:15, Matthias BUSSONNIER wrote:
>> Hi Mauricio,
>>
>> Be careful when modifying system files, your updates might not behave correctly afterwards.
>> The differences between your file (debian) and original one seem to be due to a custom debian patch
>>  (cc jtaylor as he appears to be the author of debianize-error-messages.patch).
>>
>
> sorry the patch seems broken and I'll fix it in the next upload.
> but can someone explain to me why its broken?
> how can an import that is never called cause an unbound name error?
>
> import IPython.utils.py3compat as py3compat
> def tkinter_clipboard_get():
>     try:
>         import tkinter
>     except ImportError:
>         import IPython.utils.py3compat as py3compat
>         raise TryNext("%s" % ("python3" if py3compat.PY3 else "python"))
>     root = tkinter.Tk()
>     root.withdraw()
>     text = root.clipboard_get()
>     root.destroy()
>     # error here after successful tkinter import
>     text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)
>     return text

The error is that py3compat.cast_unicode() is called outside of the
except block. So, it appears that the import should not be inside the
exception (eg, the import is only done when there is an error).

Hope that helps,

-Doug

> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev



More information about the IPython-dev mailing list