[IPython-user] problem with unicode and the compile function in ipython

pan nirvana117@gmail....
Tue Nov 27 06:13:38 CST 2007

I tested on windows xp. The built-in compile function, when passed to the
first <source> argument with unicode string, the <source> would be converted
to utf8(maybe by python parser). So if the <source> contained no-ascii
characters, the no-ascii characters would be converted to utf8, and the
problem would occur like this:

In [1]: '<console-default-stdout-encoding of no-ascii characters>'
Out[1]: '<utf8-encoding of no-ascii characters>'

I suggests to change the codes in runsource in iplib.py:

"code = self.compile(source,filename,symbol)"  to
"code = self.compile(source.encode(sys.stdout.encoding),filename,symbol)"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20071127/0abeea67/attachment.html 

More information about the IPython-user mailing list