blob: 8c5a9602e43df73d63c53f1dabb3e9ec21696e87 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001.. _bltin-exceptions:
2
3Built-in Exceptions
4===================
5
Georg Brandl116aa622007-08-15 14:28:22 +00006.. index::
7 statement: try
8 statement: except
9
Georg Brandlfbd1b222009-12-29 21:38:35 +000010In Python, all exceptions must be instances of a class that derives from
11:class:`BaseException`. In a :keyword:`try` statement with an :keyword:`except`
Georg Brandl116aa622007-08-15 14:28:22 +000012clause that mentions a particular class, that clause also handles any exception
13classes derived from that class (but not exception classes from which *it* is
14derived). Two exception classes that are not related via subclassing are never
15equivalent, even if they have the same name.
16
17.. index:: statement: raise
18
19The built-in exceptions listed below can be generated by the interpreter or
20built-in functions. Except where mentioned, they have an "associated value"
Georg Brandlfb6fd5d2011-01-07 18:28:45 +000021indicating the detailed cause of the error. This may be a string or a tuple of
22several items of information (e.g., an error code and a string explaining the
23code). The associated value is usually passed as arguments to the exception
24class's constructor.
Georg Brandl116aa622007-08-15 14:28:22 +000025
26User code can raise built-in exceptions. This can be used to test an exception
27handler or to report an error condition "just like" the situation in which the
28interpreter raises the same exception; but beware that there is nothing to
29prevent user code from raising an inappropriate error.
30
31The built-in exception classes can be sub-classed to define new exceptions;
32programmers are encouraged to at least derive new exceptions from the
33:exc:`Exception` class and not :exc:`BaseException`. More information on
34defining exceptions is available in the Python Tutorial under
35:ref:`tut-userexceptions`.
36
Nick Coghlanab7bf212012-02-26 17:49:52 +100037When raising (or re-raising) an exception in an :keyword:`except` clause
38:attr:`__context__` is automatically set to the last exception caught; if the
39new exception is not handled the traceback that is eventually displayed will
40include the originating exception(s) and the final exception.
41
42This implicit exception chain can be made explicit by using :keyword:`from`
43with :keyword:`raise`. The single argument to :keyword:`from` must be an
Benjamin Petersonad8586d2012-02-27 10:59:10 -050044exception or :const:`None`, and it will be set as :attr:`__cause__` on the
Nick Coghlanab7bf212012-02-26 17:49:52 +100045raised exception. If :attr:`__cause__` is an exception it will be displayed
46instead of :attr:`__context__`; if :attr:`__cause__` is None,
47:attr:`__context__` will not be displayed by the default exception handling
48code. (Note: the default value for :attr:`__context__` is :const:`None`,
49while the default value for :attr:`__cause__` is :const:`Ellipsis`.)
50
51In either case, the default exception handling code will not display
52any of the remaining links in the :attr:`__context__` chain if
53:attr:`__cause__` has been set.
54
Antoine Pitrouf9c77462011-10-12 16:02:00 +020055
56Base classes
57------------
58
Georg Brandlfbd1b222009-12-29 21:38:35 +000059The following exceptions are used mostly as base classes for other exceptions.
Georg Brandl116aa622007-08-15 14:28:22 +000060
Georg Brandl116aa622007-08-15 14:28:22 +000061.. exception:: BaseException
62
63 The base class for all built-in exceptions. It is not meant to be directly
Georg Brandlfb6fd5d2011-01-07 18:28:45 +000064 inherited by user-defined classes (for that, use :exc:`Exception`). If
Amaury Forgeot d'Arc3b1acf12011-11-22 19:34:08 +010065 :func:`str` is called on an instance of this class, the representation of
66 the argument(s) to the instance are returned, or the empty string when
67 there were no arguments.
Georg Brandlfb6fd5d2011-01-07 18:28:45 +000068
69 .. attribute:: args
70
71 The tuple of arguments given to the exception constructor. Some built-in
72 exceptions (like :exc:`IOError`) expect a certain number of arguments and
73 assign a special meaning to the elements of this tuple, while others are
74 usually called only with a single string giving an error message.
75
76 .. method:: with_traceback(tb)
77
78 This method sets *tb* as the new traceback for the exception and returns
79 the exception object. It is usually used in exception handling code like
80 this::
81
82 try:
83 ...
84 except SomeException:
85 tb = sys.exc_info()[2]
86 raise OtherException(...).with_traceback(tb)
Georg Brandl116aa622007-08-15 14:28:22 +000087
Georg Brandl116aa622007-08-15 14:28:22 +000088
89.. exception:: Exception
90
91 All built-in, non-system-exiting exceptions are derived from this class. All
92 user-defined exceptions should also be derived from this class.
93
Georg Brandl116aa622007-08-15 14:28:22 +000094
95.. exception:: ArithmeticError
96
97 The base class for those built-in exceptions that are raised for various
98 arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`,
99 :exc:`FloatingPointError`.
100
101
Georg Brandl0bdfbfa2010-12-18 17:51:28 +0000102.. exception:: BufferError
103
104 Raised when a :ref:`buffer <bufferobjects>` related operation cannot be
105 performed.
106
107
Georg Brandl116aa622007-08-15 14:28:22 +0000108.. exception:: LookupError
109
Benjamin Petersonfa0d7032009-06-01 22:42:33 +0000110 The base class for the exceptions that are raised when a key or index used on
111 a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. This
112 can be raised directly by :func:`codecs.lookup`.
Georg Brandl116aa622007-08-15 14:28:22 +0000113
114
Antoine Pitrouf9c77462011-10-12 16:02:00 +0200115Concrete exceptions
116-------------------
Georg Brandl116aa622007-08-15 14:28:22 +0000117
Georg Brandlfbd1b222009-12-29 21:38:35 +0000118The following exceptions are the exceptions that are usually raised.
Georg Brandl116aa622007-08-15 14:28:22 +0000119
120.. exception:: AssertionError
121
122 .. index:: statement: assert
123
124 Raised when an :keyword:`assert` statement fails.
125
126
127.. exception:: AttributeError
128
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000129 Raised when an attribute reference (see :ref:`attribute-references`) or
130 assignment fails. (When an object does not support attribute references or
131 attribute assignments at all, :exc:`TypeError` is raised.)
Georg Brandl116aa622007-08-15 14:28:22 +0000132
133
134.. exception:: EOFError
135
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000136 Raised when one of the built-in functions (:func:`input` or :func:`raw_input`)
137 hits an end-of-file condition (EOF) without reading any data. (N.B.: the
Georg Brandl81ac1ce2007-08-31 17:17:17 +0000138 :meth:`file.read` and :meth:`file.readline` methods return an empty string
139 when they hit EOF.)
Georg Brandl116aa622007-08-15 14:28:22 +0000140
141
142.. exception:: FloatingPointError
143
144 Raised when a floating point operation fails. This exception is always defined,
145 but can only be raised when Python is configured with the
Éric Araujo713d3032010-11-18 16:38:46 +0000146 ``--with-fpectl`` option, or the :const:`WANT_SIGFPE_HANDLER` symbol is
Georg Brandl116aa622007-08-15 14:28:22 +0000147 defined in the :file:`pyconfig.h` file.
148
149
150.. exception:: GeneratorExit
151
Christian Heimescbf3b5c2007-12-03 21:02:03 +0000152 Raise when a :term:`generator`\'s :meth:`close` method is called. It
153 directly inherits from :exc:`BaseException` instead of :exc:`Exception` since
154 it is technically not an error.
Georg Brandl116aa622007-08-15 14:28:22 +0000155
Georg Brandl116aa622007-08-15 14:28:22 +0000156
Georg Brandl116aa622007-08-15 14:28:22 +0000157.. exception:: ImportError
158
159 Raised when an :keyword:`import` statement fails to find the module definition
160 or when a ``from ... import`` fails to find a name that is to be imported.
161
Georg Brandl116aa622007-08-15 14:28:22 +0000162
163.. exception:: IndexError
164
Georg Brandl95817b32008-05-11 14:30:18 +0000165 Raised when a sequence subscript is out of range. (Slice indices are
166 silently truncated to fall in the allowed range; if an index is not an
167 integer, :exc:`TypeError` is raised.)
Georg Brandl116aa622007-08-15 14:28:22 +0000168
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000169 .. XXX xref to sequences
Georg Brandl116aa622007-08-15 14:28:22 +0000170
171
172.. exception:: KeyError
173
174 Raised when a mapping (dictionary) key is not found in the set of existing keys.
175
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000176 .. XXX xref to mapping objects?
Georg Brandl116aa622007-08-15 14:28:22 +0000177
178
179.. exception:: KeyboardInterrupt
180
181 Raised when the user hits the interrupt key (normally :kbd:`Control-C` or
Georg Brandl81ac1ce2007-08-31 17:17:17 +0000182 :kbd:`Delete`). During execution, a check for interrupts is made
183 regularly. The exception inherits from :exc:`BaseException` so as to not be
184 accidentally caught by code that catches :exc:`Exception` and thus prevent
185 the interpreter from exiting.
Georg Brandl116aa622007-08-15 14:28:22 +0000186
Georg Brandl116aa622007-08-15 14:28:22 +0000187
188.. exception:: MemoryError
189
190 Raised when an operation runs out of memory but the situation may still be
191 rescued (by deleting some objects). The associated value is a string indicating
192 what kind of (internal) operation ran out of memory. Note that because of the
Georg Brandl60203b42010-10-06 10:11:56 +0000193 underlying memory management architecture (C's :c:func:`malloc` function), the
Georg Brandl116aa622007-08-15 14:28:22 +0000194 interpreter may not always be able to completely recover from this situation; it
195 nevertheless raises an exception so that a stack traceback can be printed, in
196 case a run-away program was the cause.
197
198
199.. exception:: NameError
200
201 Raised when a local or global name is not found. This applies only to
202 unqualified names. The associated value is an error message that includes the
203 name that could not be found.
204
205
206.. exception:: NotImplementedError
207
208 This exception is derived from :exc:`RuntimeError`. In user defined base
209 classes, abstract methods should raise this exception when they require derived
210 classes to override the method.
211
Georg Brandl116aa622007-08-15 14:28:22 +0000212
213.. exception:: OSError
214
Christian Heimesa62da1d2008-01-12 19:39:10 +0000215 .. index:: module: errno
216
Antoine Pitrouf9c77462011-10-12 16:02:00 +0200217 This exception is raised when a system function returns a system-related
218 error, including I/O failures such as "file not found" or "disk full"
219 (not for illegal argument types or other incidental errors). Often a
220 subclass of :exc:`OSError` will actually be raised as described in
221 `OS exceptions`_ below. The :attr:`errno` attribute is a numeric error
222 code from the C variable :c:data:`errno`.
Christian Heimesa62da1d2008-01-12 19:39:10 +0000223
Antoine Pitrouf9c77462011-10-12 16:02:00 +0200224 Under Windows, the :attr:`winerror` attribute gives you the native
225 Windows error code. The :attr:`errno` attribute is then an approximate
226 translation, in POSIX terms, of that native error code.
227
228 Under all platforms, the :attr:`strerror` attribute is the corresponding
229 error message as provided by the operating system (as formatted by the C
230 functions :c:func:`perror` under POSIX, and :c:func:`FormatMessage`
231 Windows).
232
233 For exceptions that involve a file system path (such as :func:`open` or
234 :func:`os.unlink`), the exception instance will contain an additional
235 attribute, :attr:`filename`, which is the file name passed to the function.
Georg Brandl116aa622007-08-15 14:28:22 +0000236
Antoine Pitrou195e7022011-10-12 16:46:46 +0200237 .. versionchanged:: 3.3
238 :exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`,
239 :exc:`VMSError`, :exc:`socket.error`, :exc:`select.error` and
240 :exc:`mmap.error` have been merged into :exc:`OSError`.
241
Georg Brandl116aa622007-08-15 14:28:22 +0000242
243.. exception:: OverflowError
244
245 Raised when the result of an arithmetic operation is too large to be
Georg Brandlba956ae2007-11-29 17:24:34 +0000246 represented. This cannot occur for integers (which would rather raise
Georg Brandl116aa622007-08-15 14:28:22 +0000247 :exc:`MemoryError` than give up). Because of the lack of standardization of
248 floating point exception handling in C, most floating point operations also
Georg Brandl81ac1ce2007-08-31 17:17:17 +0000249 aren't checked.
Georg Brandl116aa622007-08-15 14:28:22 +0000250
251
252.. exception:: ReferenceError
253
254 This exception is raised when a weak reference proxy, created by the
255 :func:`weakref.proxy` function, is used to access an attribute of the referent
256 after it has been garbage collected. For more information on weak references,
257 see the :mod:`weakref` module.
258
Georg Brandl116aa622007-08-15 14:28:22 +0000259
260.. exception:: RuntimeError
261
262 Raised when an error is detected that doesn't fall in any of the other
263 categories. The associated value is a string indicating what precisely went
264 wrong. (This exception is mostly a relic from a previous version of the
265 interpreter; it is not used very much any more.)
266
267
268.. exception:: StopIteration
269
Georg Brandlc4a55fc2010-02-06 18:46:57 +0000270 Raised by built-in function :func:`next` and an :term:`iterator`\'s
Nick Coghlan1f7ce622012-01-13 21:43:40 +1000271 :meth:`__next__` method to signal that there are no further items to be
272 produced by the iterator.
273
274 The exception object has a single attribute :attr:`value`, which is
275 given as an argument when constructing the exception, and defaults
276 to :const:`None`.
277
278 When a generator function returns, a new :exc:`StopIteration` instance is
279 raised, and the value returned by the function is used as the
280 :attr:`value` parameter to the constructor of the exception.
Georg Brandl116aa622007-08-15 14:28:22 +0000281
Nick Coghlan0ed80192012-01-14 14:43:24 +1000282 .. versionchanged:: 3.3
283 Added ``value`` attribute and the ability for generator functions to
284 use it to return a value.
Georg Brandl116aa622007-08-15 14:28:22 +0000285
286.. exception:: SyntaxError
287
288 Raised when the parser encounters a syntax error. This may occur in an
289 :keyword:`import` statement, in a call to the built-in functions :func:`exec`
290 or :func:`eval`, or when reading the initial script or standard input
291 (also interactively).
292
Georg Brandl116aa622007-08-15 14:28:22 +0000293 Instances of this class have attributes :attr:`filename`, :attr:`lineno`,
294 :attr:`offset` and :attr:`text` for easier access to the details. :func:`str`
295 of the exception instance returns only the message.
296
297
Georg Brandl0bdfbfa2010-12-18 17:51:28 +0000298.. exception:: IndentationError
299
300 Base class for syntax errors related to incorrect indentation. This is a
301 subclass of :exc:`SyntaxError`.
302
303
304.. exception:: TabError
305
306 Raised when indentation contains an inconsistent use of tabs and spaces.
307 This is a subclass of :exc:`IndentationError`.
308
309
Georg Brandl116aa622007-08-15 14:28:22 +0000310.. exception:: SystemError
311
312 Raised when the interpreter finds an internal error, but the situation does not
313 look so serious to cause it to abandon all hope. The associated value is a
314 string indicating what went wrong (in low-level terms).
315
316 You should report this to the author or maintainer of your Python interpreter.
317 Be sure to report the version of the Python interpreter (``sys.version``; it is
318 also printed at the start of an interactive Python session), the exact error
319 message (the exception's associated value) and if possible the source of the
320 program that triggered the error.
321
322
323.. exception:: SystemExit
324
325 This exception is raised by the :func:`sys.exit` function. When it is not
326 handled, the Python interpreter exits; no stack traceback is printed. If the
Georg Brandl95817b32008-05-11 14:30:18 +0000327 associated value is an integer, it specifies the system exit status (passed
Georg Brandl60203b42010-10-06 10:11:56 +0000328 to C's :c:func:`exit` function); if it is ``None``, the exit status is zero;
Georg Brandl95817b32008-05-11 14:30:18 +0000329 if it has another type (such as a string), the object's value is printed and
330 the exit status is one.
Georg Brandl116aa622007-08-15 14:28:22 +0000331
Georg Brandl116aa622007-08-15 14:28:22 +0000332 Instances have an attribute :attr:`code` which is set to the proposed exit
333 status or error message (defaulting to ``None``). Also, this exception derives
334 directly from :exc:`BaseException` and not :exc:`Exception`, since it is not
335 technically an error.
336
337 A call to :func:`sys.exit` is translated into an exception so that clean-up
338 handlers (:keyword:`finally` clauses of :keyword:`try` statements) can be
339 executed, and so that a debugger can execute a script without running the risk
340 of losing control. The :func:`os._exit` function can be used if it is
341 absolutely positively necessary to exit immediately (for example, in the child
342 process after a call to :func:`fork`).
343
344 The exception inherits from :exc:`BaseException` instead of :exc:`Exception` so
345 that it is not accidentally caught by code that catches :exc:`Exception`. This
346 allows the exception to properly propagate up and cause the interpreter to exit.
347
Georg Brandl116aa622007-08-15 14:28:22 +0000348
349.. exception:: TypeError
350
351 Raised when an operation or function is applied to an object of inappropriate
352 type. The associated value is a string giving details about the type mismatch.
353
354
355.. exception:: UnboundLocalError
356
357 Raised when a reference is made to a local variable in a function or method, but
358 no value has been bound to that variable. This is a subclass of
359 :exc:`NameError`.
360
Georg Brandl116aa622007-08-15 14:28:22 +0000361
362.. exception:: UnicodeError
363
364 Raised when a Unicode-related encoding or decoding error occurs. It is a
365 subclass of :exc:`ValueError`.
366
Georg Brandl116aa622007-08-15 14:28:22 +0000367
368.. exception:: UnicodeEncodeError
369
370 Raised when a Unicode-related error occurs during encoding. It is a subclass of
371 :exc:`UnicodeError`.
372
Georg Brandl116aa622007-08-15 14:28:22 +0000373
374.. exception:: UnicodeDecodeError
375
376 Raised when a Unicode-related error occurs during decoding. It is a subclass of
377 :exc:`UnicodeError`.
378
Georg Brandl116aa622007-08-15 14:28:22 +0000379
380.. exception:: UnicodeTranslateError
381
382 Raised when a Unicode-related error occurs during translating. It is a subclass
383 of :exc:`UnicodeError`.
384
Georg Brandl116aa622007-08-15 14:28:22 +0000385
386.. exception:: ValueError
387
388 Raised when a built-in operation or function receives an argument that has the
389 right type but an inappropriate value, and the situation is not described by a
390 more precise exception such as :exc:`IndexError`.
391
392
Georg Brandl116aa622007-08-15 14:28:22 +0000393.. exception:: ZeroDivisionError
394
395 Raised when the second argument of a division or modulo operation is zero. The
396 associated value is a string indicating the type of the operands and the
397 operation.
398
Georg Brandlfbd1b222009-12-29 21:38:35 +0000399
Antoine Pitrouf9c77462011-10-12 16:02:00 +0200400The following exceptions are kept for compatibility with previous versions;
401starting from Python 3.3, they are aliases of :exc:`OSError`.
402
403.. exception:: EnvironmentError
404
405.. exception:: IOError
406
407.. exception:: VMSError
408
409 Only available on VMS.
410
411.. exception:: WindowsError
412
413 Only available on Windows.
414
415
416OS exceptions
417^^^^^^^^^^^^^
418
419The following exceptions are subclasses of :exc:`OSError`, they get raised
420depending on the system error code.
421
422.. exception:: BlockingIOError
423
424 Raised when an operation would block on an object (e.g. socket) set
425 for non-blocking operation.
426 Corresponds to :c:data:`errno` ``EAGAIN``, ``EALREADY``,
427 ``EWOULDBLOCK`` and ``EINPROGRESS``.
428
Antoine Pitrouf55011f2011-10-12 18:57:23 +0200429 In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have
430 one more attribute:
431
432 .. attribute:: characters_written
433
434 An integer containing the number of characters written to the stream
435 before it blocked. This attribute is available when using the
436 buffered I/O classes from the :mod:`io` module.
437
Antoine Pitrouf9c77462011-10-12 16:02:00 +0200438.. exception:: ChildProcessError
439
440 Raised when an operation on a child process failed.
441 Corresponds to :c:data:`errno` ``ECHILD``.
442
443.. exception:: ConnectionError
444
445 A base class for connection-related issues. Subclasses are
446 :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`,
447 :exc:`ConnectionRefusedError` and :exc:`ConnectionResetError`.
448
449 .. exception:: BrokenPipeError
450
451 A subclass of :exc:`ConnectionError`, raised when trying to write on a
452 pipe while the other end has been closed, or trying to write on a socket
453 which has been shutdown for writing.
454 Corresponds to :c:data:`errno` ``EPIPE`` and ``ESHUTDOWN``.
455
456 .. exception:: ConnectionAbortedError
457
458 A subclass of :exc:`ConnectionError`, raised when a connection attempt
459 is aborted by the peer.
460 Corresponds to :c:data:`errno` ``ECONNABORTED``.
461
462 .. exception:: ConnectionRefusedError
463
464 A subclass of :exc:`ConnectionError`, raised when a connection attempt
465 is refused by the peer.
466 Corresponds to :c:data:`errno` ``ECONNREFUSED``.
467
468 .. exception:: ConnectionResetError
469
470 A subclass of :exc:`ConnectionError`, raised when a connection is
471 reset by the peer.
472 Corresponds to :c:data:`errno` ``ECONNRESET``.
473
474.. exception:: FileExistsError
475
476 Raised when trying to create a file or directory which already exists.
477 Corresponds to :c:data:`errno` ``EEXIST``.
478
479.. exception:: FileNotFoundError
480
481 Raised when a file or directory is requested but doesn't exist.
482 Corresponds to :c:data:`errno` ``ENOENT``.
483
484.. exception:: InterruptedError
485
486 Raised when a system call is interrupted by an incoming signal.
487 Corresponds to :c:data:`errno` ``EEINTR``.
488
489.. exception:: IsADirectoryError
490
491 Raised when a file operation (such as :func:`os.remove`) is requested
492 on a directory.
493 Corresponds to :c:data:`errno` ``EISDIR``.
494
495.. exception:: NotADirectoryError
496
497 Raised when a directory operation (such as :func:`os.listdir`) is requested
498 on something which is not a directory.
499 Corresponds to :c:data:`errno` ``ENOTDIR``.
500
501.. exception:: PermissionError
502
503 Raised when trying to run an operation without the adequate access
504 rights - for example filesystem permissions.
505 Corresponds to :c:data:`errno` ``EACCES`` and ``EPERM``.
506
507.. exception:: ProcessLookupError
508
509 Raised when a given process doesn't exist.
510 Corresponds to :c:data:`errno` ``ESRCH``.
511
512.. exception:: TimeoutError
513
514 Raised when a system function timed out at the system level.
515 Corresponds to :c:data:`errno` ``ETIMEDOUT``.
516
517.. versionadded:: 3.3
518 All the above :exc:`OSError` subclasses were added.
519
520
521.. seealso::
522
523 :pep:`3151` - Reworking the OS and IO exception hierarchy
524 PEP written and implemented by Antoine Pitrou.
525
526
527Warnings
528--------
529
Georg Brandl116aa622007-08-15 14:28:22 +0000530The following exceptions are used as warning categories; see the :mod:`warnings`
531module for more information.
532
Georg Brandl116aa622007-08-15 14:28:22 +0000533.. exception:: Warning
534
535 Base class for warning categories.
536
537
538.. exception:: UserWarning
539
540 Base class for warnings generated by user code.
541
542
543.. exception:: DeprecationWarning
544
545 Base class for warnings about deprecated features.
546
547
548.. exception:: PendingDeprecationWarning
549
550 Base class for warnings about features which will be deprecated in the future.
551
552
553.. exception:: SyntaxWarning
554
555 Base class for warnings about dubious syntax
556
557
558.. exception:: RuntimeWarning
559
560 Base class for warnings about dubious runtime behavior.
561
562
563.. exception:: FutureWarning
564
565 Base class for warnings about constructs that will change semantically in the
566 future.
567
568
569.. exception:: ImportWarning
570
571 Base class for warnings about probable mistakes in module imports.
572
Georg Brandl116aa622007-08-15 14:28:22 +0000573
574.. exception:: UnicodeWarning
575
576 Base class for warnings related to Unicode.
577
Georg Brandl08be72d2010-10-24 15:11:22 +0000578
Guido van Rossum98297ee2007-11-06 21:34:58 +0000579.. exception:: BytesWarning
Georg Brandl116aa622007-08-15 14:28:22 +0000580
Guido van Rossum98297ee2007-11-06 21:34:58 +0000581 Base class for warnings related to :class:`bytes` and :class:`buffer`.
582
Georg Brandl08be72d2010-10-24 15:11:22 +0000583
584.. exception:: ResourceWarning
585
586 Base class for warnings related to resource usage.
587
588 .. versionadded:: 3.2
589
590
591
Alexandre Vassalottic22c6f22009-07-21 00:51:58 +0000592Exception hierarchy
593-------------------
Guido van Rossum98297ee2007-11-06 21:34:58 +0000594
595The class hierarchy for built-in exceptions is:
Georg Brandl116aa622007-08-15 14:28:22 +0000596
597.. literalinclude:: ../../Lib/test/exception_hierarchy.txt