[IPython-user] problem with unicode and the compile function in ipython
pan
nirvana117@gmail....
Wed Nov 28 22:56:04 CST 2007
And because python2.3 lacks sys.setappdefaultencoding, so have to
reload(sys), and use sys.setdefaultencoding.
The patch for svn-2875:
Index: IPython/iplib.py
===================================================================
--- IPython/iplib.py (修订版 2876)
+++ IPython/iplib.py (工作拷贝)
@@ -79,6 +79,14 @@
import IPython.shadowns
# Globals
+# make converting between str and unicode easy
+try:
+ sys.setappdefaultencoding(sys.stdin.encoding or 'ascii')
+except:
+ # python2.3 does not have sys.setappdefaultencoding
+ reload(sys)
+ sys.setdefaultencoding(sys.stdin.encoding or 'ascii')
+
# store the builtin raw_input globally, and use this always, in case user
code
# overwrites it (like wx.py.PyShell does)
raw_input_original = raw_input
@@ -1911,7 +1919,7 @@
# this allows execution of indented pasted code. It is tempting
# to add '\n' at the end of source to run commands like ' a=1'
# directly, but this fails for more complicated scenarios
- source=source.encode(self.stdin_encoding)
+ source = str(source)
if source[:1] in [' ', '\t']:
source = 'if 1:\n%s' % source
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20071129/3e64e543/attachment-0001.html
More information about the IPython-user
mailing list