Bug 111341 - default string encoding in Python should be UTF-8
Summary: default string encoding in Python should be UTF-8
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: python
Version: 1
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Mihai Ibanescu
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-12-02 12:40 UTC by Juha Sahakangas
Modified: 2007-11-30 22:10 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2005-09-30 18:29:02 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Juha Sahakangas 2003-12-02 12:40:59 UTC
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 19:56:10 UTC
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 06:07:36 UTC
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 18:29:02 UTC
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.