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