exception unicode handling in %run is faulty in qtconsole #535

jstenar opened this Issue Jun 22, 2011 · 6 comments


None yet

3 participants

IPython member

On master 1144388 %running:

# -*- coding: ISO-8859-1 -*-

as a script from the regular ipython console I get:

AttributeError                            Traceback (most recent call last)
C:\python\external\ipy-bugs\run_qtcons_bug.py in <module>()
      3 a=[]
----> 4 a.apppend(u"åäö")

AttributeError: 'list' object has no attribute 'apppend'

from qtconsole I get a long traceback that ends in:

c:\python26\lib\json\encoder.pyc in _iterencode(self, o, markers)
292                     and not (_encoding == 'utf-8')):
293                 o = o.decode(_encoding)
--> 294             yield encoder(o)
295         elif o is None:
296             yield 'null'
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 292: invalid continuation byte
IPython member

Can you put the full traceback in a pastebin somewhere, and give a link to it?

IPython member

OK, I think the issue is that we read the file without worrying about its encoding. That's fine at the terminal, where we can just dump it back out without trying to encode or decode it. It's more complicated for sending it as JSON.

@jstenar jstenar closed this Jun 22, 2011
@jstenar jstenar reopened this Jun 22, 2011
IPython member

Oops pushed the wrong button. Did not mean to close it.

IPython member

This one, at least, I can replicate. I think it may have to wait for an overhaul of the exception handling code, though. In the meantime, ensure that your editor is set to save in UTF-8.

IPython member

This should be fixed by PR #770

@minrk minrk added a commit to minrk/ipython that referenced this issue Sep 9, 2011
@minrk minrk json_clean zmqshell replies
closes gh-535
@minrk minrk was assigned Sep 9, 2011
@minrk minrk closed this Oct 14, 2011
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@minrk minrk json_clean zmqshell replies
closes gh-535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment