Loading django/utils/encoding.py +11 −0 Original line number Diff line number Diff line import types import urllib import locale import datetime import codecs from django.utils.functional import Promise Loading Loading @@ -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' django/utils/tzinfo.py +4 −10 Original line number Diff line number Diff line "Implementation of tzinfo classes for use with datetime.datetime." import locale import time from datetime import timedelta, tzinfo from django.utils.encoding import smart_unicode try: DEFAULT_ENCODING = locale.getdefaultlocale()[1] or 'ascii' except: # Any problems at all determining the locale and we fallback. See #5846. DEFAULT_ENCODING = 'ascii' from django.utils.encoding import smart_unicode, smart_str, DEFAULT_LOCALE_ENCODING class FixedOffset(tzinfo): "Fixed offset in minutes east from UTC." Loading Loading @@ -41,7 +34,7 @@ class LocalTimezone(tzinfo): self._tzname = self.tzname(dt) def __repr__(self): return self._tzname return smart_str(self._tzname) def utcoffset(self, dt): if self._isdst(dt): Loading @@ -57,7 +50,8 @@ class LocalTimezone(tzinfo): def tzname(self, dt): try: return smart_unicode(time.tzname[self._isdst(dt)], DEFAULT_ENCODING) return smart_unicode(time.tzname[self._isdst(dt)], DEFAULT_LOCALE_ENCODING) except UnicodeDecodeError: return None Loading Loading
django/utils/encoding.py +11 −0 Original line number Diff line number Diff line import types import urllib import locale import datetime import codecs from django.utils.functional import Promise Loading Loading @@ -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'
django/utils/tzinfo.py +4 −10 Original line number Diff line number Diff line "Implementation of tzinfo classes for use with datetime.datetime." import locale import time from datetime import timedelta, tzinfo from django.utils.encoding import smart_unicode try: DEFAULT_ENCODING = locale.getdefaultlocale()[1] or 'ascii' except: # Any problems at all determining the locale and we fallback. See #5846. DEFAULT_ENCODING = 'ascii' from django.utils.encoding import smart_unicode, smart_str, DEFAULT_LOCALE_ENCODING class FixedOffset(tzinfo): "Fixed offset in minutes east from UTC." Loading Loading @@ -41,7 +34,7 @@ class LocalTimezone(tzinfo): self._tzname = self.tzname(dt) def __repr__(self): return self._tzname return smart_str(self._tzname) def utcoffset(self, dt): if self._isdst(dt): Loading @@ -57,7 +50,8 @@ class LocalTimezone(tzinfo): def tzname(self, dt): try: return smart_unicode(time.tzname[self._isdst(dt)], DEFAULT_ENCODING) return smart_unicode(time.tzname[self._isdst(dt)], DEFAULT_LOCALE_ENCODING) except UnicodeDecodeError: return None Loading