exceptions.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. '''
  2. Custom exceptions raised by pytz.
  3. '''
  4. __all__ = [
  5. 'UnknownTimeZoneError', 'InvalidTimeError', 'AmbiguousTimeError',
  6. 'NonExistentTimeError',
  7. ]
  8. class UnknownTimeZoneError(KeyError):
  9. '''Exception raised when pytz is passed an unknown timezone.
  10. >>> isinstance(UnknownTimeZoneError(), LookupError)
  11. True
  12. This class is actually a subclass of KeyError to provide backwards
  13. compatibility with code relying on the undocumented behavior of earlier
  14. pytz releases.
  15. >>> isinstance(UnknownTimeZoneError(), KeyError)
  16. True
  17. '''
  18. pass
  19. class InvalidTimeError(Exception):
  20. '''Base class for invalid time exceptions.'''
  21. class AmbiguousTimeError(InvalidTimeError):
  22. '''Exception raised when attempting to create an ambiguous wallclock time.
  23. At the end of a DST transition period, a particular wallclock time will
  24. occur twice (once before the clocks are set back, once after). Both
  25. possibilities may be correct, unless further information is supplied.
  26. See DstTzInfo.normalize() for more info
  27. '''
  28. class NonExistentTimeError(InvalidTimeError):
  29. '''Exception raised when attempting to create a wallclock time that
  30. cannot exist.
  31. At the start of a DST transition period, the wallclock time jumps forward.
  32. The instants jumped over never occur.
  33. '''