annotate Lib/exceptions.py @ 8831:00a6bb65ff29 legacy-trunk

Getting rid of this ancient stuff.
author Guido van Rossum <guido@python.org>
date Wed, 05 Aug 1998 21:10:09 +0000
parents edbf631fb7e9
children 0a6892b1a4ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
1 """Class based built-in exception hierarchy.
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
2
6272
775899583da6 #Adapt the doc string to reality.
Guido van Rossum <guido@python.org>
parents: 6245
diff changeset
3 This is a new feature whereby all the standard built-in exceptions,
775899583da6 #Adapt the doc string to reality.
Guido van Rossum <guido@python.org>
parents: 6245
diff changeset
4 traditionally string objects, are replaced with classes. This gives
775899583da6 #Adapt the doc string to reality.
Guido van Rossum <guido@python.org>
parents: 6245
diff changeset
5 Python's exception handling mechanism a more object-oriented feel.
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
6
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
7 Most existing code should continue to work with class based
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
8 exceptions. Some tricky uses of IOError may break, but the most
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
9 common uses should work.
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
10
6272
775899583da6 #Adapt the doc string to reality.
Guido van Rossum <guido@python.org>
parents: 6245
diff changeset
11 To disable this feature, start the Python executable with the -X option.
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
12
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
13 Here is a rundown of the class hierarchy. You can change this by
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
14 editing this file, but it isn't recommended. The classes with a `*'
6272
775899583da6 #Adapt the doc string to reality.
Guido van Rossum <guido@python.org>
parents: 6245
diff changeset
15 are new with this feature. They are defined as tuples containing the
775899583da6 #Adapt the doc string to reality.
Guido van Rossum <guido@python.org>
parents: 6245
diff changeset
16 derived exceptions when string-based exceptions are used.
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
17
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
18 Exception(*)
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
19 |
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
20 +-- StandardError(*)
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
21 |
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
22 +-- SystemExit
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
23 +-- KeyboardInterrupt
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
24 +-- ImportError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
25 +-- IOError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
26 +-- EOFError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
27 +-- RuntimeError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
28 +-- NameError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
29 +-- AttributeError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
30 +-- SyntaxError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
31 +-- TypeError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
32 +-- AssertionError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
33 +-- LookupError(*)
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
34 | |
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
35 | +-- IndexError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
36 | +-- KeyError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
37 |
6325
5cdc3ca053d6 NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents: 6317
diff changeset
38 +-- ArithmeticError(*)
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
39 | |
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
40 | +-- OverflowError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
41 | +-- ZeroDivisionError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
42 | +-- FloatingPointError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
43 |
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
44 +-- ValueError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
45 +-- SystemError
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
46 +-- MemoryError
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
47 """
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
48
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
49 class Exception:
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
50 def __init__(self, *args):
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
51 self.args = args
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
52
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
53 def __str__(self):
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
54 if not self.args:
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
55 return ''
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
56 elif len(self.args) == 1:
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
57 return str(self.args[0])
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
58 else:
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
59 return str(self.args)
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
60
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
61 def __getitem__(self, i):
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
62 return self.args[i]
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
63
6394
784a16f56643 Move the __getitem__() definition from StandardException to Exception.
Fred Drake <fdrake@acm.org>
parents: 6325
diff changeset
64 class StandardError(Exception):
784a16f56643 Move the __getitem__() definition from StandardException to Exception.
Fred Drake <fdrake@acm.org>
parents: 6325
diff changeset
65 pass
784a16f56643 Move the __getitem__() definition from StandardException to Exception.
Fred Drake <fdrake@acm.org>
parents: 6325
diff changeset
66
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
67 class SyntaxError(StandardError):
6245
15bcec3d3259 Made the 'info' argument to SyntaxError optional, so phase-2 syntax
Guido van Rossum <guido@python.org>
parents: 6195
diff changeset
68 filename = lineno = offset = text = None
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
69 msg = ""
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
70 def __init__(self, *args):
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
71 self.args = args
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
72 if len(self.args) >= 1:
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
73 self.msg = self.args[0]
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
74 if len(self.args) == 2:
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
75 info = self.args[1]
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
76 try:
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
77 self.filename, self.lineno, self.offset, self.text = info
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
78 except:
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
79 pass
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
80 def __str__(self):
6245
15bcec3d3259 Made the 'info' argument to SyntaxError optional, so phase-2 syntax
Guido van Rossum <guido@python.org>
parents: 6195
diff changeset
81 return str(self.msg)
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
82
8705
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
83 class EnvironmentError(StandardError):
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
84 """Base class for exceptions that occur outside the Python system.
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
85 Primarily used as a base class for OSError and IOError."""
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
86 def __init__(self, *args):
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
87 self.args = args
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
88 self.errno = None
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
89 self.strerror = None
8705
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
90 self.filename = None
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
91 if len(args) == 3:
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
92 # open() errors give third argument which is the filename. BUT,
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
93 # so common in-place unpacking doesn't break, e.g.:
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
94 #
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
95 # except IOError, (errno, strerror):
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
96 #
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
97 # we hack args so that it only contains two items. This also
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
98 # means we need our own __str__() which prints out the filename
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
99 # when it was supplied.
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
100 self.errno, self.strerror, self.filename = args
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
101 self.args = args[0:2]
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
102 if len(args) == 2:
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
103 # common case: PyErr_SetFromErrno()
8705
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
104 self.errno, self.strerror = args
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
105
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
106 def __str__(self):
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
107 if self.filename:
8774
edbf631fb7e9 fix __str__ method of EnvironmentError (base class of IOError): was
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8705
diff changeset
108 return '[Errno %s] %s: %s' % (self.errno, self.strerror,
8705
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
109 self.filename)
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
110 elif self.errno and self.strerror:
8774
edbf631fb7e9 fix __str__ method of EnvironmentError (base class of IOError): was
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8705
diff changeset
111 return '[Errno %s] %s' % (self.errno, self.strerror)
8705
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
112 else:
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
113 return StandardError.__str__(self)
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
114
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
115 class IOError(EnvironmentError):
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
116 pass
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
117
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
118 class OSError(EnvironmentError):
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
119 """Used by the posix module."""
8571c1246f09 Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents: 7755
diff changeset
120 pass
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
121
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
122 class RuntimeError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
123 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
124
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
125 class SystemError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
126 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
127
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
128 class EOFError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
129 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
130
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
131 class ImportError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
132 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
133
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
134 class TypeError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
135 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
136
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
137 class ValueError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
138 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
139
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
140 class KeyboardInterrupt(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
141 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
142
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
143 class AssertionError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
144 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
145
6325
5cdc3ca053d6 NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents: 6317
diff changeset
146 class ArithmeticError(StandardError):
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
147 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
148
6325
5cdc3ca053d6 NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents: 6317
diff changeset
149 class OverflowError(ArithmeticError):
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
150 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
151
6325
5cdc3ca053d6 NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents: 6317
diff changeset
152 class FloatingPointError(ArithmeticError):
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
153 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
154
6325
5cdc3ca053d6 NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents: 6317
diff changeset
155 class ZeroDivisionError(ArithmeticError):
6195
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
156 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
157
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
158 class LookupError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
159 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
160
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
161 class IndexError(LookupError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
162 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
163
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
164 class KeyError(LookupError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
165 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
166
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
167 class AttributeError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
168 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
169
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
170 class NameError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
171 pass
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
172
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
173 class MemoryError(StandardError):
d97980e7c05f New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff changeset
174 pass
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
175
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
176 class SystemExit(Exception):
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
177 def __init__(self, *args):
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6394
diff changeset
178 self.args = args
6317
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
179 if len(args) == 0:
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
180 self.code = None
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
181 elif len(args) == 1:
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
182 self.code = args[0]
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
183 else:
71b40cc4cc03 Two subtle changes:
Guido van Rossum <guido@python.org>
parents: 6272
diff changeset
184 self.code = args