Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10048 closed (fixed)

Check for no timezone in dateformat.py

Reported by: claudep 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'

Attachments (0)

Change History (4)

comment:1 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:3 Changed 5 years ago by mtredinnick

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

Backport of r9919 from trunk.

comment:4 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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.