diff options
Diffstat (limited to 'devdocs/python~3.12/library%2Furllib.error.html')
| -rw-r--r-- | devdocs/python~3.12/library%2Furllib.error.html | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Furllib.error.html b/devdocs/python~3.12/library%2Furllib.error.html new file mode 100644 index 00000000..eeff5037 --- /dev/null +++ b/devdocs/python~3.12/library%2Furllib.error.html @@ -0,0 +1,36 @@ + <span id="urllib-error-exception-classes-raised-by-urllib-request"></span><h1>urllib.error — Exception classes raised by urllib.request</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/urllib/error.py">Lib/urllib/error.py</a></p> <p>The <a class="reference internal" href="#module-urllib.error" title="urllib.error: Exception classes raised by urllib.request."><code>urllib.error</code></a> module defines the exception classes for exceptions raised by <a class="reference internal" href="urllib.request#module-urllib.request" title="urllib.request: Extensible library for opening URLs."><code>urllib.request</code></a>. The base exception class is <a class="reference internal" href="#urllib.error.URLError" title="urllib.error.URLError"><code>URLError</code></a>.</p> <p>The following exceptions are raised by <a class="reference internal" href="#module-urllib.error" title="urllib.error: Exception classes raised by urllib.request."><code>urllib.error</code></a> as appropriate:</p> <dl class="py exception"> <dt class="sig sig-object py" id="urllib.error.URLError"> +<code>exception urllib.error.URLError</code> </dt> <dd> +<p>The handlers raise this exception (or derived exceptions) when they run into a problem. It is a subclass of <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a>.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="urllib.error.URLError.reason"> +<code>reason</code> </dt> <dd> +<p>The reason for this error. It can be a message string or another exception instance.</p> </dd> +</dl> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.3: </span><a class="reference internal" href="#urllib.error.URLError" title="urllib.error.URLError"><code>URLError</code></a> used to be a subtype of <a class="reference internal" href="exceptions#IOError" title="IOError"><code>IOError</code></a>, which is now an alias of <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a>.</p> </div> </dd> +</dl> <dl class="py exception"> <dt class="sig sig-object py" id="urllib.error.HTTPError"> +<code>exception urllib.error.HTTPError(url, code, msg, hdrs, fp)</code> </dt> <dd> +<p>Though being an exception (a subclass of <a class="reference internal" href="#urllib.error.URLError" title="urllib.error.URLError"><code>URLError</code></a>), an <a class="reference internal" href="#urllib.error.HTTPError" title="urllib.error.HTTPError"><code>HTTPError</code></a> can also function as a non-exceptional file-like return value (the same thing that <a class="reference internal" href="urllib.request#urllib.request.urlopen" title="urllib.request.urlopen"><code>urlopen()</code></a> returns). This is useful when handling exotic HTTP errors, such as requests for authentication.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="urllib.error.HTTPError.url"> +<code>url</code> </dt> <dd> +<p>Contains the request URL. An alias for <em>filename</em> attribute.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="urllib.error.HTTPError.code"> +<code>code</code> </dt> <dd> +<p>An HTTP status code as defined in <span class="target" id="index-0"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2616.html"><strong>RFC 2616</strong></a>. This numeric value corresponds to a value found in the dictionary of codes as found in <a class="reference internal" href="http.server#http.server.BaseHTTPRequestHandler.responses" title="http.server.BaseHTTPRequestHandler.responses"><code>http.server.BaseHTTPRequestHandler.responses</code></a>.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="urllib.error.HTTPError.reason"> +<code>reason</code> </dt> <dd> +<p>This is usually a string explaining the reason for this error. An alias for <em>msg</em> attribute.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="urllib.error.HTTPError.headers"> +<code>headers</code> </dt> <dd> +<p>The HTTP response headers for the HTTP request that caused the <a class="reference internal" href="#urllib.error.HTTPError" title="urllib.error.HTTPError"><code>HTTPError</code></a>. An alias for <em>hdrs</em> attribute.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.4.</span></p> </div> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="urllib.error.HTTPError.fp"> +<code>fp</code> </dt> <dd> +<p>A file-like object where the HTTP error body can be read from.</p> </dd> +</dl> </dd> +</dl> <dl class="py exception"> <dt class="sig sig-object py" id="urllib.error.ContentTooShortError"> +<code>exception urllib.error.ContentTooShortError(msg, content)</code> </dt> <dd> +<p>This exception is raised when the <a class="reference internal" href="urllib.request#urllib.request.urlretrieve" title="urllib.request.urlretrieve"><code>urlretrieve()</code></a> function detects that the amount of the downloaded data is less than the expected amount (given by the <em>Content-Length</em> header).</p> <dl class="py attribute"> <dt class="sig sig-object py" id="urllib.error.ContentTooShortError.content"> +<code>content</code> </dt> <dd> +<p>The downloaded (and supposedly truncated) data.</p> </dd> +</dl> </dd> +</dl> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/library/urllib.error.html" class="_attribution-link">https://docs.python.org/3.12/library/urllib.error.html</a> + </p> +</div> |
