Unspecific Exception for .localize() of non-existent local time

Bug #195626 reported by Paul Lanier
10
Affects Status Importance Assigned to Milestone
pytz
Fix Released
Wishlist
Stuart Bishop

Bug Description

If you try to localize() a non-existent datetime like datetime.datetime(2008, 3, 9, 2, 30) to US/Pacific, you get an IndexError. It would be much nicer if there were a custom Exception type for this case. Reusing AmbiguousTimeError would be OK but I think a distinct Exception type would be better. If you set is_dst=None then you do get an AmbiguousTimeError but this is not really correct since the time is non-existent rather than ambiguous and the handling of user input of such a time would be different than user input of an ambiguous time at the end of dst.

Related branches

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

This shouldn't be a problem. A subclass of IndexError would be best.

Changed in pytz:
importance: Undecided → Wishlist
status: New → Triaged
Stuart Bishop (stub)
Changed in pytz:
assignee: nobody → stub
status: Triaged → In Progress
Stuart Bishop (stub)
Changed in pytz:
status: In Progress → Fix Committed
Stuart Bishop (stub)
Changed in pytz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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