Red Hat Bugzilla – Bug 111341
default string encoding in Python should be UTF-8
Last modified: 2007-11-30 17:10:34 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016
Description of problem:
Since Fedora is always running on UTF-8 locale by default and is
nigh-impossible to even change away from this mode, all programs
should except UTF-8 input by default.
Python expects ASCII data and will complain about other characters if
you don't explicitly specify it's encoding.
This could be easily resolved by having
/usr/lib/python2.2/site-packages/sitecustomize.py along the following
import sys, locale
encoding = locale.getdefaultlocale()
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. open interactive python interpreter
2. type for example 'â¬'.decode()
Actual Results: Python throws UnicodeError with message: ASCII
decoding error: ordinal not in range(128)
Expected Results: Unicode string u'\u20ac' should be displayed.
Looks like python 2.4.1 completely removes setdefaultencoding in site.py. Were
you able to make your patch work with newer versions of python?
Seems to work without modification in ubuntu hoary 2.4.1, python.org 2.4.1 rpm's
for fc3 and activepython 2.4.1 for windows, not a slightest idea what might be
different in fc4/rawhide python.
However, I'm no longer sure if doing this would be so bright after all, it'd be
damn convenient every now and then, especially when fiddling around in the
interactive interpreter, but on the other hand it could encourage writing apps
that might not work without modification on other systems that do not set
non-ascii default encoding.
OK, I will close this. I would suggest send the patch upstream, to the python