jpayne@68: ''' jpayne@68: Custom exceptions raised by pytz. jpayne@68: ''' jpayne@68: jpayne@68: __all__ = [ jpayne@68: 'UnknownTimeZoneError', 'InvalidTimeError', 'AmbiguousTimeError', jpayne@68: 'NonExistentTimeError', jpayne@68: ] jpayne@68: jpayne@68: jpayne@68: class Error(Exception): jpayne@68: '''Base class for all exceptions raised by the pytz library''' jpayne@68: jpayne@68: jpayne@68: class UnknownTimeZoneError(KeyError, Error): jpayne@68: '''Exception raised when pytz is passed an unknown timezone. jpayne@68: jpayne@68: >>> isinstance(UnknownTimeZoneError(), LookupError) jpayne@68: True jpayne@68: jpayne@68: This class is actually a subclass of KeyError to provide backwards jpayne@68: compatibility with code relying on the undocumented behavior of earlier jpayne@68: pytz releases. jpayne@68: jpayne@68: >>> isinstance(UnknownTimeZoneError(), KeyError) jpayne@68: True jpayne@68: jpayne@68: And also a subclass of pytz.exceptions.Error, as are other pytz jpayne@68: exceptions. jpayne@68: jpayne@68: >>> isinstance(UnknownTimeZoneError(), Error) jpayne@68: True jpayne@68: jpayne@68: ''' jpayne@68: pass jpayne@68: jpayne@68: jpayne@68: class InvalidTimeError(Error): jpayne@68: '''Base class for invalid time exceptions.''' jpayne@68: jpayne@68: jpayne@68: class AmbiguousTimeError(InvalidTimeError): jpayne@68: '''Exception raised when attempting to create an ambiguous wallclock time. jpayne@68: jpayne@68: At the end of a DST transition period, a particular wallclock time will jpayne@68: occur twice (once before the clocks are set back, once after). Both jpayne@68: possibilities may be correct, unless further information is supplied. jpayne@68: jpayne@68: See DstTzInfo.normalize() for more info jpayne@68: ''' jpayne@68: jpayne@68: jpayne@68: class NonExistentTimeError(InvalidTimeError): jpayne@68: '''Exception raised when attempting to create a wallclock time that jpayne@68: cannot exist. jpayne@68: jpayne@68: At the start of a DST transition period, the wallclock time jumps forward. jpayne@68: The instants jumped over never occur. jpayne@68: '''