jpayne@69
|
1 '''
|
jpayne@69
|
2 Custom exceptions raised by pytz.
|
jpayne@69
|
3 '''
|
jpayne@69
|
4
|
jpayne@69
|
5 __all__ = [
|
jpayne@69
|
6 'UnknownTimeZoneError', 'InvalidTimeError', 'AmbiguousTimeError',
|
jpayne@69
|
7 'NonExistentTimeError',
|
jpayne@69
|
8 ]
|
jpayne@69
|
9
|
jpayne@69
|
10
|
jpayne@69
|
11 class Error(Exception):
|
jpayne@69
|
12 '''Base class for all exceptions raised by the pytz library'''
|
jpayne@69
|
13
|
jpayne@69
|
14
|
jpayne@69
|
15 class UnknownTimeZoneError(KeyError, Error):
|
jpayne@69
|
16 '''Exception raised when pytz is passed an unknown timezone.
|
jpayne@69
|
17
|
jpayne@69
|
18 >>> isinstance(UnknownTimeZoneError(), LookupError)
|
jpayne@69
|
19 True
|
jpayne@69
|
20
|
jpayne@69
|
21 This class is actually a subclass of KeyError to provide backwards
|
jpayne@69
|
22 compatibility with code relying on the undocumented behavior of earlier
|
jpayne@69
|
23 pytz releases.
|
jpayne@69
|
24
|
jpayne@69
|
25 >>> isinstance(UnknownTimeZoneError(), KeyError)
|
jpayne@69
|
26 True
|
jpayne@69
|
27
|
jpayne@69
|
28 And also a subclass of pytz.exceptions.Error, as are other pytz
|
jpayne@69
|
29 exceptions.
|
jpayne@69
|
30
|
jpayne@69
|
31 >>> isinstance(UnknownTimeZoneError(), Error)
|
jpayne@69
|
32 True
|
jpayne@69
|
33
|
jpayne@69
|
34 '''
|
jpayne@69
|
35 pass
|
jpayne@69
|
36
|
jpayne@69
|
37
|
jpayne@69
|
38 class InvalidTimeError(Error):
|
jpayne@69
|
39 '''Base class for invalid time exceptions.'''
|
jpayne@69
|
40
|
jpayne@69
|
41
|
jpayne@69
|
42 class AmbiguousTimeError(InvalidTimeError):
|
jpayne@69
|
43 '''Exception raised when attempting to create an ambiguous wallclock time.
|
jpayne@69
|
44
|
jpayne@69
|
45 At the end of a DST transition period, a particular wallclock time will
|
jpayne@69
|
46 occur twice (once before the clocks are set back, once after). Both
|
jpayne@69
|
47 possibilities may be correct, unless further information is supplied.
|
jpayne@69
|
48
|
jpayne@69
|
49 See DstTzInfo.normalize() for more info
|
jpayne@69
|
50 '''
|
jpayne@69
|
51
|
jpayne@69
|
52
|
jpayne@69
|
53 class NonExistentTimeError(InvalidTimeError):
|
jpayne@69
|
54 '''Exception raised when attempting to create a wallclock time that
|
jpayne@69
|
55 cannot exist.
|
jpayne@69
|
56
|
jpayne@69
|
57 At the start of a DST transition period, the wallclock time jumps forward.
|
jpayne@69
|
58 The instants jumped over never occur.
|
jpayne@69
|
59 '''
|