From 0fc73e59152d62c1a8713762eb94eda2b16b2b57 Mon Sep 17 00:00:00 2001 From: Valerio Gainella Date: Sat, 19 Jul 2025 13:01:51 +0200 Subject: [PATCH 1/4] urllib.request.HTTPRedirectHandler documentation uses hdrs instead of headers #135468 --- Doc/library/urllib.request.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 58bd111b5cc374..6ebabea7e578f7 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -911,11 +911,17 @@ HTTPRedirectHandler Objects do allow automatic redirection of these responses, changing the POST to a ``GET``, and the default implementation reproduces this behavior. - .. method:: HTTPRedirectHandler.http_error_301(req, fp, code, msg, hdrs) Redirect to the ``Location:`` or ``URI:`` URL. This method is called by the - parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' response. + parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' response. + :class:`OpenerDirector` will call this method with five positional arguments: + +* a :class:`Request` object, +* a file-like object with the HTTP error body, +* the three-digit code of the error, as a string, +* the user-visible explanation of the code, as as string, and +* the headers of the error, as a mapping object. .. method:: HTTPRedirectHandler.http_error_302(req, fp, code, msg, hdrs) From 61deb5b35ded9ca4535b19eb8592a15caa3af25e Mon Sep 17 00:00:00 2001 From: Valerio Gainella Date: Sat, 19 Jul 2025 13:37:23 +0200 Subject: [PATCH 2/4] readded line --- Doc/library/urllib.request.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 6ebabea7e578f7..e15f8d8355c8d5 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -911,6 +911,7 @@ HTTPRedirectHandler Objects do allow automatic redirection of these responses, changing the POST to a ``GET``, and the default implementation reproduces this behavior. + .. method:: HTTPRedirectHandler.http_error_301(req, fp, code, msg, hdrs) Redirect to the ``Location:`` or ``URI:`` URL. This method is called by the From 98aafdb473fdce62572d10bda993fffcd78efd05 Mon Sep 17 00:00:00 2001 From: Valerio Gainella Date: Sat, 19 Jul 2025 13:39:04 +0200 Subject: [PATCH 3/4] indented and fixed whitespace --- Doc/library/urllib.request.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index e15f8d8355c8d5..3ee42746d45510 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -915,14 +915,14 @@ HTTPRedirectHandler Objects .. method:: HTTPRedirectHandler.http_error_301(req, fp, code, msg, hdrs) Redirect to the ``Location:`` or ``URI:`` URL. This method is called by the - parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' response. + parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' response. :class:`OpenerDirector` will call this method with five positional arguments: -* a :class:`Request` object, -* a file-like object with the HTTP error body, -* the three-digit code of the error, as a string, -* the user-visible explanation of the code, as as string, and -* the headers of the error, as a mapping object. + * a :class:`Request` object, + * a file-like object with the HTTP error body, + * the three-digit code of the error, as a string, + * the user-visible explanation of the code, as as string, and + * the headers of the error, as a mapping object. .. method:: HTTPRedirectHandler.http_error_302(req, fp, code, msg, hdrs) From 4e5b379c2b39ff0dd648bfee8a18ec7f950e82cf Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 19 Jul 2025 16:30:27 +0200 Subject: [PATCH 4/4] Move description to base method (``http_error_default()``) --- Doc/library/urllib.request.rst | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 3ee42746d45510..1e716715fd9bed 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -829,10 +829,13 @@ The following attribute and methods should only be used by classes derived from errors. It will be called automatically by the :class:`OpenerDirector` getting the error, and should not normally be called in other circumstances. - *req* will be a :class:`Request` object, *fp* will be a file-like object with - the HTTP error body, *code* will be the three-digit code of the error, *msg* - will be the user-visible explanation of the code and *hdrs* will be a mapping - object with the headers of the error. + :class:`OpenerDirector` will call this method with five positional arguments: + + 1. a :class:`Request` object, + #. a file-like object with the HTTP error body, + #. the three-digit code of the error, as a string, + #. the user-visible explanation of the code, as as string, and + #. the headers of the error, as a mapping object. Return values and exceptions raised should be the same as those of :func:`urlopen`. @@ -916,13 +919,6 @@ HTTPRedirectHandler Objects Redirect to the ``Location:`` or ``URI:`` URL. This method is called by the parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' response. - :class:`OpenerDirector` will call this method with five positional arguments: - - * a :class:`Request` object, - * a file-like object with the HTTP error body, - * the three-digit code of the error, as a string, - * the user-visible explanation of the code, as as string, and - * the headers of the error, as a mapping object. .. method:: HTTPRedirectHandler.http_error_302(req, fp, code, msg, hdrs)