mirror of
https://github.com/python/cpython.git
synced 2025-09-14 12:46:49 +00:00
gh-101536: [docs] Improve attributes of urllib.error.HTTPError
(#101612)
* gh-101536: [docs] Improve attributes of `urllib.error.HTTPError` * Address review
This commit is contained in:
parent
89413bbccb
commit
af446bbb76
1 changed files with 12 additions and 1 deletions
|
@ -31,7 +31,7 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
|
||||||
of :exc:`IOError`.
|
of :exc:`IOError`.
|
||||||
|
|
||||||
|
|
||||||
.. exception:: HTTPError
|
.. exception:: HTTPError(url, code, msg, hdrs, fp)
|
||||||
|
|
||||||
Though being an exception (a subclass of :exc:`URLError`), an
|
Though being an exception (a subclass of :exc:`URLError`), an
|
||||||
:exc:`HTTPError` can also function as a non-exceptional file-like return
|
:exc:`HTTPError` can also function as a non-exceptional file-like return
|
||||||
|
@ -39,6 +39,11 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
|
||||||
is useful when handling exotic HTTP errors, such as requests for
|
is useful when handling exotic HTTP errors, such as requests for
|
||||||
authentication.
|
authentication.
|
||||||
|
|
||||||
|
.. attribute:: url
|
||||||
|
|
||||||
|
Contains the request URL.
|
||||||
|
An alias for *filename* attribute.
|
||||||
|
|
||||||
.. attribute:: code
|
.. attribute:: code
|
||||||
|
|
||||||
An HTTP status code as defined in :rfc:`2616`. This numeric value corresponds
|
An HTTP status code as defined in :rfc:`2616`. This numeric value corresponds
|
||||||
|
@ -48,14 +53,20 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
|
||||||
.. attribute:: reason
|
.. attribute:: reason
|
||||||
|
|
||||||
This is usually a string explaining the reason for this error.
|
This is usually a string explaining the reason for this error.
|
||||||
|
An alias for *msg* attribute.
|
||||||
|
|
||||||
.. attribute:: headers
|
.. attribute:: headers
|
||||||
|
|
||||||
The HTTP response headers for the HTTP request that caused the
|
The HTTP response headers for the HTTP request that caused the
|
||||||
:exc:`HTTPError`.
|
:exc:`HTTPError`.
|
||||||
|
An alias for *hdrs* attribute.
|
||||||
|
|
||||||
.. versionadded:: 3.4
|
.. versionadded:: 3.4
|
||||||
|
|
||||||
|
.. attribute:: fp
|
||||||
|
|
||||||
|
A file-like object where the HTTP error body can be read from.
|
||||||
|
|
||||||
.. exception:: ContentTooShortError(msg, content)
|
.. exception:: ContentTooShortError(msg, content)
|
||||||
|
|
||||||
This exception is raised when the :func:`~urllib.request.urlretrieve`
|
This exception is raised when the :func:`~urllib.request.urlretrieve`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue