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

pan nirvana117@gmail....
Wed Nov 28 21:17:05 CST 2007

These still are some problem, I have tested on debian and windows xp.

These are some place in ipython, using something like:

1. str(s1)                       will fail if s1 is unicode and can't be
encoded using ascii
2. '%s, %s' % (s1, s2)    will fail if s1 is str and can't be decoded using
ascii, and s2 is unicode

I found a easy way to fix is:

import sys

Now python will use sys.stdout.encoding(instead of ascii) to convert string
between str and unicode.

So these is not needed to use string.decode(encoding),
unicode_string.encode(encoding), just can use str(unicode_string) or

So the above change can be:
code = self.compile(str(source),filename,symbol)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20071129/881e3b2c/attachment.html 

More information about the IPython-user mailing list