1.. _bltin-exceptions: 2 3Built-in Exceptions 4=================== 5 6.. index:: 7 statement: try 8 statement: except 9 10In Python, all exceptions must be instances of a class that derives from 11:class:`BaseException`. In a :keyword:`try` statement with an :keyword:`except` 12clause 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" 21indicating 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. 25 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 subclassed to define new exceptions; 32programmers are encouraged to derive new exceptions from the :exc:`Exception` 33class or one of its subclasses, and not from :exc:`BaseException`. More 34information on defining exceptions is available in the Python Tutorial under 35:ref:`tut-userexceptions`. 36 37When raising (or re-raising) an exception in an :keyword:`except` or 38:keyword:`finally` clause 39:attr:`__context__` is automatically set to the last exception caught; if the 40new exception is not handled the traceback that is eventually displayed will 41include the originating exception(s) and the final exception. 42 43When raising a new exception (rather than using a bare ``raise`` to re-raise 44the exception currently being handled), the implicit exception context can be 45supplemented with an explicit cause by using :keyword:`from<raise>` with 46:keyword:`raise`:: 47 48 raise new_exc from original_exc 49 50The expression following :keyword:`from<raise>` must be an exception or ``None``. It 51will be set as :attr:`__cause__` on the raised exception. Setting 52:attr:`__cause__` also implicitly sets the :attr:`__suppress_context__` 53attribute to ``True``, so that using ``raise new_exc from None`` 54effectively replaces the old exception with the new one for display 55purposes (e.g. converting :exc:`KeyError` to :exc:`AttributeError`), while 56leaving the old exception available in :attr:`__context__` for introspection 57when debugging. 58 59The default traceback display code shows these chained exceptions in 60addition to the traceback for the exception itself. An explicitly chained 61exception in :attr:`__cause__` is always shown when present. An implicitly 62chained exception in :attr:`__context__` is shown only if :attr:`__cause__` 63is :const:`None` and :attr:`__suppress_context__` is false. 64 65In either case, the exception itself is always shown after any chained 66exceptions so that the final line of the traceback always shows the last 67exception that was raised. 68 69 70Base classes 71------------ 72 73The following exceptions are used mostly as base classes for other exceptions. 74 75.. exception:: BaseException 76 77 The base class for all built-in exceptions. It is not meant to be directly 78 inherited by user-defined classes (for that, use :exc:`Exception`). If 79 :func:`str` is called on an instance of this class, the representation of 80 the argument(s) to the instance are returned, or the empty string when 81 there were no arguments. 82 83 .. attribute:: args 84 85 The tuple of arguments given to the exception constructor. Some built-in 86 exceptions (like :exc:`OSError`) expect a certain number of arguments and 87 assign a special meaning to the elements of this tuple, while others are 88 usually called only with a single string giving an error message. 89 90 .. method:: with_traceback(tb) 91 92 This method sets *tb* as the new traceback for the exception and returns 93 the exception object. It is usually used in exception handling code like 94 this:: 95 96 try: 97 ... 98 except SomeException: 99 tb = sys.exc_info()[2] 100 raise OtherException(...).with_traceback(tb) 101 102 103.. exception:: Exception 104 105 All built-in, non-system-exiting exceptions are derived from this class. All 106 user-defined exceptions should also be derived from this class. 107 108 109.. exception:: ArithmeticError 110 111 The base class for those built-in exceptions that are raised for various 112 arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, 113 :exc:`FloatingPointError`. 114 115 116.. exception:: BufferError 117 118 Raised when a :ref:`buffer <bufferobjects>` related operation cannot be 119 performed. 120 121 122.. exception:: LookupError 123 124 The base class for the exceptions that are raised when a key or index used on 125 a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. This 126 can be raised directly by :func:`codecs.lookup`. 127 128 129Concrete exceptions 130------------------- 131 132The following exceptions are the exceptions that are usually raised. 133 134.. exception:: AssertionError 135 136 .. index:: statement: assert 137 138 Raised when an :keyword:`assert` statement fails. 139 140 141.. exception:: AttributeError 142 143 Raised when an attribute reference (see :ref:`attribute-references`) or 144 assignment fails. (When an object does not support attribute references or 145 attribute assignments at all, :exc:`TypeError` is raised.) 146 147 148.. exception:: EOFError 149 150 Raised when the :func:`input` function hits an end-of-file condition (EOF) 151 without reading any data. (N.B.: the :meth:`io.IOBase.read` and 152 :meth:`io.IOBase.readline` methods return an empty string when they hit EOF.) 153 154 155.. exception:: FloatingPointError 156 157 Not currently used. 158 159 160.. exception:: GeneratorExit 161 162 Raised when a :term:`generator` or :term:`coroutine` is closed; 163 see :meth:`generator.close` and :meth:`coroutine.close`. It 164 directly inherits from :exc:`BaseException` instead of :exc:`Exception` since 165 it is technically not an error. 166 167 168.. exception:: ImportError 169 170 Raised when the :keyword:`import` statement has troubles trying to 171 load a module. Also raised when the "from list" in ``from ... import`` 172 has a name that cannot be found. 173 174 The :attr:`name` and :attr:`path` attributes can be set using keyword-only 175 arguments to the constructor. When set they represent the name of the module 176 that was attempted to be imported and the path to any file which triggered 177 the exception, respectively. 178 179 .. versionchanged:: 3.3 180 Added the :attr:`name` and :attr:`path` attributes. 181 182.. exception:: ModuleNotFoundError 183 184 A subclass of :exc:`ImportError` which is raised by :keyword:`import` 185 when a module could not be located. It is also raised when ``None`` 186 is found in :data:`sys.modules`. 187 188 .. versionadded:: 3.6 189 190 191.. exception:: IndexError 192 193 Raised when a sequence subscript is out of range. (Slice indices are 194 silently truncated to fall in the allowed range; if an index is not an 195 integer, :exc:`TypeError` is raised.) 196 197 .. XXX xref to sequences 198 199 200.. exception:: KeyError 201 202 Raised when a mapping (dictionary) key is not found in the set of existing keys. 203 204 .. XXX xref to mapping objects? 205 206 207.. exception:: KeyboardInterrupt 208 209 Raised when the user hits the interrupt key (normally :kbd:`Control-C` or 210 :kbd:`Delete`). During execution, a check for interrupts is made 211 regularly. The exception inherits from :exc:`BaseException` so as to not be 212 accidentally caught by code that catches :exc:`Exception` and thus prevent 213 the interpreter from exiting. 214 215 216.. exception:: MemoryError 217 218 Raised when an operation runs out of memory but the situation may still be 219 rescued (by deleting some objects). The associated value is a string indicating 220 what kind of (internal) operation ran out of memory. Note that because of the 221 underlying memory management architecture (C's :c:func:`malloc` function), the 222 interpreter may not always be able to completely recover from this situation; it 223 nevertheless raises an exception so that a stack traceback can be printed, in 224 case a run-away program was the cause. 225 226 227.. exception:: NameError 228 229 Raised when a local or global name is not found. This applies only to 230 unqualified names. The associated value is an error message that includes the 231 name that could not be found. 232 233 234.. exception:: NotImplementedError 235 236 This exception is derived from :exc:`RuntimeError`. In user defined base 237 classes, abstract methods should raise this exception when they require 238 derived classes to override the method, or while the class is being 239 developed to indicate that the real implementation still needs to be added. 240 241 .. note:: 242 243 It should not be used to indicate that an operator or method is not 244 meant to be supported at all -- in that case either leave the operator / 245 method undefined or, if a subclass, set it to :data:`None`. 246 247 .. note:: 248 249 ``NotImplementedError`` and ``NotImplemented`` are not interchangeable, 250 even though they have similar names and purposes. See 251 :data:`NotImplemented` for details on when to use it. 252 253.. exception:: OSError([arg]) 254 OSError(errno, strerror[, filename[, winerror[, filename2]]]) 255 256 .. index:: module: errno 257 258 This exception is raised when a system function returns a system-related 259 error, including I/O failures such as "file not found" or "disk full" 260 (not for illegal argument types or other incidental errors). 261 262 The second form of the constructor sets the corresponding attributes, 263 described below. The attributes default to :const:`None` if not 264 specified. For backwards compatibility, if three arguments are passed, 265 the :attr:`~BaseException.args` attribute contains only a 2-tuple 266 of the first two constructor arguments. 267 268 The constructor often actually returns a subclass of :exc:`OSError`, as 269 described in `OS exceptions`_ below. The particular subclass depends on 270 the final :attr:`.errno` value. This behaviour only occurs when 271 constructing :exc:`OSError` directly or via an alias, and is not 272 inherited when subclassing. 273 274 .. attribute:: errno 275 276 A numeric error code from the C variable :c:data:`errno`. 277 278 .. attribute:: winerror 279 280 Under Windows, this gives you the native 281 Windows error code. The :attr:`.errno` attribute is then an approximate 282 translation, in POSIX terms, of that native error code. 283 284 Under Windows, if the *winerror* constructor argument is an integer, 285 the :attr:`.errno` attribute is determined from the Windows error code, 286 and the *errno* argument is ignored. On other platforms, the 287 *winerror* argument is ignored, and the :attr:`winerror` attribute 288 does not exist. 289 290 .. attribute:: strerror 291 292 The corresponding error message, as provided by 293 the operating system. It is formatted by the C 294 functions :c:func:`perror` under POSIX, and :c:func:`FormatMessage` 295 under Windows. 296 297 .. attribute:: filename 298 filename2 299 300 For exceptions that involve a file system path (such as :func:`open` or 301 :func:`os.unlink`), :attr:`filename` is the file name passed to the function. 302 For functions that involve two file system paths (such as 303 :func:`os.rename`), :attr:`filename2` corresponds to the second 304 file name passed to the function. 305 306 307 .. versionchanged:: 3.3 308 :exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, 309 :exc:`socket.error`, :exc:`select.error` and 310 :exc:`mmap.error` have been merged into :exc:`OSError`, and the 311 constructor may return a subclass. 312 313 .. versionchanged:: 3.4 314 The :attr:`filename` attribute is now the original file name passed to 315 the function, instead of the name encoded to or decoded from the 316 filesystem encoding. Also, the *filename2* constructor argument and 317 attribute was added. 318 319 320.. exception:: OverflowError 321 322 Raised when the result of an arithmetic operation is too large to be 323 represented. This cannot occur for integers (which would rather raise 324 :exc:`MemoryError` than give up). However, for historical reasons, 325 OverflowError is sometimes raised for integers that are outside a required 326 range. Because of the lack of standardization of floating point exception 327 handling in C, most floating point operations are not checked. 328 329 330.. exception:: RecursionError 331 332 This exception is derived from :exc:`RuntimeError`. It is raised when the 333 interpreter detects that the maximum recursion depth (see 334 :func:`sys.getrecursionlimit`) is exceeded. 335 336 .. versionadded:: 3.5 337 Previously, a plain :exc:`RuntimeError` was raised. 338 339 340.. exception:: ReferenceError 341 342 This exception is raised when a weak reference proxy, created by the 343 :func:`weakref.proxy` function, is used to access an attribute of the referent 344 after it has been garbage collected. For more information on weak references, 345 see the :mod:`weakref` module. 346 347 348.. exception:: RuntimeError 349 350 Raised when an error is detected that doesn't fall in any of the other 351 categories. The associated value is a string indicating what precisely went 352 wrong. 353 354 355.. exception:: StopIteration 356 357 Raised by built-in function :func:`next` and an :term:`iterator`\'s 358 :meth:`~iterator.__next__` method to signal that there are no further 359 items produced by the iterator. 360 361 The exception object has a single attribute :attr:`value`, which is 362 given as an argument when constructing the exception, and defaults 363 to :const:`None`. 364 365 When a :term:`generator` or :term:`coroutine` function 366 returns, a new :exc:`StopIteration` instance is 367 raised, and the value returned by the function is used as the 368 :attr:`value` parameter to the constructor of the exception. 369 370 If a generator code directly or indirectly raises :exc:`StopIteration`, 371 it is converted into a :exc:`RuntimeError` (retaining the 372 :exc:`StopIteration` as the new exception's cause). 373 374 .. versionchanged:: 3.3 375 Added ``value`` attribute and the ability for generator functions to 376 use it to return a value. 377 378 .. versionchanged:: 3.5 379 Introduced the RuntimeError transformation via 380 ``from __future__ import generator_stop``, see :pep:`479`. 381 382 .. versionchanged:: 3.7 383 Enable :pep:`479` for all code by default: a :exc:`StopIteration` 384 error raised in a generator is transformed into a :exc:`RuntimeError`. 385 386.. exception:: StopAsyncIteration 387 388 Must be raised by :meth:`__anext__` method of an 389 :term:`asynchronous iterator` object to stop the iteration. 390 391 .. versionadded:: 3.5 392 393.. exception:: SyntaxError 394 395 Raised when the parser encounters a syntax error. This may occur in an 396 :keyword:`import` statement, in a call to the built-in functions :func:`exec` 397 or :func:`eval`, or when reading the initial script or standard input 398 (also interactively). 399 400 The :func:`str` of the exception instance returns only the error message. 401 402 .. attribute:: filename 403 404 The name of the file the syntax error occurred in. 405 406 .. attribute:: lineno 407 408 Which line number in the file the error occurred in. This is 409 1-indexed: the first line in the file has a ``lineno`` of 1. 410 411 .. attribute:: offset 412 413 The column in the line where the error occurred. This is 414 1-indexed: the first character in the line has an ``offset`` of 1. 415 416 .. attribute:: text 417 418 The source code text involved in the error. 419 420 421.. exception:: IndentationError 422 423 Base class for syntax errors related to incorrect indentation. This is a 424 subclass of :exc:`SyntaxError`. 425 426 427.. exception:: TabError 428 429 Raised when indentation contains an inconsistent use of tabs and spaces. 430 This is a subclass of :exc:`IndentationError`. 431 432 433.. exception:: SystemError 434 435 Raised when the interpreter finds an internal error, but the situation does not 436 look so serious to cause it to abandon all hope. The associated value is a 437 string indicating what went wrong (in low-level terms). 438 439 You should report this to the author or maintainer of your Python interpreter. 440 Be sure to report the version of the Python interpreter (``sys.version``; it is 441 also printed at the start of an interactive Python session), the exact error 442 message (the exception's associated value) and if possible the source of the 443 program that triggered the error. 444 445 446.. exception:: SystemExit 447 448 This exception is raised by the :func:`sys.exit` function. It inherits from 449 :exc:`BaseException` instead of :exc:`Exception` so that it is not accidentally 450 caught by code that catches :exc:`Exception`. This allows the exception to 451 properly propagate up and cause the interpreter to exit. When it is not 452 handled, the Python interpreter exits; no stack traceback is printed. The 453 constructor accepts the same optional argument passed to :func:`sys.exit`. 454 If the value is an integer, it specifies the system exit status (passed to 455 C's :c:func:`exit` function); if it is ``None``, the exit status is zero; if 456 it has another type (such as a string), the object's value is printed and 457 the exit status is one. 458 459 A call to :func:`sys.exit` is translated into an exception so that clean-up 460 handlers (:keyword:`finally` clauses of :keyword:`try` statements) can be 461 executed, and so that a debugger can execute a script without running the risk 462 of losing control. The :func:`os._exit` function can be used if it is 463 absolutely positively necessary to exit immediately (for example, in the child 464 process after a call to :func:`os.fork`). 465 466 .. attribute:: code 467 468 The exit status or error message that is passed to the constructor. 469 (Defaults to ``None``.) 470 471 472.. exception:: TypeError 473 474 Raised when an operation or function is applied to an object of inappropriate 475 type. The associated value is a string giving details about the type mismatch. 476 477 This exception may be raised by user code to indicate that an attempted 478 operation on an object is not supported, and is not meant to be. If an object 479 is meant to support a given operation but has not yet provided an 480 implementation, :exc:`NotImplementedError` is the proper exception to raise. 481 482 Passing arguments of the wrong type (e.g. passing a :class:`list` when an 483 :class:`int` is expected) should result in a :exc:`TypeError`, but passing 484 arguments with the wrong value (e.g. a number outside expected boundaries) 485 should result in a :exc:`ValueError`. 486 487.. exception:: UnboundLocalError 488 489 Raised when a reference is made to a local variable in a function or method, but 490 no value has been bound to that variable. This is a subclass of 491 :exc:`NameError`. 492 493 494.. exception:: UnicodeError 495 496 Raised when a Unicode-related encoding or decoding error occurs. It is a 497 subclass of :exc:`ValueError`. 498 499 :exc:`UnicodeError` has attributes that describe the encoding or decoding 500 error. For example, ``err.object[err.start:err.end]`` gives the particular 501 invalid input that the codec failed on. 502 503 .. attribute:: encoding 504 505 The name of the encoding that raised the error. 506 507 .. attribute:: reason 508 509 A string describing the specific codec error. 510 511 .. attribute:: object 512 513 The object the codec was attempting to encode or decode. 514 515 .. attribute:: start 516 517 The first index of invalid data in :attr:`object`. 518 519 .. attribute:: end 520 521 The index after the last invalid data in :attr:`object`. 522 523 524.. exception:: UnicodeEncodeError 525 526 Raised when a Unicode-related error occurs during encoding. It is a subclass of 527 :exc:`UnicodeError`. 528 529 530.. exception:: UnicodeDecodeError 531 532 Raised when a Unicode-related error occurs during decoding. It is a subclass of 533 :exc:`UnicodeError`. 534 535 536.. exception:: UnicodeTranslateError 537 538 Raised when a Unicode-related error occurs during translating. It is a subclass 539 of :exc:`UnicodeError`. 540 541 542.. exception:: ValueError 543 544 Raised when an operation or function receives an argument that has the 545 right type but an inappropriate value, and the situation is not described by a 546 more precise exception such as :exc:`IndexError`. 547 548 549.. exception:: ZeroDivisionError 550 551 Raised when the second argument of a division or modulo operation is zero. The 552 associated value is a string indicating the type of the operands and the 553 operation. 554 555 556The following exceptions are kept for compatibility with previous versions; 557starting from Python 3.3, they are aliases of :exc:`OSError`. 558 559.. exception:: EnvironmentError 560 561.. exception:: IOError 562 563.. exception:: WindowsError 564 565 Only available on Windows. 566 567 568OS exceptions 569^^^^^^^^^^^^^ 570 571The following exceptions are subclasses of :exc:`OSError`, they get raised 572depending on the system error code. 573 574.. exception:: BlockingIOError 575 576 Raised when an operation would block on an object (e.g. socket) set 577 for non-blocking operation. 578 Corresponds to :c:data:`errno` ``EAGAIN``, ``EALREADY``, 579 ``EWOULDBLOCK`` and ``EINPROGRESS``. 580 581 In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have 582 one more attribute: 583 584 .. attribute:: characters_written 585 586 An integer containing the number of characters written to the stream 587 before it blocked. This attribute is available when using the 588 buffered I/O classes from the :mod:`io` module. 589 590.. exception:: ChildProcessError 591 592 Raised when an operation on a child process failed. 593 Corresponds to :c:data:`errno` ``ECHILD``. 594 595.. exception:: ConnectionError 596 597 A base class for connection-related issues. 598 599 Subclasses are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, 600 :exc:`ConnectionRefusedError` and :exc:`ConnectionResetError`. 601 602.. exception:: BrokenPipeError 603 604 A subclass of :exc:`ConnectionError`, raised when trying to write on a 605 pipe while the other end has been closed, or trying to write on a socket 606 which has been shutdown for writing. 607 Corresponds to :c:data:`errno` ``EPIPE`` and ``ESHUTDOWN``. 608 609.. exception:: ConnectionAbortedError 610 611 A subclass of :exc:`ConnectionError`, raised when a connection attempt 612 is aborted by the peer. 613 Corresponds to :c:data:`errno` ``ECONNABORTED``. 614 615.. exception:: ConnectionRefusedError 616 617 A subclass of :exc:`ConnectionError`, raised when a connection attempt 618 is refused by the peer. 619 Corresponds to :c:data:`errno` ``ECONNREFUSED``. 620 621.. exception:: ConnectionResetError 622 623 A subclass of :exc:`ConnectionError`, raised when a connection is 624 reset by the peer. 625 Corresponds to :c:data:`errno` ``ECONNRESET``. 626 627.. exception:: FileExistsError 628 629 Raised when trying to create a file or directory which already exists. 630 Corresponds to :c:data:`errno` ``EEXIST``. 631 632.. exception:: FileNotFoundError 633 634 Raised when a file or directory is requested but doesn't exist. 635 Corresponds to :c:data:`errno` ``ENOENT``. 636 637.. exception:: InterruptedError 638 639 Raised when a system call is interrupted by an incoming signal. 640 Corresponds to :c:data:`errno` :py:data:`~errno.EINTR`. 641 642 .. versionchanged:: 3.5 643 Python now retries system calls when a syscall is interrupted by a 644 signal, except if the signal handler raises an exception (see :pep:`475` 645 for the rationale), instead of raising :exc:`InterruptedError`. 646 647.. exception:: IsADirectoryError 648 649 Raised when a file operation (such as :func:`os.remove`) is requested 650 on a directory. 651 Corresponds to :c:data:`errno` ``EISDIR``. 652 653.. exception:: NotADirectoryError 654 655 Raised when a directory operation (such as :func:`os.listdir`) is requested 656 on something which is not a directory. 657 Corresponds to :c:data:`errno` ``ENOTDIR``. 658 659.. exception:: PermissionError 660 661 Raised when trying to run an operation without the adequate access 662 rights - for example filesystem permissions. 663 Corresponds to :c:data:`errno` ``EACCES`` and ``EPERM``. 664 665.. exception:: ProcessLookupError 666 667 Raised when a given process doesn't exist. 668 Corresponds to :c:data:`errno` ``ESRCH``. 669 670.. exception:: TimeoutError 671 672 Raised when a system function timed out at the system level. 673 Corresponds to :c:data:`errno` ``ETIMEDOUT``. 674 675.. versionadded:: 3.3 676 All the above :exc:`OSError` subclasses were added. 677 678 679.. seealso:: 680 681 :pep:`3151` - Reworking the OS and IO exception hierarchy 682 683 684.. _warning-categories-as-exceptions: 685 686Warnings 687-------- 688 689The following exceptions are used as warning categories; see the 690:ref:`warning-categories` documentation for more details. 691 692.. exception:: Warning 693 694 Base class for warning categories. 695 696 697.. exception:: UserWarning 698 699 Base class for warnings generated by user code. 700 701 702.. exception:: DeprecationWarning 703 704 Base class for warnings about deprecated features when those warnings are 705 intended for other Python developers. 706 707 708.. exception:: PendingDeprecationWarning 709 710 Base class for warnings about features which are obsolete and 711 expected to be deprecated in the future, but are not deprecated 712 at the moment. 713 714 This class is rarely used as emitting a warning about a possible 715 upcoming deprecation is unusual, and :exc:`DeprecationWarning` 716 is preferred for already active deprecations. 717 718 719.. exception:: SyntaxWarning 720 721 Base class for warnings about dubious syntax. 722 723 724.. exception:: RuntimeWarning 725 726 Base class for warnings about dubious runtime behavior. 727 728 729.. exception:: FutureWarning 730 731 Base class for warnings about deprecated features when those warnings are 732 intended for end users of applications that are written in Python. 733 734 735.. exception:: ImportWarning 736 737 Base class for warnings about probable mistakes in module imports. 738 739 740.. exception:: UnicodeWarning 741 742 Base class for warnings related to Unicode. 743 744 745.. exception:: BytesWarning 746 747 Base class for warnings related to :class:`bytes` and :class:`bytearray`. 748 749 750.. exception:: ResourceWarning 751 752 Base class for warnings related to resource usage. Ignored by the default 753 warning filters. 754 755 .. versionadded:: 3.2 756 757 758 759Exception hierarchy 760------------------- 761 762The class hierarchy for built-in exceptions is: 763 764.. literalinclude:: ../../Lib/test/exception_hierarchy.txt 765