From a109a223b83fa7fc4e46795219a545a651e8f8a9 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 8 May 2009 09:56:25 +0000 Subject: [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 --- django/utils/encoding.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'django/utils/encoding.py') 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' -- cgit v1.3