pytz dst() incorrectly handles Pacific/Apia day leap
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pytz |
Fix Released
|
High
|
Stuart Bishop | ||
python-tz (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Lucid |
Fix Released
|
High
|
Unassigned | ||
Maverick |
Fix Released
|
High
|
Unassigned | ||
Natty |
Fix Released
|
High
|
Unassigned | ||
Oneiric |
Fix Released
|
High
|
Unassigned |
Bug Description
Request for SRU for Lucid, Maverick, Natty and Oneiric
=======
1. Impact
- Incorrect calculation of DST changes
- Landscape failure to accept new users or edit current users' setting
- "Django timezones app "timezones.zones" module unimportable" (reported on comment #11)
2. Development fix
The issue was fixed upstream in revision 268:
http://
That is the diff grabbed for this SRU.
The same diff is also applied to the python-tz package in the current ubuntu development version (precise).
3. Stable fix
The development fix applies cleanly to the stable releases.
4. Test case
Run the script below. If you get a backtrace, you are affected. If not, the bug is fixed in your environment:
#!/usr/bin/python
import pytz
from datetime import datetime
tz = pytz.timezone(
d2 = datetime(2012,1,1)
local = tz.localize(d2)
local.dst()
print "All is good, NOT hit by bug #885163!"
5. Regression potential
Not sure, timezones can be tricky. I welcome comments from upstream for this section since I basically packaged their fix. The patch is minimal, and it fixed the problems we were having in our production servers.
Original bug description follows:
=======
>>> from datetime import datetime
>>> import pytz
>>> tz = pytz.timezone(
>>> d1 = datetime(2011, 11, 1)
>>> d2 = datetime(2012, 1, 1)
>>> tz.dst(d1)
datetime.
>>> tz.dst(d2)
datetime.
while utcoffset is correct:
>>> tz.utcoffset(d1)
datetime.
>>> tz.utcoffset(d2)
datetime.
Related branches
- Ubuntu branches: Pending requested
-
Diff: 71 lines (+52/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/samoa-idl (+44/-0)
debian/patches/series (+1/-0)
Changed in pytz: | |
status: | New → Confirmed |
importance: | Undecided → High |
Changed in pytz: | |
assignee: | nobody → Stuart Bishop (stub) |
status: | Fix Committed → Fix Released |
tags: | removed: patch |
description: | updated |
Changed in python-tz (Ubuntu Lucid): | |
status: | New → Fix Committed |
importance: | Undecided → High |
Changed in python-tz (Ubuntu Maverick): | |
importance: | Undecided → High |
Changed in python-tz (Ubuntu Natty): | |
importance: | Undecided → High |
Changed in python-tz (Ubuntu Oneiric): | |
importance: | Undecided → High |
Changed in python-tz (Ubuntu Maverick): | |
status: | New → Fix Committed |
Changed in python-tz (Ubuntu Natty): | |
status: | New → Fix Committed |
Changed in python-tz (Ubuntu Oneiric): | |
status: | New → Fix Committed |
tags: |
added: verification-done removed: verification-needed |
It affects python's datetime.dst method:
>>> local = tz.localize(d2)
>>> local.dst()
Traceback (most recent call last):
File "<input>", line 1, in <module>
ValueError: tzinfo.dst() returned 1440; must be in -1439 .. 1439
and strftime: '%H:%M' )
>>> local.strftime(
Traceback (most recent call last):
File "<input>", line 1, in <module>
ValueError: tzinfo.dst() returned 1440; must be in -1439 .. 1439