IPythonのUnicode問題

python manage.py shellでテストしているときに気づいたこと。
IPythonだとUnicodeが正しく扱われない様子。

標準のインタプリタだと

$ python
Python 2.4.3 (#1, Nov  4 2006, 21:43:51) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'あいうえお'
>>> u = u'あいうえお'
>>> print a
あいうえお
>>> print u
あいうえお
>>> len(a)
15
>>> len(u)
5

IPythonだと

$ ipython
Python 2.4.3 (#1, Nov  4 2006, 21:43:51) 
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 = 'あいうえお'

In [2]: u = u'あいうえお'

In [3]: print a
あいうえお

In [4]: print u
あいうえお

In [5]: len(a)
Out[5]: 15

In [6]: len(u)
Out[6]: 15

困っている方々

バグレポート


http://projects.scipy.org/ipython/ipython/ticket/129
によると修正されたらしい。Milestoneは0.7.4。

$ port list py-ipython
py-ipython                     @0.7.2          python/py-ipython

バージョンがあがるまで無視か。