Mercurial > cpython-lru_cache-weakref
annotate Lib/exceptions.py @ 12357:5b59ea41db4e legacy-trunk
Install the docs (with fewer rules).
Add descriptions for the system variables.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 10 Apr 2000 19:36:27 +0000 |
| parents | 3303a5bac6dd |
| children | f0d2253b664f |
| 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 |
|
9145
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
3 New with Python 1.5, all standard built-in exceptions are now class objects by |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
4 default. This gives Python's exception handling mechanism a more |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
5 object-oriented feel. Traditionally they were string objects. Python will |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
6 fallback to string based exceptions if the interpreter is invoked with the -X |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
7 option, or if some failure occurs during class exception initialization (in |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
8 this case a warning will be printed). |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
9 |
|
9145
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
10 Most existing code should continue to work with class based exceptions. Some |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
11 tricky uses of IOError may break, but the most common uses should work. |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
12 |
|
9145
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
13 Here is a rundown of the class hierarchy. You can change this by editing this |
|
10291
9be2726c9b25
Document the correct class hierarchy for SystemExit. It is not an
Barry Warsaw <barry@python.org>
parents:
9899
diff
changeset
|
14 file, but it isn't recommended because the old string based exceptions won't |
|
9be2726c9b25
Document the correct class hierarchy for SystemExit. It is not an
Barry Warsaw <barry@python.org>
parents:
9899
diff
changeset
|
15 be kept in sync. The class names described here are expected to be found by |
|
9be2726c9b25
Document the correct class hierarchy for SystemExit. It is not an
Barry Warsaw <barry@python.org>
parents:
9899
diff
changeset
|
16 the bltinmodule.c file. If you add classes here, you must modify |
|
9be2726c9b25
Document the correct class hierarchy for SystemExit. It is not an
Barry Warsaw <barry@python.org>
parents:
9899
diff
changeset
|
17 bltinmodule.c or the exceptions won't be available in the __builtin__ module, |
|
9be2726c9b25
Document the correct class hierarchy for SystemExit. It is not an
Barry Warsaw <barry@python.org>
parents:
9899
diff
changeset
|
18 nor will they be accessible from C. |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
19 |
|
9565
a091185ccfb6
Added NotImplementedError, subclassed from RuntimeError
Barry Warsaw <barry@python.org>
parents:
9145
diff
changeset
|
20 The classes with a `*' are new since Python 1.5. They are defined as tuples |
|
9145
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
21 containing the derived exceptions when string-based exceptions are used. If |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
22 you define your own class based exceptions, they should be derived from |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
23 Exception. |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
24 |
| 6317 | 25 Exception(*) |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
26 | |
|
10291
9be2726c9b25
Document the correct class hierarchy for SystemExit. It is not an
Barry Warsaw <barry@python.org>
parents:
9899
diff
changeset
|
27 +-- SystemExit |
| 6317 | 28 +-- StandardError(*) |
| 29 | | |
| 30 +-- KeyboardInterrupt | |
| 31 +-- ImportError | |
|
9145
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
32 +-- EnvironmentError(*) |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
33 | | |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
34 | +-- IOError |
|
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
35 | +-- OSError(*) |
|
11798
50a6ab3fa036
Added WindowsError, for Mark Hammond's extensions.
Guido van Rossum <guido@python.org>
parents:
11213
diff
changeset
|
36 | | |
|
50a6ab3fa036
Added WindowsError, for Mark Hammond's extensions.
Guido van Rossum <guido@python.org>
parents:
11213
diff
changeset
|
37 | +-- WindowsError(*) |
|
9145
e578439b981f
Updated the docstring and class hierarchy diagram
Barry Warsaw <barry@python.org>
parents:
8949
diff
changeset
|
38 | |
| 6317 | 39 +-- EOFError |
| 40 +-- RuntimeError | |
|
9565
a091185ccfb6
Added NotImplementedError, subclassed from RuntimeError
Barry Warsaw <barry@python.org>
parents:
9145
diff
changeset
|
41 | | |
|
a091185ccfb6
Added NotImplementedError, subclassed from RuntimeError
Barry Warsaw <barry@python.org>
parents:
9145
diff
changeset
|
42 | +-- NotImplementedError(*) |
|
a091185ccfb6
Added NotImplementedError, subclassed from RuntimeError
Barry Warsaw <barry@python.org>
parents:
9145
diff
changeset
|
43 | |
| 6317 | 44 +-- NameError |
| 11030 | 45 | | |
| 46 | +-- UnboundLocalError(*) | |
|
11213
eaf9eeab3bcf
A nit to make Fred proud.
Barry Warsaw <barry@python.org>
parents:
11030
diff
changeset
|
47 | |
| 6317 | 48 +-- AttributeError |
| 49 +-- SyntaxError | |
| 50 +-- TypeError | |
| 51 +-- AssertionError | |
| 52 +-- LookupError(*) | |
| 53 | | | |
| 54 | +-- IndexError | |
| 55 | +-- KeyError | |
| 56 | | |
|
6325
5cdc3ca053d6
NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents:
6317
diff
changeset
|
57 +-- ArithmeticError(*) |
| 6317 | 58 | | |
| 59 | +-- OverflowError | |
| 60 | +-- ZeroDivisionError | |
| 61 | +-- FloatingPointError | |
| 62 | | |
| 63 +-- ValueError | |
|
11986
3303a5bac6dd
Marc-Andre Lemburg: Add UnicodeError, derived from ValueError.
Guido van Rossum <guido@python.org>
parents:
11798
diff
changeset
|
64 | | |
|
3303a5bac6dd
Marc-Andre Lemburg: Add UnicodeError, derived from ValueError.
Guido van Rossum <guido@python.org>
parents:
11798
diff
changeset
|
65 | +-- UnicodeError(*) |
|
3303a5bac6dd
Marc-Andre Lemburg: Add UnicodeError, derived from ValueError.
Guido van Rossum <guido@python.org>
parents:
11798
diff
changeset
|
66 | |
| 6317 | 67 +-- SystemError |
| 68 +-- MemoryError | |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
69 """ |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
70 |
| 6317 | 71 class Exception: |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
72 """Proposed base class for all exceptions.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
73 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
|
74 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
|
75 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
76 def __str__(self): |
| 6317 | 77 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
|
78 return '' |
|
7755
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6394
diff
changeset
|
79 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
|
80 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
|
81 else: |
|
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6394
diff
changeset
|
82 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
|
83 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
84 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
|
85 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
|
86 |
|
6394
784a16f56643
Move the __getitem__() definition from StandardException to Exception.
Fred Drake <fdrake@acm.org>
parents:
6325
diff
changeset
|
87 class StandardError(Exception): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
88 """Base class for all standard Python exceptions.""" |
|
6394
784a16f56643
Move the __getitem__() definition from StandardException to Exception.
Fred Drake <fdrake@acm.org>
parents:
6325
diff
changeset
|
89 pass |
|
784a16f56643
Move the __getitem__() definition from StandardException to Exception.
Fred Drake <fdrake@acm.org>
parents:
6325
diff
changeset
|
90 |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
91 class SyntaxError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
92 """Invalid syntax.""" |
|
6245
15bcec3d3259
Made the 'info' argument to SyntaxError optional, so phase-2 syntax
Guido van Rossum <guido@python.org>
parents:
6195
diff
changeset
|
93 filename = lineno = offset = text = None |
| 6317 | 94 msg = "" |
| 95 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
|
96 self.args = args |
|
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6394
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 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
|
101 try: |
|
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6394
diff
changeset
|
102 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
|
103 except: |
|
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6394
diff
changeset
|
104 pass |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
105 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
|
106 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
|
107 |
|
8705
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
108 class EnvironmentError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
109 """Base class for I/O related errors.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 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
|
114 self.filename = None |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
115 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
|
116 # 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
|
117 # 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
|
118 # |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
119 # 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
|
120 # |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
121 # 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
|
122 # 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
|
123 # 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
|
124 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
|
125 self.args = args[0:2] |
| 6317 | 126 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
|
127 # 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
|
128 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
|
129 |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
130 def __str__(self): |
|
8949
0a6892b1a4ac
Use repr() on the filename in EnvironmentError.__str__(). This
Guido van Rossum <guido@python.org>
parents:
8774
diff
changeset
|
131 if self.filename is not None: |
|
8774
edbf631fb7e9
fix __str__ method of EnvironmentError (base class of IOError): was
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
8705
diff
changeset
|
132 return '[Errno %s] %s: %s' % (self.errno, self.strerror, |
|
8949
0a6892b1a4ac
Use repr() on the filename in EnvironmentError.__str__(). This
Guido van Rossum <guido@python.org>
parents:
8774
diff
changeset
|
133 repr(self.filename)) |
|
8705
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
134 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
|
135 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
|
136 else: |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
137 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
|
138 |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
139 class IOError(EnvironmentError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
140 """I/O operation failed.""" |
|
8705
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
141 pass |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
142 |
|
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
143 class OSError(EnvironmentError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
144 """OS system call failed.""" |
|
8705
8571c1246f09
Added support for including the filename in IOErrors and OSErrors that
Barry Warsaw <barry@python.org>
parents:
7755
diff
changeset
|
145 pass |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
146 |
|
11798
50a6ab3fa036
Added WindowsError, for Mark Hammond's extensions.
Guido van Rossum <guido@python.org>
parents:
11213
diff
changeset
|
147 class WindowsError(OSError): |
|
50a6ab3fa036
Added WindowsError, for Mark Hammond's extensions.
Guido van Rossum <guido@python.org>
parents:
11213
diff
changeset
|
148 """MS-Windows OS system call failed.""" |
|
50a6ab3fa036
Added WindowsError, for Mark Hammond's extensions.
Guido van Rossum <guido@python.org>
parents:
11213
diff
changeset
|
149 pass |
|
50a6ab3fa036
Added WindowsError, for Mark Hammond's extensions.
Guido van Rossum <guido@python.org>
parents:
11213
diff
changeset
|
150 |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
151 class RuntimeError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
152 """Unspecified run-time error.""" |
|
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 |
|
9565
a091185ccfb6
Added NotImplementedError, subclassed from RuntimeError
Barry Warsaw <barry@python.org>
parents:
9145
diff
changeset
|
155 class NotImplementedError(RuntimeError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
156 """Method or function hasn't been implemented yet.""" |
|
9565
a091185ccfb6
Added NotImplementedError, subclassed from RuntimeError
Barry Warsaw <barry@python.org>
parents:
9145
diff
changeset
|
157 pass |
|
a091185ccfb6
Added NotImplementedError, subclassed from RuntimeError
Barry Warsaw <barry@python.org>
parents:
9145
diff
changeset
|
158 |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
159 class SystemError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
160 """Internal error in the Python interpreter. |
|
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
161 |
|
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
162 Please report this to the Python maintainer, along with the traceback, |
|
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
163 the Python version, and the hardware/OS platform and version.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
164 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
165 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
166 class EOFError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
167 """Read beyond end of file.""" |
|
6195
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 ImportError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
171 """Import can't find module, or can't find name in module.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
172 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
173 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
174 class TypeError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
175 """Inappropriate argument type.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
176 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
177 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
178 class ValueError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
179 """Inappropriate argument value (of correct type).""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
180 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
181 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
182 class KeyboardInterrupt(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
183 """Program interrupted by user.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
184 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
185 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
186 class AssertionError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
187 """Assertion failed.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
188 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
189 |
|
6325
5cdc3ca053d6
NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents:
6317
diff
changeset
|
190 class ArithmeticError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
191 """Base class for arithmetic errors.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
192 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
193 |
|
6325
5cdc3ca053d6
NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents:
6317
diff
changeset
|
194 class OverflowError(ArithmeticError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
195 """Result too large to be represented.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
196 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
197 |
|
6325
5cdc3ca053d6
NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents:
6317
diff
changeset
|
198 class FloatingPointError(ArithmeticError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
199 """Floating point operation failed.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
200 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
201 |
|
6325
5cdc3ca053d6
NumberError => ArithmeticError
Barry Warsaw <barry@python.org>
parents:
6317
diff
changeset
|
202 class ZeroDivisionError(ArithmeticError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
203 """Second argument to a division or modulo operation was zero.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
204 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
205 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
206 class LookupError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
207 """Base class for lookup errors.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
208 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
209 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
210 class IndexError(LookupError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
211 """Sequence index out of range.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
212 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
213 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
214 class KeyError(LookupError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
215 """Mapping key not found.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
216 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
217 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
218 class AttributeError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
219 """Attribute not found.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
220 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
221 |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
222 class NameError(StandardError): |
| 11030 | 223 """Name not found globally.""" |
| 224 pass | |
| 225 | |
| 226 class UnboundLocalError(NameError): | |
| 227 """Local name referenced but not bound to a value.""" | |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
228 pass |
|
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
229 |
|
11986
3303a5bac6dd
Marc-Andre Lemburg: Add UnicodeError, derived from ValueError.
Guido van Rossum <guido@python.org>
parents:
11798
diff
changeset
|
230 class UnicodeError(ValueError): |
|
3303a5bac6dd
Marc-Andre Lemburg: Add UnicodeError, derived from ValueError.
Guido van Rossum <guido@python.org>
parents:
11798
diff
changeset
|
231 """Unicode related error.""" |
|
3303a5bac6dd
Marc-Andre Lemburg: Add UnicodeError, derived from ValueError.
Guido van Rossum <guido@python.org>
parents:
11798
diff
changeset
|
232 pass |
|
3303a5bac6dd
Marc-Andre Lemburg: Add UnicodeError, derived from ValueError.
Guido van Rossum <guido@python.org>
parents:
11798
diff
changeset
|
233 |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
234 class MemoryError(StandardError): |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
235 """Out of memory.""" |
|
6195
d97980e7c05f
New file, which is imported by the built-in module when python is
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
236 pass |
| 6317 | 237 |
| 238 class SystemExit(Exception): | |
|
9899
5ad1a35f540c
Added doc strings to the exception classes.
Guido van Rossum <guido@python.org>
parents:
9565
diff
changeset
|
239 """Request to exit from the interpreter.""" |
| 6317 | 240 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
|
241 self.args = args |
| 6317 | 242 if len(args) == 0: |
| 243 self.code = None | |
| 244 elif len(args) == 1: | |
| 245 self.code = args[0] | |
| 246 else: | |
| 247 self.code = args |
