Bug 111341 - default string encoding in Python should be UTF-8
default string encoding in Python should be UTF-8
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: python (Show other bugs)
1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Mihai Ibanescu
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-12-02 07:40 EST by Juha Sahakangas
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-09-30 14:29:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Juha Sahakangas 2003-12-02 07:40:59 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
lines:

import sys, locale
                                                                     
          
encoding = locale.getdefaultlocale()[1]
sys.setdefaultencoding(encoding)


Version-Release number of selected component (if applicable):


How reproducible:
Always

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.
Comment 1 Mihai Ibanescu 2005-04-20 15:56:10 EDT
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?
Comment 2 Juha Sahakangas 2005-04-21 02:07:36 EDT
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.
Comment 3 Mihai Ibanescu 2005-09-30 14:29:02 EDT
OK, I will close this. I would suggest send the patch upstream, to the python
developers.

Note You need to log in before you can comment on or make changes to this bug.