Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#10048 closed (fixed)

Check for no timezone in dateformat.py

Reported by: Claude Paroz Owned by: nobody
Component: Core (Other) Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The DateFormat class in source:django/trunk/django/utils/dateformat.py has a self.timezone attribute that can be None (self.timezone = getattr(dt, 'tzinfo', None)). However, it is not checked for None value when called in I(), T(), U() and Z() methods.

This can lead to AttributeError:

File "/usr/lib/python2.5/site-packages/django/utils/dateformat.py", line 195, in T
    name = self.timezone.tzname(self.data)

AttributeError: 'NoneType' object has no attribute 'tzname'

Change History (4)

comment:1 Changed 8 years ago by Jacob

milestone: 1.1
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [9919]) Fixed #10048 -- Handle non-existent timezone in dateformat functions.

comment:3 Changed 8 years ago by Malcolm Tredinnick

(In [9920]) [1.0.X] Fixed #10048 -- Handle non-existent timezone in dateformat functions.

Backport of r9919 from trunk.

comment:4 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top