<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Built-in Exceptions — Python 3.7.4 documentation</title> <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/language_data.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 3.7.4 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="next" title="Text Processing Services" href="text.html" /> <link rel="prev" title="Built-in Types" href="stdtypes.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="https://docs.python.org/3/library/exceptions.html" /> <script type="text/javascript" src="../_static/copybutton.js"></script> <script type="text/javascript" src="../_static/switchers.js"></script> <style> @media only screen { table.full-width-table { width: 100%; } } </style> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="text.html" title="Text Processing Services" accesskey="N">next</a> |</li> <li class="right" > <a href="stdtypes.html" title="Built-in Types" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <span class="language_switcher_placeholder">en</span> <span class="version_switcher_placeholder">3.7.4</span> <a href="../index.html">Documentation </a> » </li> <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Python Standard Library</a> »</li> <li class="right"> <div class="inline-search" style="display: none" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="Quick search" type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('.inline-search').show(0);</script> | </li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="built-in-exceptions"> <span id="bltin-exceptions"></span><h1>Built-in Exceptions<a class="headerlink" href="#built-in-exceptions" title="Permalink to this headline">¶</a></h1> <p id="index-0">In Python, all exceptions must be instances of a class that derives from <a class="reference internal" href="#BaseException" title="BaseException"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseException</span></code></a>. In a <a class="reference internal" href="../reference/compound_stmts.html#try"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> statement with an <a class="reference internal" href="../reference/compound_stmts.html#except"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">except</span></code></a> clause that mentions a particular class, that clause also handles any exception classes derived from that class (but not exception classes from which <em>it</em> is derived). Two exception classes that are not related via subclassing are never equivalent, even if they have the same name.</p> <p id="index-1">The built-in exceptions listed below can be generated by the interpreter or built-in functions. Except where mentioned, they have an “associated value” indicating the detailed cause of the error. This may be a string or a tuple of several items of information (e.g., an error code and a string explaining the code). The associated value is usually passed as arguments to the exception class’s constructor.</p> <p>User code can raise built-in exceptions. This can be used to test an exception handler or to report an error condition “just like” the situation in which the interpreter raises the same exception; but beware that there is nothing to prevent user code from raising an inappropriate error.</p> <p>The built-in exception classes can be subclassed to define new exceptions; programmers are encouraged to derive new exceptions from the <a class="reference internal" href="#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a> class or one of its subclasses, and not from <a class="reference internal" href="#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a>. More information on defining exceptions is available in the Python Tutorial under <a class="reference internal" href="../tutorial/errors.html#tut-userexceptions"><span class="std std-ref">User-defined Exceptions</span></a>.</p> <p>When raising (or re-raising) an exception in an <a class="reference internal" href="../reference/compound_stmts.html#except"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">except</span></code></a> or <a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a> clause <code class="xref py py-attr docutils literal notranslate"><span class="pre">__context__</span></code> is automatically set to the last exception caught; if the new exception is not handled the traceback that is eventually displayed will include the originating exception(s) and the final exception.</p> <p>When raising a new exception (rather than using a bare <code class="docutils literal notranslate"><span class="pre">raise</span></code> to re-raise the exception currently being handled), the implicit exception context can be supplemented with an explicit cause by using <a class="reference internal" href="../reference/simple_stmts.html#from"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">from</span></code></a> with <a class="reference internal" href="../reference/simple_stmts.html#raise"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">raise</span></code></a>:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">raise</span> <span class="n">new_exc</span> <span class="kn">from</span> <span class="nn">original_exc</span> </pre></div> </div> <p>The expression following <a class="reference internal" href="../reference/simple_stmts.html#from"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">from</span></code></a> must be an exception or <code class="docutils literal notranslate"><span class="pre">None</span></code>. It will be set as <code class="xref py py-attr docutils literal notranslate"><span class="pre">__cause__</span></code> on the raised exception. Setting <code class="xref py py-attr docutils literal notranslate"><span class="pre">__cause__</span></code> also implicitly sets the <code class="xref py py-attr docutils literal notranslate"><span class="pre">__suppress_context__</span></code> attribute to <code class="docutils literal notranslate"><span class="pre">True</span></code>, so that using <code class="docutils literal notranslate"><span class="pre">raise</span> <span class="pre">new_exc</span> <span class="pre">from</span> <span class="pre">None</span></code> effectively replaces the old exception with the new one for display purposes (e.g. converting <a class="reference internal" href="#KeyError" title="KeyError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a> to <a class="reference internal" href="#AttributeError" title="AttributeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code></a>), while leaving the old exception available in <code class="xref py py-attr docutils literal notranslate"><span class="pre">__context__</span></code> for introspection when debugging.</p> <p>The default traceback display code shows these chained exceptions in addition to the traceback for the exception itself. An explicitly chained exception in <code class="xref py py-attr docutils literal notranslate"><span class="pre">__cause__</span></code> is always shown when present. An implicitly chained exception in <code class="xref py py-attr docutils literal notranslate"><span class="pre">__context__</span></code> is shown only if <code class="xref py py-attr docutils literal notranslate"><span class="pre">__cause__</span></code> is <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">__suppress_context__</span></code> is false.</p> <p>In either case, the exception itself is always shown after any chained exceptions so that the final line of the traceback always shows the last exception that was raised.</p> <div class="section" id="base-classes"> <h2>Base classes<a class="headerlink" href="#base-classes" title="Permalink to this headline">¶</a></h2> <p>The following exceptions are used mostly as base classes for other exceptions.</p> <dl class="exception"> <dt id="BaseException"> <em class="property">exception </em><code class="descname">BaseException</code><a class="headerlink" href="#BaseException" title="Permalink to this definition">¶</a></dt> <dd><p>The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that, use <a class="reference internal" href="#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a>). If <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-func docutils literal notranslate"><span class="pre">str()</span></code></a> is called on an instance of this class, the representation of the argument(s) to the instance are returned, or the empty string when there were no arguments.</p> <dl class="attribute"> <dt id="BaseException.args"> <code class="descname">args</code><a class="headerlink" href="#BaseException.args" title="Permalink to this definition">¶</a></dt> <dd><p>The tuple of arguments given to the exception constructor. Some built-in exceptions (like <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>) expect a certain number of arguments and assign a special meaning to the elements of this tuple, while others are usually called only with a single string giving an error message.</p> </dd></dl> <dl class="method"> <dt id="BaseException.with_traceback"> <code class="descname">with_traceback</code><span class="sig-paren">(</span><em>tb</em><span class="sig-paren">)</span><a class="headerlink" href="#BaseException.with_traceback" title="Permalink to this definition">¶</a></dt> <dd><p>This method sets <em>tb</em> as the new traceback for the exception and returns the exception object. It is usually used in exception handling code like this:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span> <span class="o">...</span> <span class="k">except</span> <span class="n">SomeException</span><span class="p">:</span> <span class="n">tb</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span> <span class="k">raise</span> <span class="n">OtherException</span><span class="p">(</span><span class="o">...</span><span class="p">)</span><span class="o">.</span><span class="n">with_traceback</span><span class="p">(</span><span class="n">tb</span><span class="p">)</span> </pre></div> </div> </dd></dl> </dd></dl> <dl class="exception"> <dt id="Exception"> <em class="property">exception </em><code class="descname">Exception</code><a class="headerlink" href="#Exception" title="Permalink to this definition">¶</a></dt> <dd><p>All built-in, non-system-exiting exceptions are derived from this class. All user-defined exceptions should also be derived from this class.</p> </dd></dl> <dl class="exception"> <dt id="ArithmeticError"> <em class="property">exception </em><code class="descname">ArithmeticError</code><a class="headerlink" href="#ArithmeticError" title="Permalink to this definition">¶</a></dt> <dd><p>The base class for those built-in exceptions that are raised for various arithmetic errors: <a class="reference internal" href="#OverflowError" title="OverflowError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OverflowError</span></code></a>, <a class="reference internal" href="#ZeroDivisionError" title="ZeroDivisionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ZeroDivisionError</span></code></a>, <a class="reference internal" href="#FloatingPointError" title="FloatingPointError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FloatingPointError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="BufferError"> <em class="property">exception </em><code class="descname">BufferError</code><a class="headerlink" href="#BufferError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a <a class="reference internal" href="../c-api/buffer.html#bufferobjects"><span class="std std-ref">buffer</span></a> related operation cannot be performed.</p> </dd></dl> <dl class="exception"> <dt id="LookupError"> <em class="property">exception </em><code class="descname">LookupError</code><a class="headerlink" href="#LookupError" title="Permalink to this definition">¶</a></dt> <dd><p>The base class for the exceptions that are raised when a key or index used on a mapping or sequence is invalid: <a class="reference internal" href="#IndexError" title="IndexError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a>, <a class="reference internal" href="#KeyError" title="KeyError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a>. This can be raised directly by <a class="reference internal" href="codecs.html#codecs.lookup" title="codecs.lookup"><code class="xref py py-func docutils literal notranslate"><span class="pre">codecs.lookup()</span></code></a>.</p> </dd></dl> </div> <div class="section" id="concrete-exceptions"> <h2>Concrete exceptions<a class="headerlink" href="#concrete-exceptions" title="Permalink to this headline">¶</a></h2> <p>The following exceptions are the exceptions that are usually raised.</p> <dl class="exception"> <dt id="AssertionError"> <em class="property">exception </em><code class="descname">AssertionError</code><a class="headerlink" href="#AssertionError" title="Permalink to this definition">¶</a></dt> <dd><p id="index-2">Raised when an <a class="reference internal" href="../reference/simple_stmts.html#assert"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">assert</span></code></a> statement fails.</p> </dd></dl> <dl class="exception"> <dt id="AttributeError"> <em class="property">exception </em><code class="descname">AttributeError</code><a class="headerlink" href="#AttributeError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an attribute reference (see <a class="reference internal" href="../reference/expressions.html#attribute-references"><span class="std std-ref">Attribute references</span></a>) or assignment fails. (When an object does not support attribute references or attribute assignments at all, <a class="reference internal" href="#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> is raised.)</p> </dd></dl> <dl class="exception"> <dt id="EOFError"> <em class="property">exception </em><code class="descname">EOFError</code><a class="headerlink" href="#EOFError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the <a class="reference internal" href="functions.html#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a> function hits an end-of-file condition (EOF) without reading any data. (N.B.: the <code class="xref py py-meth docutils literal notranslate"><span class="pre">io.IOBase.read()</span></code> and <a class="reference internal" href="io.html#io.IOBase.readline" title="io.IOBase.readline"><code class="xref py py-meth docutils literal notranslate"><span class="pre">io.IOBase.readline()</span></code></a> methods return an empty string when they hit EOF.)</p> </dd></dl> <dl class="exception"> <dt id="FloatingPointError"> <em class="property">exception </em><code class="descname">FloatingPointError</code><a class="headerlink" href="#FloatingPointError" title="Permalink to this definition">¶</a></dt> <dd><p>Not currently used.</p> </dd></dl> <dl class="exception"> <dt id="GeneratorExit"> <em class="property">exception </em><code class="descname">GeneratorExit</code><a class="headerlink" href="#GeneratorExit" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a <a class="reference internal" href="../glossary.html#term-generator"><span class="xref std std-term">generator</span></a> or <a class="reference internal" href="../glossary.html#term-coroutine"><span class="xref std std-term">coroutine</span></a> is closed; see <a class="reference internal" href="../reference/expressions.html#generator.close" title="generator.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">generator.close()</span></code></a> and <a class="reference internal" href="../reference/datamodel.html#coroutine.close" title="coroutine.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">coroutine.close()</span></code></a>. It directly inherits from <a class="reference internal" href="#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a> instead of <a class="reference internal" href="#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a> since it is technically not an error.</p> </dd></dl> <dl class="exception"> <dt id="ImportError"> <em class="property">exception </em><code class="descname">ImportError</code><a class="headerlink" href="#ImportError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> statement has troubles trying to load a module. Also raised when the “from list” in <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">...</span> <span class="pre">import</span></code> has a name that cannot be found.</p> <p>The <code class="xref py py-attr docutils literal notranslate"><span class="pre">name</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">path</span></code> attributes can be set using keyword-only arguments to the constructor. When set they represent the name of the module that was attempted to be imported and the path to any file which triggered the exception, respectively.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.3: </span>Added the <code class="xref py py-attr docutils literal notranslate"><span class="pre">name</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">path</span></code> attributes.</p> </div> </dd></dl> <dl class="exception"> <dt id="ModuleNotFoundError"> <em class="property">exception </em><code class="descname">ModuleNotFoundError</code><a class="headerlink" href="#ModuleNotFoundError" title="Permalink to this definition">¶</a></dt> <dd><p>A subclass of <a class="reference internal" href="#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> which is raised by <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> when a module could not be located. It is also raised when <code class="docutils literal notranslate"><span class="pre">None</span></code> is found in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.modules</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.6.</span></p> </div> </dd></dl> <dl class="exception"> <dt id="IndexError"> <em class="property">exception </em><code class="descname">IndexError</code><a class="headerlink" href="#IndexError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a sequence subscript is out of range. (Slice indices are silently truncated to fall in the allowed range; if an index is not an integer, <a class="reference internal" href="#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> is raised.)</p> </dd></dl> <dl class="exception"> <dt id="KeyError"> <em class="property">exception </em><code class="descname">KeyError</code><a class="headerlink" href="#KeyError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a mapping (dictionary) key is not found in the set of existing keys.</p> </dd></dl> <dl class="exception"> <dt id="KeyboardInterrupt"> <em class="property">exception </em><code class="descname">KeyboardInterrupt</code><a class="headerlink" href="#KeyboardInterrupt" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the user hits the interrupt key (normally <kbd class="kbd docutils literal notranslate">Control-C</kbd> or <kbd class="kbd docutils literal notranslate">Delete</kbd>). During execution, a check for interrupts is made regularly. The exception inherits from <a class="reference internal" href="#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a> so as to not be accidentally caught by code that catches <a class="reference internal" href="#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a> and thus prevent the interpreter from exiting.</p> </dd></dl> <dl class="exception"> <dt id="MemoryError"> <em class="property">exception </em><code class="descname">MemoryError</code><a class="headerlink" href="#MemoryError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an operation runs out of memory but the situation may still be rescued (by deleting some objects). The associated value is a string indicating what kind of (internal) operation ran out of memory. Note that because of the underlying memory management architecture (C’s <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> function), the interpreter may not always be able to completely recover from this situation; it nevertheless raises an exception so that a stack traceback can be printed, in case a run-away program was the cause.</p> </dd></dl> <dl class="exception"> <dt id="NameError"> <em class="property">exception </em><code class="descname">NameError</code><a class="headerlink" href="#NameError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a local or global name is not found. This applies only to unqualified names. The associated value is an error message that includes the name that could not be found.</p> </dd></dl> <dl class="exception"> <dt id="NotImplementedError"> <em class="property">exception </em><code class="descname">NotImplementedError</code><a class="headerlink" href="#NotImplementedError" title="Permalink to this definition">¶</a></dt> <dd><p>This exception is derived from <a class="reference internal" href="#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>. In user defined base classes, abstract methods should raise this exception when they require derived classes to override the method, or while the class is being developed to indicate that the real implementation still needs to be added.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>It should not be used to indicate that an operator or method is not meant to be supported at all – in that case either leave the operator / method undefined or, if a subclass, set it to <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-data docutils literal notranslate"><span class="pre">None</span></code></a>.</p> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p><code class="docutils literal notranslate"><span class="pre">NotImplementedError</span></code> and <code class="docutils literal notranslate"><span class="pre">NotImplemented</span></code> are not interchangeable, even though they have similar names and purposes. See <a class="reference internal" href="constants.html#NotImplemented" title="NotImplemented"><code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code></a> for details on when to use it.</p> </div> </dd></dl> <dl class="exception"> <dt id="OSError"> <em class="property">exception </em><code class="descname">OSError</code><span class="sig-paren">(</span><span class="optional">[</span><em>arg</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#OSError" title="Permalink to this definition">¶</a></dt> <dt> <em class="property">exception </em><code class="descname">OSError</code><span class="sig-paren">(</span><em>errno</em>, <em>strerror</em><span class="optional">[</span>, <em>filename</em><span class="optional">[</span>, <em>winerror</em><span class="optional">[</span>, <em>filename2</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span></dt> <dd><p id="index-3">This exception is raised when a system function returns a system-related error, including I/O failures such as “file not found” or “disk full” (not for illegal argument types or other incidental errors).</p> <p>The second form of the constructor sets the corresponding attributes, described below. The attributes default to <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> if not specified. For backwards compatibility, if three arguments are passed, the <a class="reference internal" href="#BaseException.args" title="BaseException.args"><code class="xref py py-attr docutils literal notranslate"><span class="pre">args</span></code></a> attribute contains only a 2-tuple of the first two constructor arguments.</p> <p>The constructor often actually returns a subclass of <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>, as described in <a class="reference internal" href="#os-exceptions">OS exceptions</a> below. The particular subclass depends on the final <a class="reference internal" href="#OSError.errno" title="OSError.errno"><code class="xref py py-attr docutils literal notranslate"><span class="pre">errno</span></code></a> value. This behaviour only occurs when constructing <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> directly or via an alias, and is not inherited when subclassing.</p> <dl class="attribute"> <dt id="OSError.errno"> <code class="descname">errno</code><a class="headerlink" href="#OSError.errno" title="Permalink to this definition">¶</a></dt> <dd><p>A numeric error code from the C variable <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code>.</p> </dd></dl> <dl class="attribute"> <dt id="OSError.winerror"> <code class="descname">winerror</code><a class="headerlink" href="#OSError.winerror" title="Permalink to this definition">¶</a></dt> <dd><p>Under Windows, this gives you the native Windows error code. The <a class="reference internal" href="#OSError.errno" title="OSError.errno"><code class="xref py py-attr docutils literal notranslate"><span class="pre">errno</span></code></a> attribute is then an approximate translation, in POSIX terms, of that native error code.</p> <p>Under Windows, if the <em>winerror</em> constructor argument is an integer, the <a class="reference internal" href="#OSError.errno" title="OSError.errno"><code class="xref py py-attr docutils literal notranslate"><span class="pre">errno</span></code></a> attribute is determined from the Windows error code, and the <em>errno</em> argument is ignored. On other platforms, the <em>winerror</em> argument is ignored, and the <a class="reference internal" href="#OSError.winerror" title="OSError.winerror"><code class="xref py py-attr docutils literal notranslate"><span class="pre">winerror</span></code></a> attribute does not exist.</p> </dd></dl> <dl class="attribute"> <dt id="OSError.strerror"> <code class="descname">strerror</code><a class="headerlink" href="#OSError.strerror" title="Permalink to this definition">¶</a></dt> <dd><p>The corresponding error message, as provided by the operating system. It is formatted by the C functions <code class="xref c c-func docutils literal notranslate"><span class="pre">perror()</span></code> under POSIX, and <code class="xref c c-func docutils literal notranslate"><span class="pre">FormatMessage()</span></code> under Windows.</p> </dd></dl> <dl class="attribute"> <dt id="OSError.filename"> <code class="descname">filename</code><a class="headerlink" href="#OSError.filename" title="Permalink to this definition">¶</a></dt> <dt id="OSError.filename2"> <code class="descname">filename2</code><a class="headerlink" href="#OSError.filename2" title="Permalink to this definition">¶</a></dt> <dd><p>For exceptions that involve a file system path (such as <a class="reference internal" href="functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> or <a class="reference internal" href="os.html#os.unlink" title="os.unlink"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.unlink()</span></code></a>), <a class="reference internal" href="#OSError.filename" title="OSError.filename"><code class="xref py py-attr docutils literal notranslate"><span class="pre">filename</span></code></a> is the file name passed to the function. For functions that involve two file system paths (such as <a class="reference internal" href="os.html#os.rename" title="os.rename"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.rename()</span></code></a>), <a class="reference internal" href="#OSError.filename2" title="OSError.filename2"><code class="xref py py-attr docutils literal notranslate"><span class="pre">filename2</span></code></a> corresponds to the second file name passed to the function.</p> </dd></dl> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.3: </span><a class="reference internal" href="#EnvironmentError" title="EnvironmentError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">EnvironmentError</span></code></a>, <a class="reference internal" href="#IOError" title="IOError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IOError</span></code></a>, <a class="reference internal" href="#WindowsError" title="WindowsError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">WindowsError</span></code></a>, <a class="reference internal" href="socket.html#socket.error" title="socket.error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">socket.error</span></code></a>, <a class="reference internal" href="select.html#select.error" title="select.error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">select.error</span></code></a> and <code class="xref py py-exc docutils literal notranslate"><span class="pre">mmap.error</span></code> have been merged into <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>, and the constructor may return a subclass.</p> </div> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.4: </span>The <a class="reference internal" href="#OSError.filename" title="OSError.filename"><code class="xref py py-attr docutils literal notranslate"><span class="pre">filename</span></code></a> attribute is now the original file name passed to the function, instead of the name encoded to or decoded from the filesystem encoding. Also, the <em>filename2</em> constructor argument and attribute was added.</p> </div> </dd></dl> <dl class="exception"> <dt id="OverflowError"> <em class="property">exception </em><code class="descname">OverflowError</code><a class="headerlink" href="#OverflowError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the result of an arithmetic operation is too large to be represented. This cannot occur for integers (which would rather raise <a class="reference internal" href="#MemoryError" title="MemoryError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">MemoryError</span></code></a> than give up). However, for historical reasons, OverflowError is sometimes raised for integers that are outside a required range. Because of the lack of standardization of floating point exception handling in C, most floating point operations are not checked.</p> </dd></dl> <dl class="exception"> <dt id="RecursionError"> <em class="property">exception </em><code class="descname">RecursionError</code><a class="headerlink" href="#RecursionError" title="Permalink to this definition">¶</a></dt> <dd><p>This exception is derived from <a class="reference internal" href="#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>. It is raised when the interpreter detects that the maximum recursion depth (see <a class="reference internal" href="sys.html#sys.getrecursionlimit" title="sys.getrecursionlimit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getrecursionlimit()</span></code></a>) is exceeded.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.5: </span>Previously, a plain <a class="reference internal" href="#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> was raised.</p> </div> </dd></dl> <dl class="exception"> <dt id="ReferenceError"> <em class="property">exception </em><code class="descname">ReferenceError</code><a class="headerlink" href="#ReferenceError" title="Permalink to this definition">¶</a></dt> <dd><p>This exception is raised when a weak reference proxy, created by the <a class="reference internal" href="weakref.html#weakref.proxy" title="weakref.proxy"><code class="xref py py-func docutils literal notranslate"><span class="pre">weakref.proxy()</span></code></a> function, is used to access an attribute of the referent after it has been garbage collected. For more information on weak references, see the <a class="reference internal" href="weakref.html#module-weakref" title="weakref: Support for weak references and weak dictionaries."><code class="xref py py-mod docutils literal notranslate"><span class="pre">weakref</span></code></a> module.</p> </dd></dl> <dl class="exception"> <dt id="RuntimeError"> <em class="property">exception </em><code class="descname">RuntimeError</code><a class="headerlink" href="#RuntimeError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an error is detected that doesn’t fall in any of the other categories. The associated value is a string indicating what precisely went wrong.</p> </dd></dl> <dl class="exception"> <dt id="StopIteration"> <em class="property">exception </em><code class="descname">StopIteration</code><a class="headerlink" href="#StopIteration" title="Permalink to this definition">¶</a></dt> <dd><p>Raised by built-in function <a class="reference internal" href="functions.html#next" title="next"><code class="xref py py-func docutils literal notranslate"><span class="pre">next()</span></code></a> and an <a class="reference internal" href="../glossary.html#term-iterator"><span class="xref std std-term">iterator</span></a>’s <a class="reference internal" href="stdtypes.html#iterator.__next__" title="iterator.__next__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__next__()</span></code></a> method to signal that there are no further items produced by the iterator.</p> <p>The exception object has a single attribute <code class="xref py py-attr docutils literal notranslate"><span class="pre">value</span></code>, which is given as an argument when constructing the exception, and defaults to <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a>.</p> <p>When a <a class="reference internal" href="../glossary.html#term-generator"><span class="xref std std-term">generator</span></a> or <a class="reference internal" href="../glossary.html#term-coroutine"><span class="xref std std-term">coroutine</span></a> function returns, a new <a class="reference internal" href="#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> instance is raised, and the value returned by the function is used as the <code class="xref py py-attr docutils literal notranslate"><span class="pre">value</span></code> parameter to the constructor of the exception.</p> <p>If a generator code directly or indirectly raises <a class="reference internal" href="#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a>, it is converted into a <a class="reference internal" href="#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> (retaining the <a class="reference internal" href="#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> as the new exception’s cause).</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.3: </span>Added <code class="docutils literal notranslate"><span class="pre">value</span></code> attribute and the ability for generator functions to use it to return a value.</p> </div> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.5: </span>Introduced the RuntimeError transformation via <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">__future__</span> <span class="pre">import</span> <span class="pre">generator_stop</span></code>, see <span class="target" id="index-4"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0479"><strong>PEP 479</strong></a>.</p> </div> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.7: </span>Enable <span class="target" id="index-5"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0479"><strong>PEP 479</strong></a> for all code by default: a <a class="reference internal" href="#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> error raised in a generator is transformed into a <a class="reference internal" href="#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>.</p> </div> </dd></dl> <dl class="exception"> <dt id="StopAsyncIteration"> <em class="property">exception </em><code class="descname">StopAsyncIteration</code><a class="headerlink" href="#StopAsyncIteration" title="Permalink to this definition">¶</a></dt> <dd><p>Must be raised by <a class="reference internal" href="../reference/datamodel.html#object.__anext__" title="object.__anext__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__anext__()</span></code></a> method of an <a class="reference internal" href="../glossary.html#term-asynchronous-iterator"><span class="xref std std-term">asynchronous iterator</span></a> object to stop the iteration.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.5.</span></p> </div> </dd></dl> <dl class="exception"> <dt id="SyntaxError"> <em class="property">exception </em><code class="descname">SyntaxError</code><a class="headerlink" href="#SyntaxError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the parser encounters a syntax error. This may occur in an <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> statement, in a call to the built-in functions <a class="reference internal" href="functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a> or <a class="reference internal" href="functions.html#eval" title="eval"><code class="xref py py-func docutils literal notranslate"><span class="pre">eval()</span></code></a>, or when reading the initial script or standard input (also interactively).</p> <p>Instances of this class have attributes <code class="xref py py-attr docutils literal notranslate"><span class="pre">filename</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">lineno</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">offset</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">text</span></code> for easier access to the details. <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-func docutils literal notranslate"><span class="pre">str()</span></code></a> of the exception instance returns only the message.</p> </dd></dl> <dl class="exception"> <dt id="IndentationError"> <em class="property">exception </em><code class="descname">IndentationError</code><a class="headerlink" href="#IndentationError" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for syntax errors related to incorrect indentation. This is a subclass of <a class="reference internal" href="#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="TabError"> <em class="property">exception </em><code class="descname">TabError</code><a class="headerlink" href="#TabError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when indentation contains an inconsistent use of tabs and spaces. This is a subclass of <a class="reference internal" href="#IndentationError" title="IndentationError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndentationError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="SystemError"> <em class="property">exception </em><code class="descname">SystemError</code><a class="headerlink" href="#SystemError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the interpreter finds an internal error, but the situation does not look so serious to cause it to abandon all hope. The associated value is a string indicating what went wrong (in low-level terms).</p> <p>You should report this to the author or maintainer of your Python interpreter. Be sure to report the version of the Python interpreter (<code class="docutils literal notranslate"><span class="pre">sys.version</span></code>; it is also printed at the start of an interactive Python session), the exact error message (the exception’s associated value) and if possible the source of the program that triggered the error.</p> </dd></dl> <dl class="exception"> <dt id="SystemExit"> <em class="property">exception </em><code class="descname">SystemExit</code><a class="headerlink" href="#SystemExit" title="Permalink to this definition">¶</a></dt> <dd><p>This exception is raised by the <a class="reference internal" href="sys.html#sys.exit" title="sys.exit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exit()</span></code></a> function. It inherits from <a class="reference internal" href="#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a> instead of <a class="reference internal" href="#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a> so that it is not accidentally caught by code that catches <a class="reference internal" href="#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a>. This allows the exception to properly propagate up and cause the interpreter to exit. When it is not handled, the Python interpreter exits; no stack traceback is printed. The constructor accepts the same optional argument passed to <a class="reference internal" href="sys.html#sys.exit" title="sys.exit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exit()</span></code></a>. If the value is an integer, it specifies the system exit status (passed to C’s <code class="xref c c-func docutils literal notranslate"><span class="pre">exit()</span></code> function); if it is <code class="docutils literal notranslate"><span class="pre">None</span></code>, the exit status is zero; if it has another type (such as a string), the object’s value is printed and the exit status is one.</p> <p>A call to <a class="reference internal" href="sys.html#sys.exit" title="sys.exit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exit()</span></code></a> is translated into an exception so that clean-up handlers (<a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a> clauses of <a class="reference internal" href="../reference/compound_stmts.html#try"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> statements) can be executed, and so that a debugger can execute a script without running the risk of losing control. The <a class="reference internal" href="os.html#os._exit" title="os._exit"><code class="xref py py-func docutils literal notranslate"><span class="pre">os._exit()</span></code></a> function can be used if it is absolutely positively necessary to exit immediately (for example, in the child process after a call to <a class="reference internal" href="os.html#os.fork" title="os.fork"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fork()</span></code></a>).</p> <dl class="attribute"> <dt id="SystemExit.code"> <code class="descname">code</code><a class="headerlink" href="#SystemExit.code" title="Permalink to this definition">¶</a></dt> <dd><p>The exit status or error message that is passed to the constructor. (Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>.)</p> </dd></dl> </dd></dl> <dl class="exception"> <dt id="TypeError"> <em class="property">exception </em><code class="descname">TypeError</code><a class="headerlink" href="#TypeError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch.</p> <p>This exception may be raised by user code to indicate that an attempted operation on an object is not supported, and is not meant to be. If an object is meant to support a given operation but has not yet provided an implementation, <a class="reference internal" href="#NotImplementedError" title="NotImplementedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotImplementedError</span></code></a> is the proper exception to raise.</p> <p>Passing arguments of the wrong type (e.g. passing a <a class="reference internal" href="stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> when an <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> is expected) should result in a <a class="reference internal" href="#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a <a class="reference internal" href="#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="UnboundLocalError"> <em class="property">exception </em><code class="descname">UnboundLocalError</code><a class="headerlink" href="#UnboundLocalError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable. This is a subclass of <a class="reference internal" href="#NameError" title="NameError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NameError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="UnicodeError"> <em class="property">exception </em><code class="descname">UnicodeError</code><a class="headerlink" href="#UnicodeError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of <a class="reference internal" href="#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>.</p> <p><a class="reference internal" href="#UnicodeError" title="UnicodeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">UnicodeError</span></code></a> has attributes that describe the encoding or decoding error. For example, <code class="docutils literal notranslate"><span class="pre">err.object[err.start:err.end]</span></code> gives the particular invalid input that the codec failed on.</p> <dl class="attribute"> <dt id="UnicodeError.encoding"> <code class="descname">encoding</code><a class="headerlink" href="#UnicodeError.encoding" title="Permalink to this definition">¶</a></dt> <dd><p>The name of the encoding that raised the error.</p> </dd></dl> <dl class="attribute"> <dt id="UnicodeError.reason"> <code class="descname">reason</code><a class="headerlink" href="#UnicodeError.reason" title="Permalink to this definition">¶</a></dt> <dd><p>A string describing the specific codec error.</p> </dd></dl> <dl class="attribute"> <dt id="UnicodeError.object"> <code class="descname">object</code><a class="headerlink" href="#UnicodeError.object" title="Permalink to this definition">¶</a></dt> <dd><p>The object the codec was attempting to encode or decode.</p> </dd></dl> <dl class="attribute"> <dt id="UnicodeError.start"> <code class="descname">start</code><a class="headerlink" href="#UnicodeError.start" title="Permalink to this definition">¶</a></dt> <dd><p>The first index of invalid data in <a class="reference internal" href="functions.html#object" title="object"><code class="xref py py-attr docutils literal notranslate"><span class="pre">object</span></code></a>.</p> </dd></dl> <dl class="attribute"> <dt id="UnicodeError.end"> <code class="descname">end</code><a class="headerlink" href="#UnicodeError.end" title="Permalink to this definition">¶</a></dt> <dd><p>The index after the last invalid data in <a class="reference internal" href="functions.html#object" title="object"><code class="xref py py-attr docutils literal notranslate"><span class="pre">object</span></code></a>.</p> </dd></dl> </dd></dl> <dl class="exception"> <dt id="UnicodeEncodeError"> <em class="property">exception </em><code class="descname">UnicodeEncodeError</code><a class="headerlink" href="#UnicodeEncodeError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a Unicode-related error occurs during encoding. It is a subclass of <a class="reference internal" href="#UnicodeError" title="UnicodeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">UnicodeError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="UnicodeDecodeError"> <em class="property">exception </em><code class="descname">UnicodeDecodeError</code><a class="headerlink" href="#UnicodeDecodeError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a Unicode-related error occurs during decoding. It is a subclass of <a class="reference internal" href="#UnicodeError" title="UnicodeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">UnicodeError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="UnicodeTranslateError"> <em class="property">exception </em><code class="descname">UnicodeTranslateError</code><a class="headerlink" href="#UnicodeTranslateError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a Unicode-related error occurs during translating. It is a subclass of <a class="reference internal" href="#UnicodeError" title="UnicodeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">UnicodeError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="ValueError"> <em class="property">exception </em><code class="descname">ValueError</code><a class="headerlink" href="#ValueError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as <a class="reference internal" href="#IndexError" title="IndexError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="ZeroDivisionError"> <em class="property">exception </em><code class="descname">ZeroDivisionError</code><a class="headerlink" href="#ZeroDivisionError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the second argument of a division or modulo operation is zero. The associated value is a string indicating the type of the operands and the operation.</p> </dd></dl> <p>The following exceptions are kept for compatibility with previous versions; starting from Python 3.3, they are aliases of <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>.</p> <dl class="exception"> <dt id="EnvironmentError"> <em class="property">exception </em><code class="descname">EnvironmentError</code><a class="headerlink" href="#EnvironmentError" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="exception"> <dt id="IOError"> <em class="property">exception </em><code class="descname">IOError</code><a class="headerlink" href="#IOError" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="exception"> <dt id="WindowsError"> <em class="property">exception </em><code class="descname">WindowsError</code><a class="headerlink" href="#WindowsError" title="Permalink to this definition">¶</a></dt> <dd><p>Only available on Windows.</p> </dd></dl> <div class="section" id="os-exceptions"> <h3>OS exceptions<a class="headerlink" href="#os-exceptions" title="Permalink to this headline">¶</a></h3> <p>The following exceptions are subclasses of <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>, they get raised depending on the system error code.</p> <dl class="exception"> <dt id="BlockingIOError"> <em class="property">exception </em><code class="descname">BlockingIOError</code><a class="headerlink" href="#BlockingIOError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an operation would block on an object (e.g. socket) set for non-blocking operation. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">EAGAIN</span></code>, <code class="docutils literal notranslate"><span class="pre">EALREADY</span></code>, <code class="docutils literal notranslate"><span class="pre">EWOULDBLOCK</span></code> and <code class="docutils literal notranslate"><span class="pre">EINPROGRESS</span></code>.</p> <p>In addition to those of <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>, <a class="reference internal" href="#BlockingIOError" title="BlockingIOError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BlockingIOError</span></code></a> can have one more attribute:</p> <dl class="attribute"> <dt id="BlockingIOError.characters_written"> <code class="descname">characters_written</code><a class="headerlink" href="#BlockingIOError.characters_written" title="Permalink to this definition">¶</a></dt> <dd><p>An integer containing the number of characters written to the stream before it blocked. This attribute is available when using the buffered I/O classes from the <a class="reference internal" href="io.html#module-io" title="io: Core tools for working with streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">io</span></code></a> module.</p> </dd></dl> </dd></dl> <dl class="exception"> <dt id="ChildProcessError"> <em class="property">exception </em><code class="descname">ChildProcessError</code><a class="headerlink" href="#ChildProcessError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an operation on a child process failed. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ECHILD</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="ConnectionError"> <em class="property">exception </em><code class="descname">ConnectionError</code><a class="headerlink" href="#ConnectionError" title="Permalink to this definition">¶</a></dt> <dd><p>A base class for connection-related issues.</p> <p>Subclasses are <a class="reference internal" href="#BrokenPipeError" title="BrokenPipeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BrokenPipeError</span></code></a>, <a class="reference internal" href="#ConnectionAbortedError" title="ConnectionAbortedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionAbortedError</span></code></a>, <a class="reference internal" href="#ConnectionRefusedError" title="ConnectionRefusedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionRefusedError</span></code></a> and <a class="reference internal" href="#ConnectionResetError" title="ConnectionResetError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionResetError</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="BrokenPipeError"> <em class="property">exception </em><code class="descname">BrokenPipeError</code><a class="headerlink" href="#BrokenPipeError" title="Permalink to this definition">¶</a></dt> <dd><p>A subclass of <a class="reference internal" href="#ConnectionError" title="ConnectionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionError</span></code></a>, raised when trying to write on a pipe while the other end has been closed, or trying to write on a socket which has been shutdown for writing. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">EPIPE</span></code> and <code class="docutils literal notranslate"><span class="pre">ESHUTDOWN</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="ConnectionAbortedError"> <em class="property">exception </em><code class="descname">ConnectionAbortedError</code><a class="headerlink" href="#ConnectionAbortedError" title="Permalink to this definition">¶</a></dt> <dd><p>A subclass of <a class="reference internal" href="#ConnectionError" title="ConnectionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionError</span></code></a>, raised when a connection attempt is aborted by the peer. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ECONNABORTED</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="ConnectionRefusedError"> <em class="property">exception </em><code class="descname">ConnectionRefusedError</code><a class="headerlink" href="#ConnectionRefusedError" title="Permalink to this definition">¶</a></dt> <dd><p>A subclass of <a class="reference internal" href="#ConnectionError" title="ConnectionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionError</span></code></a>, raised when a connection attempt is refused by the peer. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ECONNREFUSED</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="ConnectionResetError"> <em class="property">exception </em><code class="descname">ConnectionResetError</code><a class="headerlink" href="#ConnectionResetError" title="Permalink to this definition">¶</a></dt> <dd><p>A subclass of <a class="reference internal" href="#ConnectionError" title="ConnectionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionError</span></code></a>, raised when a connection is reset by the peer. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ECONNRESET</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="FileExistsError"> <em class="property">exception </em><code class="descname">FileExistsError</code><a class="headerlink" href="#FileExistsError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when trying to create a file or directory which already exists. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">EEXIST</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="FileNotFoundError"> <em class="property">exception </em><code class="descname">FileNotFoundError</code><a class="headerlink" href="#FileNotFoundError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a file or directory is requested but doesn’t exist. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ENOENT</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="InterruptedError"> <em class="property">exception </em><code class="descname">InterruptedError</code><a class="headerlink" href="#InterruptedError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a system call is interrupted by an incoming signal. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <a class="reference internal" href="errno.html#errno.EINTR" title="errno.EINTR"><code class="xref py py-data docutils literal notranslate"><span class="pre">EINTR</span></code></a>.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.5: </span>Python now retries system calls when a syscall is interrupted by a signal, except if the signal handler raises an exception (see <span class="target" id="index-6"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0475"><strong>PEP 475</strong></a> for the rationale), instead of raising <a class="reference internal" href="#InterruptedError" title="InterruptedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptedError</span></code></a>.</p> </div> </dd></dl> <dl class="exception"> <dt id="IsADirectoryError"> <em class="property">exception </em><code class="descname">IsADirectoryError</code><a class="headerlink" href="#IsADirectoryError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a file operation (such as <a class="reference internal" href="os.html#os.remove" title="os.remove"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.remove()</span></code></a>) is requested on a directory. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">EISDIR</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="NotADirectoryError"> <em class="property">exception </em><code class="descname">NotADirectoryError</code><a class="headerlink" href="#NotADirectoryError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a directory operation (such as <a class="reference internal" href="os.html#os.listdir" title="os.listdir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.listdir()</span></code></a>) is requested on something which is not a directory. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ENOTDIR</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="PermissionError"> <em class="property">exception </em><code class="descname">PermissionError</code><a class="headerlink" href="#PermissionError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when trying to run an operation without the adequate access rights - for example filesystem permissions. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">EACCES</span></code> and <code class="docutils literal notranslate"><span class="pre">EPERM</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="ProcessLookupError"> <em class="property">exception </em><code class="descname">ProcessLookupError</code><a class="headerlink" href="#ProcessLookupError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a given process doesn’t exist. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ESRCH</span></code>.</p> </dd></dl> <dl class="exception"> <dt id="TimeoutError"> <em class="property">exception </em><code class="descname">TimeoutError</code><a class="headerlink" href="#TimeoutError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a system function timed out at the system level. Corresponds to <code class="xref c c-data docutils literal notranslate"><span class="pre">errno</span></code> <code class="docutils literal notranslate"><span class="pre">ETIMEDOUT</span></code>.</p> </dd></dl> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.3: </span>All the above <a class="reference internal" href="#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> subclasses were added.</p> </div> <div class="admonition seealso"> <p class="admonition-title">See also</p> <p><span class="target" id="index-7"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-3151"><strong>PEP 3151</strong></a> - Reworking the OS and IO exception hierarchy</p> </div> </div> </div> <div class="section" id="warnings"> <span id="warning-categories-as-exceptions"></span><h2>Warnings<a class="headerlink" href="#warnings" title="Permalink to this headline">¶</a></h2> <p>The following exceptions are used as warning categories; see the <a class="reference internal" href="warnings.html#warning-categories"><span class="std std-ref">Warning Categories</span></a> documentation for more details.</p> <dl class="exception"> <dt id="Warning"> <em class="property">exception </em><code class="descname">Warning</code><a class="headerlink" href="#Warning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warning categories.</p> </dd></dl> <dl class="exception"> <dt id="UserWarning"> <em class="property">exception </em><code class="descname">UserWarning</code><a class="headerlink" href="#UserWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings generated by user code.</p> </dd></dl> <dl class="exception"> <dt id="DeprecationWarning"> <em class="property">exception </em><code class="descname">DeprecationWarning</code><a class="headerlink" href="#DeprecationWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings about deprecated features when those warnings are intended for other Python developers.</p> </dd></dl> <dl class="exception"> <dt id="PendingDeprecationWarning"> <em class="property">exception </em><code class="descname">PendingDeprecationWarning</code><a class="headerlink" href="#PendingDeprecationWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings about features which are obsolete and expected to be deprecated in the future, but are not deprecated at the moment.</p> <p>This class is rarely used as emitting a warning about a possible upcoming deprecation is unusual, and <a class="reference internal" href="#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> is preferred for already active deprecations.</p> </dd></dl> <dl class="exception"> <dt id="SyntaxWarning"> <em class="property">exception </em><code class="descname">SyntaxWarning</code><a class="headerlink" href="#SyntaxWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings about dubious syntax.</p> </dd></dl> <dl class="exception"> <dt id="RuntimeWarning"> <em class="property">exception </em><code class="descname">RuntimeWarning</code><a class="headerlink" href="#RuntimeWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings about dubious runtime behavior.</p> </dd></dl> <dl class="exception"> <dt id="FutureWarning"> <em class="property">exception </em><code class="descname">FutureWarning</code><a class="headerlink" href="#FutureWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings about deprecated features when those warnings are intended for end users of applications that are written in Python.</p> </dd></dl> <dl class="exception"> <dt id="ImportWarning"> <em class="property">exception </em><code class="descname">ImportWarning</code><a class="headerlink" href="#ImportWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings about probable mistakes in module imports.</p> </dd></dl> <dl class="exception"> <dt id="UnicodeWarning"> <em class="property">exception </em><code class="descname">UnicodeWarning</code><a class="headerlink" href="#UnicodeWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings related to Unicode.</p> </dd></dl> <dl class="exception"> <dt id="BytesWarning"> <em class="property">exception </em><code class="descname">BytesWarning</code><a class="headerlink" href="#BytesWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings related to <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> and <a class="reference internal" href="stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>.</p> </dd></dl> <dl class="exception"> <dt id="ResourceWarning"> <em class="property">exception </em><code class="descname">ResourceWarning</code><a class="headerlink" href="#ResourceWarning" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for warnings related to resource usage. Ignored by the default warning filters.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd></dl> </div> <div class="section" id="exception-hierarchy"> <h2>Exception hierarchy<a class="headerlink" href="#exception-hierarchy" title="Permalink to this headline">¶</a></h2> <p>The class hierarchy for built-in exceptions is:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="ne">BaseException</span> <span class="o">+--</span> <span class="ne">SystemExit</span> <span class="o">+--</span> <span class="ne">KeyboardInterrupt</span> <span class="o">+--</span> <span class="ne">GeneratorExit</span> <span class="o">+--</span> <span class="ne">Exception</span> <span class="o">+--</span> <span class="ne">StopIteration</span> <span class="o">+--</span> <span class="n">StopAsyncIteration</span> <span class="o">+--</span> <span class="ne">ArithmeticError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">FloatingPointError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">OverflowError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">ZeroDivisionError</span> <span class="o">+--</span> <span class="ne">AssertionError</span> <span class="o">+--</span> <span class="ne">AttributeError</span> <span class="o">+--</span> <span class="ne">BufferError</span> <span class="o">+--</span> <span class="ne">EOFError</span> <span class="o">+--</span> <span class="ne">ImportError</span> <span class="o">|</span> <span class="o">+--</span> <span class="n">ModuleNotFoundError</span> <span class="o">+--</span> <span class="ne">LookupError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">IndexError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">KeyError</span> <span class="o">+--</span> <span class="ne">MemoryError</span> <span class="o">+--</span> <span class="ne">NameError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">UnboundLocalError</span> <span class="o">+--</span> <span class="ne">OSError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">BlockingIOError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">ChildProcessError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">ConnectionError</span> <span class="o">|</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">BrokenPipeError</span> <span class="o">|</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">ConnectionAbortedError</span> <span class="o">|</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">ConnectionRefusedError</span> <span class="o">|</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">ConnectionResetError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">FileExistsError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">FileNotFoundError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">InterruptedError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">IsADirectoryError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">NotADirectoryError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">PermissionError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">ProcessLookupError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">TimeoutError</span> <span class="o">+--</span> <span class="ne">ReferenceError</span> <span class="o">+--</span> <span class="ne">RuntimeError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">NotImplementedError</span> <span class="o">|</span> <span class="o">+--</span> <span class="n">RecursionError</span> <span class="o">+--</span> <span class="ne">SyntaxError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">IndentationError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">TabError</span> <span class="o">+--</span> <span class="ne">SystemError</span> <span class="o">+--</span> <span class="ne">TypeError</span> <span class="o">+--</span> <span class="ne">ValueError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">UnicodeError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">UnicodeDecodeError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">UnicodeEncodeError</span> <span class="o">|</span> <span class="o">+--</span> <span class="ne">UnicodeTranslateError</span> <span class="o">+--</span> <span class="ne">Warning</span> <span class="o">+--</span> <span class="ne">DeprecationWarning</span> <span class="o">+--</span> <span class="ne">PendingDeprecationWarning</span> <span class="o">+--</span> <span class="ne">RuntimeWarning</span> <span class="o">+--</span> <span class="ne">SyntaxWarning</span> <span class="o">+--</span> <span class="ne">UserWarning</span> <span class="o">+--</span> <span class="ne">FutureWarning</span> <span class="o">+--</span> <span class="ne">ImportWarning</span> <span class="o">+--</span> <span class="ne">UnicodeWarning</span> <span class="o">+--</span> <span class="ne">BytesWarning</span> <span class="o">+--</span> <span class="ne">ResourceWarning</span> </pre></div> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Built-in Exceptions</a><ul> <li><a class="reference internal" href="#base-classes">Base classes</a></li> <li><a class="reference internal" href="#concrete-exceptions">Concrete exceptions</a><ul> <li><a class="reference internal" href="#os-exceptions">OS exceptions</a></li> </ul> </li> <li><a class="reference internal" href="#warnings">Warnings</a></li> <li><a class="reference internal" href="#exception-hierarchy">Exception hierarchy</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="stdtypes.html" title="previous chapter">Built-in Types</a></p> <h4>Next topic</h4> <p class="topless"><a href="text.html" title="next chapter">Text Processing Services</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li> <a href="https://github.com/python/cpython/blob/3.7/Doc/library/exceptions.rst" rel="nofollow">Show Source </a> </li> </ul> </div> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="text.html" title="Text Processing Services" >next</a> |</li> <li class="right" > <a href="stdtypes.html" title="Built-in Types" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <span class="language_switcher_placeholder">en</span> <span class="version_switcher_placeholder">3.7.4</span> <a href="../index.html">Documentation </a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="right"> <div class="inline-search" style="display: none" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="Quick search" type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('.inline-search').show(0);</script> | </li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 2001-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 13, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.0.1. </div> </body> </html>