[IPython-dev] Bug: unicode and IPython

Alexander Belchenko bialix at ukr.net
Thu Aug 10 03:00:55 CDT 2006


This bug appears in IPython with readline installed and without also. It 
was with in Gary Bishop UNC readline and is with pyreadline 1.3 too. 
When I type russian text as unicode string (u"") IPython does not decode 
it to unicode correctly. Standard python interpreter does it well.

Below is reproduction for russian word "Тест" (it's means "Test" in english)

Standard python interpreter:

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = u"Тест"
>>> a
u'\u0422\u0435\u0441\u0442'

All correct.


IPython session:

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.7.2 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: a = u"Тест"

In [2]: a
Out[2]: u'\x92\xa5\xe1\xe2'

As you can see it's incorrect -- it's not russian unicode string.


When I uninstall pyreadline:

WARNING: Readline services not available on this platform.
WARNING: Proper color support under MS Windows requires Gary Bishop's
readline library.
You can find it at:
http://sourceforge.net/projects/uncpythontools
Gary's readline needs the ctypes module, from:
http://starship.python.net/crew/theller/ctypes

Defaulting color scheme to 'NoColor'
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.7.2 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: a = u"Тест"

In [2]: a
Out[2]: u'\x92\xa5\xe1\xe2'


Again: unicode conversion is broken.

So I think it's a bug inside IPython, not inside pyreadline.

--
Alexander



More information about the IPython-dev mailing list