Code

Opened 5 years ago

Closed 5 years ago

#10428 closed (duplicate)

django.utils.dateformat: unknown encoding: gbk2312

Reported by: anonymous Owned by: nobody
Component: Internationalization Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

when the system locale is set to "zh_CN.GBK2312", following error pop up when using DateFormat to format a datetime:

Original Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/django/template/debug.py", line 71, in render_node
    result = node.render(context)
  File "/usr/lib/python2.3/site-packages/django/template/debug.py", line 87, in render
    output = force_unicode(self.filter_expression.resolve(context))
  File "/usr/lib/python2.3/site-packages/django/template/__init__.py", line 559, in resolve
    new_obj = func(obj, *arg_vals)
  File "/usr/lib/python2.3/site-packages/django/template/defaultfilters.py", line 668, in date
    return format(value, arg)
  File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 263, in format
    df = DateFormat(value)
  File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 114, in __init__
    self.timezone = LocalTimezone(dt)
  File "/usr/lib/python2.3/site-packages/django/utils/tzinfo.py", line 41, in __init__
    self._tzname = self.tzname(dt)
  File "/usr/lib/python2.3/site-packages/django/utils/tzinfo.py", line 60, in tzname
    return smart_unicode(time.tzname[self._isdst(dt)], DEFAULT_ENCODING)
  File "/usr/lib/python2.3/site-packages/django/utils/encoding.py", line 35, in smart_unicode
    return force_unicode(s, encoding, strings_only, errors)
  File "/usr/lib/python2.3/site-packages/django/utils/encoding.py", line 68, in force_unicode
    s = s.decode(encoding, errors)
LookupError: unknown encoding: gbk2312

Sample Code:

import os

import datetime
import django.utils.dateformat

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

d = datetime.datetime.now()
print d
df = django.utils.dateformat.DateFormat(d)

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #10335

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.