diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-05-08 09:56:25 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-05-08 09:56:25 +0000 |
| commit | a109a223b83fa7fc4e46795219a545a651e8f8a9 (patch) | |
| tree | c0a42c2c3d21768555e34d1d690300a055ac78be /django/utils/encoding.py | |
| parent | e93b3a7b02ab3c8fb04a794458c85a5f6d7f26b1 (diff) | |
[1.0.X] Fixed #10335: handle system locals unknown to Python in timezone name handling. Thanks, mitsuhiko. Backport of [10703] from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10704 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/encoding.py')
| -rw-r--r-- | django/utils/encoding.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 9388d67f4c..335f1a1551 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -1,6 +1,8 @@ import types import urllib +import locale import datetime +import codecs from django.utils.functional import Promise @@ -136,3 +138,12 @@ def iri_to_uri(iri): return iri return urllib.quote(smart_str(iri), safe='/#%[]=:;$&()+,!?*') + +# The encoding of the default system locale but falls back to the +# given fallback encoding if the encoding is unsupported by python or could +# not be determined. See tickets #10335 and #5846 +try: + DEFAULT_LOCALE_ENCODING = locale.getdefaultlocale()[1] or 'ascii' + codecs.lookup(DEFAULT_LOCALE_ENCODING) +except: + DEFAULT_LOCALE_ENCODING = 'ascii' |
