Skip to content

Commit af446bb

Browse files
authored
gh-101536: [docs] Improve attributes of urllib.error.HTTPError (#101612)
* gh-101536: [docs] Improve attributes of `urllib.error.HTTPError` * Address review
1 parent 89413bb commit af446bb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Doc/library/urllib.error.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
3131
of :exc:`IOError`.
3232

3333

34-
.. exception:: HTTPError
34+
.. exception:: HTTPError(url, code, msg, hdrs, fp)
3535

3636
Though being an exception (a subclass of :exc:`URLError`), an
3737
:exc:`HTTPError` can also function as a non-exceptional file-like return
3838
value (the same thing that :func:`~urllib.request.urlopen` returns). This
3939
is useful when handling exotic HTTP errors, such as requests for
4040
authentication.
4141

42+
.. attribute:: url
43+
44+
Contains the request URL.
45+
An alias for *filename* attribute.
46+
4247
.. attribute:: code
4348

4449
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:
4853
.. attribute:: reason
4954

5055
This is usually a string explaining the reason for this error.
56+
An alias for *msg* attribute.
5157

5258
.. attribute:: headers
5359

5460
The HTTP response headers for the HTTP request that caused the
5561
:exc:`HTTPError`.
62+
An alias for *hdrs* attribute.
5663

5764
.. versionadded:: 3.4
5865

66+
.. attribute:: fp
67+
68+
A file-like object where the HTTP error body can be read from.
69+
5970
.. exception:: ContentTooShortError(msg, content)
6071

6172
This exception is raised when the :func:`~urllib.request.urlretrieve`

0 commit comments

Comments
 (0)