[IPython-dev] can't %edit python statement inclued non-ascii charset

Ville M. Vainio vivainio@gmail....
Wed Mar 12 06:25:35 CDT 2008


2008/3/12 tocer <tocer.deng@gmail.com>:

>  I typed a python statement inclued non_ascii charset,such as:
>
>  In [1] : s = '你好'   # it's a Chinses string
>
>  when I wanted to edit the statement again by typing edit command:
>
>  In [2]: edit In[1]
>
>  a error occured:
>
>  UnicodeEncodeError: 'ascii' codec can't encode characters in
>  position 5-6: ordinal not in range(128)
>
>  how could I make the mistake disapper.

The patent answer with unicode errors is, don't do that ;-).

The stable IPython neglects unicode on various points, and changing
things will cause other parts to break. If you want to provide a
solution, create a new branch on bzr about it and try to fix it in
Magic.py -> magic_edit. This typically involves encoding/decoding
to/from stdin_encoding (grep iplib.py for that to see how it works).
However, it's not certain such a fix will be merged into trunk, due to
regression risks and the current stability requirements of ipython
trunk.

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-dev mailing list