Ticket #10335: tzinfo-check-encoding-supported-by-python.diff

File tzinfo-check-encoding-supported-by-python.diff, 727 bytes (added by Gunnlaugur Þór Briem, 16 years ago)

Still more conservative patch. This one just checks that the encoding is known to Python (and slightly amends a comment)

  • django/utils/tzinfo.py

     
    44import time
    55from datetime import timedelta, tzinfo
    66from django.utils.encoding import smart_unicode
     7from encodings import codecs
    78
    89try:
    910    DEFAULT_ENCODING = locale.getdefaultlocale()[1] or 'ascii'
     11    codecs.getdecoder(DEFAULT_ENCODING) # check that it is supported by Python, see #10335
    1012except:
    11     # Any problems at all determining the locale and we fallback. See #5846.
     13    # Any problems at all determining the encoding and we fallback. See #5846.
    1214    DEFAULT_ENCODING = 'ascii'
    1315
    1416class FixedOffset(tzinfo):
Back to Top