OOPS setting US/Pacific-New timezone

Bug #244681 reported by Diogo Matsubara
2
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Undecided
Edwin Grubbs
pytz
Fix Released
Medium
Stuart Bishop
python-tz (Ubuntu)
Fix Released
High
Unassigned

Bug Description

Steps to reproduce:
1. Open http://launchpad.dev/~name12/+edit
2. In Time zone select: "US/Pacific-New"
3. Click Save
4. OOPS-913EA340 IOError: [Errno 2] No such file or directory: '/usr/share/zoneinfo/US/Pacific-New'

Changed in launchpad:
assignee: nobody → edwin-grubbs
Revision history for this message
Stuart Bishop (stub) wrote :

pytz should sanitize common_timezones and all_timezones so that only timezones that are actually available are listed. It isn't a problem with the default setup, but is an issue when the timezone files being used are not the ones distributed with pytz (such as is the case with the Ubuntu package).

Changed in pytz:
importance: Undecided → Medium
status: New → Triaged
Changed in python-tz:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Stuart Bishop (stub) wrote :

This is another manifestation of Bug #207604.

Revision history for this message
Stuart Bishop (stub) wrote :

The following monkey patch should get Launchpad happy for now with minimal effort:

$ python
Python 2.5.2 (r252:60911, May 7 2008, 15:21:12)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytz
>>> 'US/Pacific-New' in pytz.common_timezones
True
>>> for timezone_name in pytz.all_timezones[:]:
... try:
... ignored_tzinfo = pytz.timezone(timezone_name)
... except:
... pytz.all_timezones.remove(timezone_name)
... pytz.common_timezones.remove(timezone_name)
...
>>> 'US/Pacific-New' in pytz.common_timezones

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Loading all the timezone objects is definitely the most thorough check, but it takes at least 300 milliseconds. Checking that the timezone files exist with os.path.isfile only takes 4 milliseconds.

>>> for timezone_name in pytz.common_timezones:
... if not os.path.isfile(os.path.join(dir, timezone_name)):
... pytz.common_timezones.remove(timezone_name)

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

pytz.timezone() should also catch the IOError and throw a pytz.UnknownTimeZoneError even though it is very unlikely to occur if pytz.all_timezones_set is clean, but that also depends on whether they are preloaded or if all_timezones_set is just verified with os.path.isfile().

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Fixed and cherry picked.

Changed in launchpad:
status: New → Fix Committed
Revision history for this message
Diogo Matsubara (matsubara) wrote :

This was fixed by running a DB query <https://pastebin.canonical.com/6996/> which converted US/Pacific-New timezone to US/Pacific

More details <https://launchpad.canonical.com/LaunchpadProductionStatus?action=recall&rev=958>

Changed in launchpad:
status: Fix Committed → Fix Released
Stuart Bishop (stub)
Changed in pytz:
assignee: nobody → stub
status: Triaged → Fix Committed
Stuart Bishop (stub)
Changed in pytz:
status: Fix Committed → Fix Released
Matthias Klose (doko)
Changed in python-tz:
status: Confirmed → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-tz - 2008h-1

---------------
python-tz (2008h-1) unstable; urgency=low

  * New upstream version.
    - Fixes lookup errors with unknown timezones (error setting US/Pacific-New
      timezone. LP: #244681).
  * debian/copyright: Update copyright year and download location.
  * debian/control: Update homepage.

python-tz (2008c-2) unstable; urgency=low

  * Do not use setuptools to build the package (the setup falls back to
    distutils).
  * Set version to 2008c. Closes: #489979.

python-tz (2008c-1) unstable; urgency=low

  * New upstream release.

 -- Matthias Klose <email address hidden> Thu, 13 Nov 2008 14:50:15 +0000

Changed in python-tz:
status: In Progress → Fix Released
Revision history for this message
tpederson (ted-pederson) wrote :

I ran setup for pytz 2009l on my windows box. My zoneinfo directory has files for all time zones, but a number of those files are blank, and calling timezone('America/Los_Angeles') for example (LA file is empty) causes unpack to throw an exception.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.