[IPython-User] The unicode error when print source code on ipython QT console

MinRK benjaminrk@gmail....
Sun Nov 6 11:20:05 CST 2011


I believe this has been fixed in master, can you try that?

On Sun, Nov 6, 2011 at 06:54, Tivon <holybreath@gmail.com> wrote:

> Hi, guys, I'm a new user with python 2.7 + win7 64bit + ipython + QT
> console. now I found that when I run this script:
>
> # coding: utf-8
> print '中文'+ 0
>
> when run this script in cmd console
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> D:\WORK\project management\NewPostAlert\t.py in <module>()
>       1 # coding: utf-8
>
> ----> 2 print '中文'+ 0
>       3
>       4
>       5
>
> TypeError: cannot concatenate 'str' and 'int' objects
>
> but in the qt console, it seems crash when print the source code which
> include non english character,
> the UnicodeDecodeError was thrown,so is there missed some decode thing?
>
> ---------------------------------------------------------------------------
> UnicodeDecodeError                        Traceback (most recent call last)
> D:\WORK\project management\NewPostAlert\<ipython-input-2-fe74509ea0b3> in
> <module>()
> ----> 1 get_ipython().magic(u"run t")
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\core\interactiveshell.pyc
> in magic(self, arg_s, next_input)
>    1892                 self._magic_locals = sys._getframe(1).f_locals
>    1893             with self.builtin_trap:
> -> 1894                 result = fn(magic_args)
>    1895             # Ensure we're not keeping object references around:
>
>    1896             self._magic_locals = {}
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\core\magic.pyc
> in magic_run(self, parameter_s, runner, file_finder)
>    1703                         else:
>    1704                             # regular execution
>
> -> 1705
> runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
>    1706
>    1707                 if opts.has_key('i'):
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\core\interactiveshell.pyc
> in safe_execfile(self, fname, *where, **kw)
>    2198                     self.showtraceback(exception_only=True)
>    2199             except:
> -> 2200                 self.showtraceback()
>    2201
>    2202     def safe_execfile_ipy(self, fname):
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\core\interactiveshell.pyc
> in showtraceback(self, exc_tuple, filename, tb_offset, exception_only)
>    1560
>    1561                 # Actually show the traceback
>
> -> 1562                 self._showtraceback(etype, value, stb)
>    1563
>    1564         except KeyboardInterrupt:
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\zmq\zmqshell.pyc
> in _showtraceback(self, etype, evalue, stb)
>     145         # Send exception info over pub socket for other clients
> than the caller
>
>     146         # to pick up
>
> --> 147         exc_msg = dh.session.send(dh.pub_socket, u'pyerr',
> exc_content, dh.parent_header)
>     148
>     149         # FIXME - Hack: store exception info in shell object.
>  Right now, the
>
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\zmq\session.pyc
> in send(self, stream, msg_or_type, content, parent, ident, buffers,
> subheader, track)
>     494
>     495         buffers = [] if buffers is None else buffers
> --> 496         to_send = self.serialize(msg, ident)
>     497         flag = 0
>     498         if buffers:
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\zmq\session.pyc
> in serialize(self, msg, ident)
>     404             content = self.none
>     405         elif isinstance(content, dict):
> --> 406             content = self.pack(content)
>     407         elif isinstance(content, bytes):
>     408             # content is already packed, as in a relayed message
>
>
> D:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\zmq\session.pyc
> in <lambda>(obj)
>      73
> #-----------------------------------------------------------------------------
>
>      74 key = 'on_unknown' if jsonapi.jsonmod.__name__ == 'jsonlib' else
> 'default'
> ---> 75 json_packer = lambda obj: jsonapi.dumps(obj, **{key:date_default})
>      76 json_unpacker = lambda s: extract_dates(jsonapi.loads(s))
>      77
>
> D:\Python27\lib\site-packages\zmq\utils\jsonapi.pyc in jsonlib_dumps(o,
> **kwargs)
>      65     See jsonlib.dumps for details on kwargs.
>      66     """
> ---> 67     return _squash_unicode(jsonmod.dumps(o,**kwargs))
>      68
>      69 def dumps(o, **kwargs):
>
> D:\Python27\lib\site-packages\jsonlib.pyc in write(value, sort_keys,
> indent, ascii_only, coerce_keys, encoding, on_unknown)
>     801                            validate_on_unknown (on_unknown),
>     802                            SerializerErrorHelper (),
> --> 803                    UserString, Decimal)
>     804
>     805 dumps = write
>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xd6 in position 198:
> ordinal not in range(128)
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20111106/d6e0d531/attachment-0001.html 


More information about the IPython-User mailing list