blob: 54b141a9a1490ff62ebb26d4878a7c59ab22e757 [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Built-in Exceptions}
Fred Drake3bd9ab01998-07-23 19:33:08 +00002
Fred Drakeffbe6871999-04-22 21:23:22 +00003\declaremodule{standard}{exceptions}
Fred Drake3bd9ab01998-07-23 19:33:08 +00004\modulesynopsis{Standard exceptions classes.}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00005
Fred Drakeb91e9341998-07-23 17:59:49 +00006
Fred Drake7acb2182000-09-09 03:28:00 +00007Exceptions can be class objects or string objects. Though most
8exceptions have been string objects in past versions of Python, in
9Python 1.5 and newer versions, all standard exceptions have been
10converted to class objects, and users are encouraged to do the same.
11The exceptions are defined in the module \module{exceptions}. This
12module never needs to be imported explicitly: the exceptions are
Fred Drakec6920552001-09-21 21:12:30 +000013provided in the built-in namespace as well as the \module{exceptions}
14module.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000015
Guido van Rossumdf3dba01997-10-05 18:51:26 +000016Two distinct string objects with the same value are considered different
17exceptions. This is done to force programmers to use exception names
18rather than their string value when specifying exception handlers.
19The string value of all built-in exceptions is their name, but this is
20not a requirement for user-defined exceptions or exceptions defined by
21library modules.
22
Fred Drake38e5d272000-04-03 20:13:55 +000023For class exceptions, in a \keyword{try}\stindex{try} statement with
24an \keyword{except}\stindex{except} clause that mentions a particular
25class, that clause also handles any exception classes derived from
26that class (but not exception classes from which \emph{it} is
27derived). Two exception classes that are not related via subclassing
28are never equivalent, even if they have the same name.
Guido van Rossumdf3dba01997-10-05 18:51:26 +000029
30The built-in exceptions listed below can be generated by the
31interpreter or built-in functions. Except where mentioned, they have
32an ``associated value'' indicating the detailed cause of the error.
33This may be a string or a tuple containing several items of
34information (e.g., an error code and a string explaining the code).
Fred Drake38e5d272000-04-03 20:13:55 +000035The associated value is the second argument to the
36\keyword{raise}\stindex{raise} statement. For string exceptions, the
37associated value itself will be stored in the variable named as the
38second argument of the \keyword{except} clause (if any). For class
39exceptions, that variable receives the exception instance. If the
40exception class is derived from the standard root class
41\exception{Exception}, the associated value is present as the
42exception instance's \member{args} attribute, and possibly on other
43attributes as well.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000044
45User code can raise built-in exceptions. This can be used to test an
Guido van Rossumdf3dba01997-10-05 18:51:26 +000046exception handler or to report an error condition ``just like'' the
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000047situation in which the interpreter raises the same exception; but
48beware that there is nothing to prevent user code from raising an
49inappropriate error.
50
Fred Drakec6920552001-09-21 21:12:30 +000051The built-in exception classes can be sub-classed to define new
52exceptions; programmers are encouraged to at least derive new
53exceptions from the \exception{Exception} base class. More
54information on defining exceptions is available in the
55\citetitle[../tut/tut.html]{Python Tutorial} under the heading
56``User-defined Exceptions.''
57
Fred Drake19479911998-02-13 06:58:54 +000058\setindexsubitem{(built-in exception base class)}
Guido van Rossumdf3dba01997-10-05 18:51:26 +000059
60The following exceptions are only used as base classes for other
Fred Drake5828ad62000-04-06 15:03:01 +000061exceptions.
Guido van Rossumdf3dba01997-10-05 18:51:26 +000062
63\begin{excdesc}{Exception}
64The root class for exceptions. All built-in exceptions are derived
65from this class. All user-defined exceptions should also be derived
Fred Drake27467e41998-07-23 19:47:41 +000066from this class, but this is not (yet) enforced. The \function{str()}
Guido van Rossumdf3dba01997-10-05 18:51:26 +000067function, when applied to an instance of this class (or most derived
68classes) returns the string value of the argument or arguments, or an
Guido van Rossum6cd7ecb1997-10-07 14:41:04 +000069empty string if no arguments were given to the constructor. When used
70as a sequence, this accesses the arguments given to the constructor
Barry Warsawda00c871998-07-23 19:57:35 +000071(handy for backward compatibility with old code). The arguments are
Fred Drakec457ca71998-07-23 20:31:53 +000072also available on the instance's \member{args} attribute, as a tuple.
Guido van Rossumdf3dba01997-10-05 18:51:26 +000073\end{excdesc}
74
75\begin{excdesc}{StandardError}
Barry Warsawf2b45541999-02-24 00:27:14 +000076The base class for all built-in exceptions except
Fred Drakec046e972001-07-23 19:19:39 +000077\exception{StopIteration} and \exception{SystemExit}.
78\exception{StandardError} itself is derived from the root class
Fred Drake27467e41998-07-23 19:47:41 +000079\exception{Exception}.
Guido van Rossumdf3dba01997-10-05 18:51:26 +000080\end{excdesc}
81
82\begin{excdesc}{ArithmeticError}
83The base class for those built-in exceptions that are raised for
Fred Drake27467e41998-07-23 19:47:41 +000084various arithmetic errors: \exception{OverflowError},
85\exception{ZeroDivisionError}, \exception{FloatingPointError}.
Guido van Rossumdf3dba01997-10-05 18:51:26 +000086\end{excdesc}
87
88\begin{excdesc}{LookupError}
Barry Warsawda00c871998-07-23 19:57:35 +000089The base class for the exceptions that are raised when a key or
Fred Drake27467e41998-07-23 19:47:41 +000090index used on a mapping or sequence is invalid: \exception{IndexError},
Fred Drake53143be2000-10-25 21:05:29 +000091\exception{KeyError}. This can be raised directly by
92\function{sys.setdefaultencoding()}.
Guido van Rossumdf3dba01997-10-05 18:51:26 +000093\end{excdesc}
94
Barry Warsawda00c871998-07-23 19:57:35 +000095\begin{excdesc}{EnvironmentError}
96The base class for exceptions that
97can occur outside the Python system: \exception{IOError},
98\exception{OSError}. When exceptions of this type are created with a
992-tuple, the first item is available on the instance's \member{errno}
100attribute (it is assumed to be an error number), and the second item
101is available on the \member{strerror} attribute (it is usually the
102associated error message). The tuple itself is also available on the
103\member{args} attribute.
Fred Draked0bceee1999-02-02 18:00:40 +0000104\versionadded{1.5.2}
Barry Warsawda00c871998-07-23 19:57:35 +0000105
106When an \exception{EnvironmentError} exception is instantiated with a
1073-tuple, the first two items are available as above, while the third
108item is available on the \member{filename} attribute. However, for
109backwards compatibility, the \member{args} attribute contains only a
1102-tuple of the first two constructor arguments.
111
112The \member{filename} attribute is \code{None} when this exception is
113created with other than 3 arguments. The \member{errno} and
114\member{strerror} attributes are also \code{None} when the instance was
115created with other than 2 or 3 arguments. In this last case,
116\member{args} contains the verbatim constructor arguments as a tuple.
117\end{excdesc}
118
Fred Drake88c023b2000-09-07 16:33:32 +0000119
Fred Drake19479911998-02-13 06:58:54 +0000120\setindexsubitem{(built-in exception)}
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000121
122The following exceptions are the exceptions that are actually raised.
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000123
124\begin{excdesc}{AssertionError}
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000125\stindex{assert}
Fred Drake38e5d272000-04-03 20:13:55 +0000126Raised when an \keyword{assert} statement fails.
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000127\end{excdesc}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000128
129\begin{excdesc}{AttributeError}
130% xref to attribute reference?
131 Raised when an attribute reference or assignment fails. (When an
Guido van Rossum470be141995-03-17 16:07:09 +0000132 object does not support attribute references or attribute assignments
Fred Drake27467e41998-07-23 19:47:41 +0000133 at all, \exception{TypeError} is raised.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000134\end{excdesc}
135
136\begin{excdesc}{EOFError}
137% XXXJH xrefs here
Fred Drake27467e41998-07-23 19:47:41 +0000138 Raised when one of the built-in functions (\function{input()} or
Fred Drakec37b65e2001-11-28 07:26:15 +0000139 \function{raw_input()}) hits an end-of-file condition (\EOF) without
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000140 reading any data.
141% XXXJH xrefs here
Fred Drake27467e41998-07-23 19:47:41 +0000142 (N.B.: the \method{read()} and \method{readline()} methods of file
Fred Drakec37b65e2001-11-28 07:26:15 +0000143 objects return an empty string when they hit \EOF.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000144\end{excdesc}
145
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000146\begin{excdesc}{FloatingPointError}
Fred Drakeb44e7531998-07-27 21:11:42 +0000147 Raised when a floating point operation fails. This exception is
148 always defined, but can only be raised when Python is configured
Fred Drakeee775a12000-04-11 19:46:40 +0000149 with the \longprogramopt{with-fpectl} option, or the
Fred Drakeb44e7531998-07-27 21:11:42 +0000150 \constant{WANT_SIGFPE_HANDLER} symbol is defined in the
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +0000151 \file{pyconfig.h} file.
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000152\end{excdesc}
153
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000154\begin{excdesc}{IOError}
155% XXXJH xrefs here
Fred Drakeb44e7531998-07-27 21:11:42 +0000156 Raised when an I/O operation (such as a \keyword{print} statement,
157 the built-in \function{open()} function or a method of a file
158 object) fails for an I/O-related reason, e.g., ``file not found'' or
159 ``disk full''.
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000160
Fred Drake02e18b41999-01-05 21:42:18 +0000161 This class is derived from \exception{EnvironmentError}. See the
Fred Drakeb44e7531998-07-27 21:11:42 +0000162 discussion above for more information on exception instance
163 attributes.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000164\end{excdesc}
165
166\begin{excdesc}{ImportError}
167% XXXJH xref to import statement?
Fred Drake27467e41998-07-23 19:47:41 +0000168 Raised when an \keyword{import} statement fails to find the module
Fred Drakef65e3231998-11-25 20:55:03 +0000169 definition or when a \code{from \textrm{\ldots} import} fails to find a
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000170 name that is to be imported.
171\end{excdesc}
172
173\begin{excdesc}{IndexError}
174% XXXJH xref to sequences
175 Raised when a sequence subscript is out of range. (Slice indices are
176 silently truncated to fall in the allowed range; if an index is not a
Fred Drake27467e41998-07-23 19:47:41 +0000177 plain integer, \exception{TypeError} is raised.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000178\end{excdesc}
179
180\begin{excdesc}{KeyError}
181% XXXJH xref to mapping objects?
182 Raised when a mapping (dictionary) key is not found in the set of
183 existing keys.
184\end{excdesc}
185
186\begin{excdesc}{KeyboardInterrupt}
187 Raised when the user hits the interrupt key (normally
Fred Drake682d5f32001-07-12 02:09:51 +0000188 \kbd{Control-C} or \kbd{Delete}). During execution, a check for
Fred Drake2a1cc3e1998-04-28 13:38:54 +0000189 interrupts is made regularly.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000190% XXXJH xrefs here
Fred Drake2a1cc3e1998-04-28 13:38:54 +0000191 Interrupts typed when a built-in function \function{input()} or
192 \function{raw_input()}) is waiting for input also raise this
Barry Warsawda00c871998-07-23 19:57:35 +0000193 exception.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000194\end{excdesc}
195
196\begin{excdesc}{MemoryError}
197 Raised when an operation runs out of memory but the situation may
198 still be rescued (by deleting some objects). The associated value is
199 a string indicating what kind of (internal) operation ran out of memory.
200 Note that because of the underlying memory management architecture
Fred Drake5828ad62000-04-06 15:03:01 +0000201 (C's \cfunction{malloc()} function), the interpreter may not
Fred Drake27467e41998-07-23 19:47:41 +0000202 always be able to completely recover from this situation; it
203 nevertheless raises an exception so that a stack traceback can be
204 printed, in case a run-away program was the cause.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000205\end{excdesc}
206
207\begin{excdesc}{NameError}
208 Raised when a local or global name is not found. This applies only
Raymond Hettinger9240be22002-08-27 23:53:23 +0000209 to unqualified names. The associated value is an error message that
210 includes the name that could not be found.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000211\end{excdesc}
212
Barry Warsaw6d26f4b1998-12-01 19:48:04 +0000213\begin{excdesc}{NotImplementedError}
Barry Warsaw6d26f4b1998-12-01 19:48:04 +0000214 This exception is derived from \exception{RuntimeError}. In user
215 defined base classes, abstract methods should raise this exception
216 when they require derived classes to override the method.
Fred Draked0bceee1999-02-02 18:00:40 +0000217 \versionadded{1.5.2}
Barry Warsaw6d26f4b1998-12-01 19:48:04 +0000218\end{excdesc}
219
Barry Warsawda00c871998-07-23 19:57:35 +0000220\begin{excdesc}{OSError}
221 %xref for os module
Fred Drakec457ca71998-07-23 20:31:53 +0000222 This class is derived from \exception{EnvironmentError} and is used
Fred Drakeffbe6871999-04-22 21:23:22 +0000223 primarily as the \refmodule{os} module's \code{os.error} exception.
Fred Drake98be47e1999-02-01 16:17:40 +0000224 See \exception{EnvironmentError} above for a description of the
225 possible associated values.
Fred Draked0bceee1999-02-02 18:00:40 +0000226 \versionadded{1.5.2}
Barry Warsawda00c871998-07-23 19:57:35 +0000227\end{excdesc}
228
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000229\begin{excdesc}{OverflowError}
230% XXXJH reference to long's and/or int's?
231 Raised when the result of an arithmetic operation is too large to be
232 represented. This cannot occur for long integers (which would rather
Fred Drake27467e41998-07-23 19:47:41 +0000233 raise \exception{MemoryError} than give up). Because of the lack of
Fred Drake5828ad62000-04-06 15:03:01 +0000234 standardization of floating point exception handling in C, most
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000235 floating point operations also aren't checked. For plain integers,
236 all operations that can overflow are checked except left shift, where
237 typical applications prefer to drop bits than raise an exception.
238\end{excdesc}
239
Fred Drake8c2c3d32001-10-06 06:10:54 +0000240\begin{excdesc}{ReferenceError}
241 This exception is raised when a weak reference proxy, created by the
242 \function{\refmodule{weakref}.proxy()} function, is used to access
243 an attribute of the referent after it has been garbage collected.
244 For more information on weak references, see the \refmodule{weakref}
245 module.
246 \versionadded[Previously known as the
247 \exception{\refmodule{weakref}.ReferenceError}
248 exception]{2.2}
249\end{excdesc}
250
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000251\begin{excdesc}{RuntimeError}
252 Raised when an error is detected that doesn't fall in any of the
253 other categories. The associated value is a string indicating what
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000254 precisely went wrong. (This exception is mostly a relic from a
255 previous version of the interpreter; it is not used very much any
256 more.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000257\end{excdesc}
258
Fred Drake9cfe1822001-05-03 04:30:45 +0000259\begin{excdesc}{StopIteration}
260 Raised by an iterator's \method{next()} method to signal that there
261 are no further values.
262 This is derived from \exception{Exception} rather than
263 \exception{StandardError}, since this is not considered an error in
264 its normal application.
Fred Drakef42cc452001-05-03 04:39:10 +0000265 \versionadded{2.2}
Fred Drake9cfe1822001-05-03 04:30:45 +0000266\end{excdesc}
267
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000268\begin{excdesc}{SyntaxError}
269% XXXJH xref to these functions?
270 Raised when the parser encounters a syntax error. This may occur in
Fred Drake27467e41998-07-23 19:47:41 +0000271 an \keyword{import} statement, in an \keyword{exec} statement, in a call
272 to the built-in function \function{eval()} or \function{input()}, or
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000273 when reading the initial script or standard input (also
274 interactively).
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000275
Fred Drakec6920552001-09-21 21:12:30 +0000276 Instances of this class have atttributes \member{filename},
277 \member{lineno}, \member{offset} and \member{text} for easier access
278 to the details. \function{str()} of the exception instance returns
279 only the message.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000280\end{excdesc}
281
282\begin{excdesc}{SystemError}
283 Raised when the interpreter finds an internal error, but the
284 situation does not look so serious to cause it to abandon all hope.
285 The associated value is a string indicating what went wrong (in
286 low-level terms).
287
288 You should report this to the author or maintainer of your Python
Fred Drakec6920552001-09-21 21:12:30 +0000289 interpreter. Be sure to report the version of the Python
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000290 interpreter (\code{sys.version}; it is also printed at the start of an
291 interactive Python session), the exact error message (the exception's
292 associated value) and if possible the source of the program that
293 triggered the error.
294\end{excdesc}
295
296\begin{excdesc}{SystemExit}
297% XXXJH xref to module sys?
Fred Drake27467e41998-07-23 19:47:41 +0000298 This exception is raised by the \function{sys.exit()} function. When it
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000299 is not handled, the Python interpreter exits; no stack traceback is
300 printed. If the associated value is a plain integer, it specifies the
Fred Drake5828ad62000-04-06 15:03:01 +0000301 system exit status (passed to C's \cfunction{exit()} function); if it is
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000302 \code{None}, the exit status is zero; if it has another type (such as
303 a string), the object's value is printed and the exit status is one.
Guido van Rossumdf3dba01997-10-05 18:51:26 +0000304
Fred Drake5828ad62000-04-06 15:03:01 +0000305 Instances have an attribute \member{code} which is set to the
306 proposed exit status or error message (defaulting to \code{None}).
307 Also, this exception derives directly from \exception{Exception} and
308 not \exception{StandardError}, since it is not technically an error.
309
Fred Drake27467e41998-07-23 19:47:41 +0000310 A call to \function{sys.exit()} is translated into an exception so that
311 clean-up handlers (\keyword{finally} clauses of \keyword{try} statements)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000312 can be executed, and so that a debugger can execute a script without
Fred Drake27467e41998-07-23 19:47:41 +0000313 running the risk of losing control. The \function{os._exit()} function
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000314 can be used if it is absolutely positively necessary to exit
Fred Drakec046e972001-07-23 19:19:39 +0000315 immediately (for example, in the child process after a call to
316 \function{fork()}).
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000317\end{excdesc}
318
319\begin{excdesc}{TypeError}
320 Raised when a built-in operation or function is applied to an object
321 of inappropriate type. The associated value is a string giving
322 details about the type mismatch.
323\end{excdesc}
324
Fred Drake5828ad62000-04-06 15:03:01 +0000325\begin{excdesc}{UnboundLocalError}
326 Raised when a reference is made to a local variable in a function or
327 method, but no value has been bound to that variable. This is a
328 subclass of \exception{NameError}.
Fred Drake30f76ff2000-06-30 16:06:19 +0000329\versionadded{2.0}
Fred Drake5828ad62000-04-06 15:03:01 +0000330\end{excdesc}
331
Fred Drake3cb793e2000-04-06 14:48:35 +0000332\begin{excdesc}{UnicodeError}
333 Raised when a Unicode-related encoding or decoding error occurs. It
334 is a subclass of \exception{ValueError}.
Fred Drake30f76ff2000-06-30 16:06:19 +0000335\versionadded{2.0}
Fred Drake3cb793e2000-04-06 14:48:35 +0000336\end{excdesc}
337
Walter Dörwald3aeb6322002-09-02 13:14:32 +0000338\begin{excdesc}{UnicodeEncodeError}
339 Raised when a Unicode-related error occurs during encoding. It
340 is a subclass of \exception{UnicodeError}.
341\versionadded{2.3}
342\end{excdesc}
343
344\begin{excdesc}{UnicodeDecodeError}
345 Raised when a Unicode-related error occurs during decoding. It
346 is a subclass of \exception{UnicodeError}.
347\versionadded{2.3}
348\end{excdesc}
349
350\begin{excdesc}{UnicodeTranslateError}
351 Raised when a Unicode-related error occurs during translating. It
352 is a subclass of \exception{UnicodeError}.
353\versionadded{2.3}
354\end{excdesc}
355
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000356\begin{excdesc}{ValueError}
357 Raised when a built-in operation or function receives an argument
358 that has the right type but an inappropriate value, and the
359 situation is not described by a more precise exception such as
Fred Drake27467e41998-07-23 19:47:41 +0000360 \exception{IndexError}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000361\end{excdesc}
362
Fred Drakecebda6f2000-04-17 17:42:00 +0000363\begin{excdesc}{WindowsError}
364 Raised when a Windows-specific error occurs or when the error number
365 does not correspond to an \cdata{errno} value. The
366 \member{errno} and \member{strerror} values are created from the
367 return values of the \cfunction{GetLastError()} and
368 \cfunction{FormatMessage()} functions from the Windows Platform API.
369 This is a subclass of \exception{OSError}.
Fred Drake30f76ff2000-06-30 16:06:19 +0000370\versionadded{2.0}
Fred Drakecebda6f2000-04-17 17:42:00 +0000371\end{excdesc}
372
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000373\begin{excdesc}{ZeroDivisionError}
374 Raised when the second argument of a division or modulo operation is
375 zero. The associated value is a string indicating the type of the
376 operands and the operation.
377\end{excdesc}
Guido van Rossum1367b832000-12-19 04:27:54 +0000378
379
Fred Drakec6920552001-09-21 21:12:30 +0000380\setindexsubitem{(built-in warning)}
Guido van Rossum1367b832000-12-19 04:27:54 +0000381
382The following exceptions are used as warning categories; see the
Barry Warsawb8c20a72002-08-14 16:40:54 +0000383\refmodule{warnings} module for more information.
Guido van Rossum1367b832000-12-19 04:27:54 +0000384
385\begin{excdesc}{Warning}
386Base class for warning categories.
387\end{excdesc}
388
389\begin{excdesc}{UserWarning}
390Base class for warnings generated by user code.
391\end{excdesc}
392
393\begin{excdesc}{DeprecationWarning}
394Base class for warnings about deprecated features.
395\end{excdesc}
396
Neal Norwitzd68f5172002-05-29 15:54:55 +0000397\begin{excdesc}{PendingDeprecationWarning}
398Base class for warnings about features which will be deprecated in the future.
399\end{excdesc}
400
Guido van Rossum1367b832000-12-19 04:27:54 +0000401\begin{excdesc}{SyntaxWarning}
402Base class for warnings about dubious syntax
403\end{excdesc}
404
405\begin{excdesc}{RuntimeWarning}
406Base class for warnings about dubious runtime behavior.
407\end{excdesc}
Skip Montanarobb6bbc42002-03-28 20:53:22 +0000408
Barry Warsawb8c20a72002-08-14 16:40:54 +0000409\begin{excdesc}{FutureWarning}
410Base class for warnings about constructs that will change semantically
411in the future.
412\end{excdesc}
413
Fred Drake8d62e942002-03-28 21:06:17 +0000414The class hierarchy for built-in exceptions is:
Skip Montanarobb6bbc42002-03-28 20:53:22 +0000415
416\begin{verbatim}
417 Exception
418 +-- SystemExit
419 +-- StopIteration
420 +-- StandardError
421 | +-- KeyboardInterrupt
422 | +-- ImportError
423 | +-- EnvironmentError
424 | | +-- IOError
425 | | +-- OSError
426 | | +-- WindowsError
427 | +-- EOFError
428 | +-- RuntimeError
429 | | +-- NotImplementedError
430 | +-- NameError
431 | | +-- UnboundLocalError
432 | +-- AttributeError
433 | +-- SyntaxError
434 | | +-- IndentationError
435 | | +-- TabError
436 | +-- TypeError
437 | +-- AssertionError
438 | +-- LookupError
439 | | +-- IndexError
440 | | +-- KeyError
441 | +-- ArithmeticError
442 | | +-- OverflowError
443 | | +-- ZeroDivisionError
444 | | +-- FloatingPointError
445 | +-- ValueError
446 | | +-- UnicodeError
Walter Dörwald3aeb6322002-09-02 13:14:32 +0000447 | | +-- UnicodeEncodeError
448 | | +-- UnicodeDecodeError
449 | | +-- UnicodeTranslateError
Skip Montanarobb6bbc42002-03-28 20:53:22 +0000450 | +-- ReferenceError
451 | +-- SystemError
452 | +-- MemoryError
453 +---Warning
454 +-- UserWarning
455 +-- DeprecationWarning
Neal Norwitzd68f5172002-05-29 15:54:55 +0000456 +-- PendingDeprecationWarning
Skip Montanarobb6bbc42002-03-28 20:53:22 +0000457 +-- SyntaxWarning
458 +-- OverflowWarning
459 +-- RuntimeWarning
Barry Warsawb8c20a72002-08-14 16:40:54 +0000460 +-- FutureWarning
Skip Montanarobb6bbc42002-03-28 20:53:22 +0000461\end{verbatim}