Outlining our code, I'm surprised to find millions of calls for C #: \ Python 26 \ bb \ encoding \ utf_8 Happened. Kpisi: 15 (decoded) to
I started debugging and found that many small bug in our code base, usually comparing Unicode strings or add sting and Unicode. Python decodes the wire by indulgence and does the following tasks in Unicode.
In what way but expensive!
I'm reading'm fluent in Unicode, and ...
I try to keep my code internal Unicode.
My question - can I stop this python good-man behavior? At least until I find all these bugs and remove them properly (usually by adding u'u)?
Some of them are very hard to find (a variable that is sometimes a string ...).
Python 2.6.5 (and I can not switch to 3.x).
should do the following:
& gt; & Gt; & Gt; Import systems and gt; & Gt; & Gt; Reload (sys) & lt; Module 'sys' (built-in) & gt; & Gt; & Gt; & Gt; Sys.setdefaultencoding ('undefined') & gt; & Gt; & Gt; U "abc" + u "xyz" u'abcxyz '& gt; & Gt; & Gt; U "abc" + "xyz" Traceback (most recent call last): File "& LT; stdin & gt;", line 1, & lt; Module & gt; File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/encodings/undefined.py", line 22, increased to decode UnicodeError ( "undefined encoding") UnicodeError: undefined encoding
reload (cis) from above the normally snippet
is only required sys.setdefaultencoding
in a sitecustomize Is supposed to go. Py
file directory in your python site-package (it is advisable to do this)
Comments
Post a Comment