Line 27: | Line 27: | ||
<!-- Expand on the summary, if appropriate. A couple sentences suffices to explain the goal, but the more details you can provide the better. --> | <!-- Expand on the summary, if appropriate. A couple sentences suffices to explain the goal, but the more details you can provide the better. --> | ||
https://bugzilla.redhat.com/show_bug.cgi?id=243541 | https://bugzilla.redhat.com/show_bug.cgi?id=243541 | ||
Currently Fedora's python implementation uses <code>ascii</code> | |||
Python's <code>site.py</code> includes this fragment of code: | |||
<pre> | |||
def setencoding(): | |||
"""Set the string encoding used by the Unicode implementation. The | |||
default is 'ascii', but if you're willing to experiment, you can | |||
change this.""" | |||
encoding = "ascii" # Default value set by _PyUnicode_Init() | |||
if 0: | |||
# Enable to support locale aware default string encodings. | |||
import locale | |||
loc = locale.getdefaultlocale() | |||
if loc[1]: | |||
encoding = loc[1] | |||
if 0: | |||
# Enable to switch off string to Unicode coercion and implicit | |||
# Unicode to string conversion. | |||
encoding = "undefined" | |||
if encoding != "ascii": | |||
# On Non-Unicode builds this will raise an AttributeError... | |||
sys.setdefaultencoding(encoding) # Needs Python Unicode build ! | |||
</pre> | |||
It is proposed to change the first conditional to <code>if 1:</code> so that Fedora's Python by default reads the locale from the environment and uses that encoding. This will generally mean <code>UTF-8</code> is used, rather than <code>ascii</code>. | |||
== Benefit to Fedora == | == Benefit to Fedora == |
Revision as of 19:12, 6 January 2010
Feature Name
Summary
Make Python use a locale-aware default string encoding (generally "UTF-8"), rather than hardcoding "ascii".
Owner
- Name: Dave Malcolm
- Email: <dmalcolm@redhat.com>
Current status
- Targeted release: Fedora 42
- Last updated: (DATE)
- Percentage of completion: XX%
Detailed Description
https://bugzilla.redhat.com/show_bug.cgi?id=243541
Currently Fedora's python implementation uses ascii
Python's site.py
includes this fragment of code:
def setencoding(): """Set the string encoding used by the Unicode implementation. The default is 'ascii', but if you're willing to experiment, you can change this.""" encoding = "ascii" # Default value set by _PyUnicode_Init() if 0: # Enable to support locale aware default string encodings. import locale loc = locale.getdefaultlocale() if loc[1]: encoding = loc[1] if 0: # Enable to switch off string to Unicode coercion and implicit # Unicode to string conversion. encoding = "undefined" if encoding != "ascii": # On Non-Unicode builds this will raise an AttributeError... sys.setdefaultencoding(encoding) # Needs Python Unicode build !
It is proposed to change the first conditional to if 1:
so that Fedora's Python by default reads the locale from the environment and uses that encoding. This will generally mean UTF-8
is used, rather than ascii
.