Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pytz-2023.3-py3.8.egg/pytz/exceptions.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 07:00 +0000

1''' 

2Custom exceptions raised by pytz. 

3''' 

4 

5__all__ = [ 

6 'UnknownTimeZoneError', 'InvalidTimeError', 'AmbiguousTimeError', 

7 'NonExistentTimeError', 

8] 

9 

10 

11class Error(Exception): 

12 '''Base class for all exceptions raised by the pytz library''' 

13 

14 

15class UnknownTimeZoneError(KeyError, Error): 

16 '''Exception raised when pytz is passed an unknown timezone. 

17 

18 >>> isinstance(UnknownTimeZoneError(), LookupError) 

19 True 

20 

21 This class is actually a subclass of KeyError to provide backwards 

22 compatibility with code relying on the undocumented behavior of earlier 

23 pytz releases. 

24 

25 >>> isinstance(UnknownTimeZoneError(), KeyError) 

26 True 

27 

28 And also a subclass of pytz.exceptions.Error, as are other pytz 

29 exceptions. 

30 

31 >>> isinstance(UnknownTimeZoneError(), Error) 

32 True 

33 

34 ''' 

35 pass 

36 

37 

38class InvalidTimeError(Error): 

39 '''Base class for invalid time exceptions.''' 

40 

41 

42class AmbiguousTimeError(InvalidTimeError): 

43 '''Exception raised when attempting to create an ambiguous wallclock time. 

44 

45 At the end of a DST transition period, a particular wallclock time will 

46 occur twice (once before the clocks are set back, once after). Both 

47 possibilities may be correct, unless further information is supplied. 

48 

49 See DstTzInfo.normalize() for more info 

50 ''' 

51 

52 

53class NonExistentTimeError(InvalidTimeError): 

54 '''Exception raised when attempting to create a wallclock time that 

55 cannot exist. 

56 

57 At the start of a DST transition period, the wallclock time jumps forward. 

58 The instants jumped over never occur. 

59 '''