Skip to content

Commit 3a181a1

Browse files
authored
[3.11] gh-101100: Fix Sphinx warnings in howto/urllib2.rst and library/http.client.rst (GH-114060) (#114064)
(cherry picked from commit c280843)
1 parent 6fa6a61 commit 3a181a1

File tree

7 files changed

+46
-46
lines changed

7 files changed

+46
-46
lines changed

Doc/howto/urllib2.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,16 @@ info and geturl
392392
===============
393393

394394
The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` instance) has two
395-
useful methods :meth:`info` and :meth:`geturl` and is defined in the module
396-
:mod:`urllib.response`..
395+
useful methods :meth:`!info` and :meth:`!geturl` and is defined in the module
396+
:mod:`urllib.response`.
397397

398-
**geturl** - this returns the real URL of the page fetched. This is useful
399-
because ``urlopen`` (or the opener object used) may have followed a
400-
redirect. The URL of the page fetched may not be the same as the URL requested.
398+
* **geturl** - this returns the real URL of the page fetched. This is useful
399+
because ``urlopen`` (or the opener object used) may have followed a
400+
redirect. The URL of the page fetched may not be the same as the URL requested.
401401

402-
**info** - this returns a dictionary-like object that describes the page
403-
fetched, particularly the headers sent by the server. It is currently an
404-
:class:`http.client.HTTPMessage` instance.
402+
* **info** - this returns a dictionary-like object that describes the page
403+
fetched, particularly the headers sent by the server. It is currently an
404+
:class:`http.client.HTTPMessage` instance.
405405

406406
Typical headers include 'Content-length', 'Content-type', and so on. See the
407407
`Quick Reference to HTTP Headers <https://jkorpela.fi/http.html>`_
@@ -507,7 +507,7 @@ than the URL you pass to .add_password() will also match. ::
507507

508508
In the above example we only supplied our ``HTTPBasicAuthHandler`` to
509509
``build_opener``. By default openers have the handlers for normal situations
510-
-- ``ProxyHandler`` (if a proxy setting such as an :envvar:`http_proxy`
510+
-- ``ProxyHandler`` (if a proxy setting such as an :envvar:`!http_proxy`
511511
environment variable is set), ``UnknownHandler``, ``HTTPHandler``,
512512
``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``,
513513
``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``.

Doc/library/http.client.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ The module provides the following classes:
9393
.. versionchanged:: 3.4.3
9494
This class now performs all the necessary certificate and hostname checks
9595
by default. To revert to the previous, unverified, behavior
96-
:func:`ssl._create_unverified_context` can be passed to the *context*
96+
:func:`!ssl._create_unverified_context` can be passed to the *context*
9797
parameter.
9898

9999
.. versionchanged:: 3.8
@@ -104,7 +104,7 @@ The module provides the following classes:
104104
.. versionchanged:: 3.10
105105
This class now sends an ALPN extension with protocol indicator
106106
``http/1.1`` when no *context* is given. Custom *context* should set
107-
ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`.
107+
ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocols`.
108108

109109
.. deprecated:: 3.6
110110

@@ -132,7 +132,7 @@ This module provides the following function:
132132
.. function:: parse_headers(fp)
133133

134134
Parse the headers from a file pointer *fp* representing a HTTP
135-
request/response. The file has to be a :class:`BufferedIOBase` reader
135+
request/response. The file has to be a :class:`~io.BufferedIOBase` reader
136136
(i.e. not text) and must provide a valid :rfc:`2822` style header.
137137

138138
This function returns an instance of :class:`http.client.HTTPMessage`
@@ -401,7 +401,7 @@ HTTPConnection Objects
401401
.. versionadded:: 3.7
402402

403403

404-
As an alternative to using the :meth:`request` method described above, you can
404+
As an alternative to using the :meth:`~HTTPConnection.request` method described above, you can
405405
also send your request step by step, by using the four functions below.
406406

407407

@@ -633,6 +633,8 @@ method attribute. Here is an example session that uses the ``PUT`` method::
633633
HTTPMessage Objects
634634
-------------------
635635

636+
.. class:: HTTPMessage(email.message.Message)
637+
636638
An :class:`http.client.HTTPMessage` instance holds the headers from an HTTP
637639
response. It is implemented using the :class:`email.message.Message` class.
638640

Doc/library/urllib.request.rst

+26-26
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ The :mod:`urllib.request` module defines the following functions:
8686
:class:`UnknownHandler` to ensure this never happens).
8787

8888
In addition, if proxy settings are detected (for example, when a ``*_proxy``
89-
environment variable like :envvar:`http_proxy` is set),
89+
environment variable like :envvar:`!http_proxy` is set),
9090
:class:`ProxyHandler` is default installed and makes sure the requests are
9191
handled through the proxy.
9292

@@ -121,7 +121,7 @@ The :mod:`urllib.request` module defines the following functions:
121121
.. versionchanged:: 3.10
122122
HTTPS connection now send an ALPN extension with protocol indicator
123123
``http/1.1`` when no *context* is given. Custom *context* should set
124-
ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`.
124+
ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocols`.
125125

126126
.. deprecated:: 3.6
127127

@@ -629,25 +629,25 @@ OpenerDirector Objects
629629
the actual HTTP code, for example :meth:`http_error_404` would handle HTTP
630630
404 errors.
631631

632-
* :meth:`<protocol>_open` --- signal that the handler knows how to open *protocol*
632+
* :meth:`!<protocol>_open` --- signal that the handler knows how to open *protocol*
633633
URLs.
634634

635635
See |protocol_open|_ for more information.
636636

637-
* :meth:`http_error_\<type\>` --- signal that the handler knows how to handle HTTP
637+
* :meth:`!http_error_\<type\>` --- signal that the handler knows how to handle HTTP
638638
errors with HTTP error code *type*.
639639

640640
See |http_error_nnn|_ for more information.
641641

642-
* :meth:`<protocol>_error` --- signal that the handler knows how to handle errors
642+
* :meth:`!<protocol>_error` --- signal that the handler knows how to handle errors
643643
from (non-\ ``http``) *protocol*.
644644

645-
* :meth:`<protocol>_request` --- signal that the handler knows how to pre-process
645+
* :meth:`!<protocol>_request` --- signal that the handler knows how to pre-process
646646
*protocol* requests.
647647

648648
See |protocol_request|_ for more information.
649649

650-
* :meth:`<protocol>_response` --- signal that the handler knows how to
650+
* :meth:`!<protocol>_response` --- signal that the handler knows how to
651651
post-process *protocol* responses.
652652

653653
See |protocol_response|_ for more information.
@@ -674,7 +674,7 @@ OpenerDirector Objects
674674
Handle an error of the given protocol. This will call the registered error
675675
handlers for the given protocol with the given arguments (which are protocol
676676
specific). The HTTP protocol is a special case which uses the HTTP response
677-
code to determine the specific error handler; refer to the :meth:`http_error_\<type\>`
677+
code to determine the specific error handler; refer to the :meth:`!http_error_\<type\>`
678678
methods of the handler classes.
679679

680680
Return values and exceptions raised are the same as those of :func:`urlopen`.
@@ -684,25 +684,25 @@ OpenerDirector objects open URLs in three stages:
684684
The order in which these methods are called within each stage is determined by
685685
sorting the handler instances.
686686

687-
#. Every handler with a method named like :meth:`<protocol>_request` has that
687+
#. Every handler with a method named like :meth:`!<protocol>_request` has that
688688
method called to pre-process the request.
689689

690-
#. Handlers with a method named like :meth:`<protocol>_open` are called to handle
690+
#. Handlers with a method named like :meth:`!<protocol>_open` are called to handle
691691
the request. This stage ends when a handler either returns a non-\ :const:`None`
692692
value (ie. a response), or raises an exception (usually
693693
:exc:`~urllib.error.URLError`). Exceptions are allowed to propagate.
694694

695695
In fact, the above algorithm is first tried for methods named
696-
:meth:`default_open`. If all such methods return :const:`None`, the algorithm
697-
is repeated for methods named like :meth:`<protocol>_open`. If all such methods
696+
:meth:`~BaseHandler.default_open`. If all such methods return :const:`None`, the algorithm
697+
is repeated for methods named like :meth:`!<protocol>_open`. If all such methods
698698
return :const:`None`, the algorithm is repeated for methods named
699-
:meth:`unknown_open`.
699+
:meth:`~BaseHandler.unknown_open`.
700700

701701
Note that the implementation of these methods may involve calls of the parent
702702
:class:`OpenerDirector` instance's :meth:`~OpenerDirector.open` and
703703
:meth:`~OpenerDirector.error` methods.
704704

705-
#. Every handler with a method named like :meth:`<protocol>_response` has that
705+
#. Every handler with a method named like :meth:`!<protocol>_response` has that
706706
method called to post-process the response.
707707

708708

@@ -751,7 +751,7 @@ The following attribute and methods should only be used by classes derived from
751751
the return value of the :meth:`~OpenerDirector.open` method of :class:`OpenerDirector`, or ``None``.
752752
It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional
753753
thing happens (for example, :exc:`MemoryError` should not be mapped to
754-
:exc:`URLError`).
754+
:exc:`~urllib.error.URLError`).
755755

756756
This method will be called before any protocol-specific open method.
757757

@@ -764,7 +764,7 @@ The following attribute and methods should only be used by classes derived from
764764
define it if they want to handle URLs with the given protocol.
765765

766766
This method, if defined, will be called by the parent :class:`OpenerDirector`.
767-
Return values should be the same as for :meth:`default_open`.
767+
Return values should be the same as for :meth:`~BaseHandler.default_open`.
768768

769769

770770
.. method:: BaseHandler.unknown_open(req)
@@ -804,7 +804,7 @@ The following attribute and methods should only be used by classes derived from
804804
Subclasses should override this method to handle specific HTTP errors.
805805

806806
Arguments, return values and exceptions raised should be the same as for
807-
:meth:`http_error_default`.
807+
:meth:`~BaseHandler.http_error_default`.
808808

809809

810810
.. _protocol_request:
@@ -844,7 +844,7 @@ HTTPRedirectHandler Objects
844844
is the case, :exc:`~urllib.error.HTTPError` is raised. See :rfc:`2616` for
845845
details of the precise meanings of the various redirection codes.
846846

847-
An :class:`HTTPError` exception raised as a security consideration if the
847+
An :exc:`~urllib.error.HTTPError` exception raised as a security consideration if the
848848
HTTPRedirectHandler is presented with a redirected URL which is not an HTTP,
849849
HTTPS or FTP URL.
850850

@@ -921,7 +921,7 @@ ProxyHandler Objects
921921
.. method:: ProxyHandler.<protocol>_open(request)
922922
:noindex:
923923

924-
The :class:`ProxyHandler` will have a method :meth:`<protocol>_open` for every
924+
The :class:`ProxyHandler` will have a method :meth:`!<protocol>_open` for every
925925
*protocol* which has a proxy in the *proxies* dictionary given in the
926926
constructor. The method will modify requests to go through the proxy, by
927927
calling ``request.set_proxy()``, and call the next handler in the chain to
@@ -1177,7 +1177,7 @@ HTTPErrorProcessor Objects
11771177
For 200 error codes, the response object is returned immediately.
11781178

11791179
For non-200 error codes, this simply passes the job on to the
1180-
:meth:`http_error_\<type\>` handler methods, via :meth:`OpenerDirector.error`.
1180+
:meth:`!http_error_\<type\>` handler methods, via :meth:`OpenerDirector.error`.
11811181
Eventually, :class:`HTTPDefaultErrorHandler` will raise an
11821182
:exc:`~urllib.error.HTTPError` if no other handler handles the error.
11831183

@@ -1284,7 +1284,7 @@ Use of Basic HTTP Authentication::
12841284
:func:`build_opener` provides many handlers by default, including a
12851285
:class:`ProxyHandler`. By default, :class:`ProxyHandler` uses the environment
12861286
variables named ``<scheme>_proxy``, where ``<scheme>`` is the URL scheme
1287-
involved. For example, the :envvar:`http_proxy` environment variable is read to
1287+
involved. For example, the :envvar:`!http_proxy` environment variable is read to
12881288
obtain the HTTP proxy's URL.
12891289

12901290
This example replaces the default :class:`ProxyHandler` with one that uses
@@ -1379,7 +1379,7 @@ some point in the future.
13791379
points to a local file, the object will not be copied unless filename is supplied.
13801380
Return a tuple ``(filename, headers)`` where *filename* is the
13811381
local file name under which the object can be found, and *headers* is whatever
1382-
the :meth:`info` method of the object returned by :func:`urlopen` returned (for
1382+
the :meth:`!info` method of the object returned by :func:`urlopen` returned (for
13831383
a remote object). Exceptions are the same as for :func:`urlopen`.
13841384

13851385
The second argument, if present, specifies the file location to copy to (if
@@ -1404,7 +1404,7 @@ some point in the future.
14041404
:mimetype:`application/x-www-form-urlencoded` format; see the
14051405
:func:`urllib.parse.urlencode` function.
14061406

1407-
:func:`urlretrieve` will raise :exc:`ContentTooShortError` when it detects that
1407+
:func:`urlretrieve` will raise :exc:`~urllib.error.ContentTooShortError` when it detects that
14081408
the amount of data available was less than the expected amount (which is the
14091409
size reported by a *Content-Length* header). This can occur, for example, when
14101410
the download is interrupted.
@@ -1413,8 +1413,8 @@ some point in the future.
14131413
urlretrieve reads more data, but if less data is available, it raises the
14141414
exception.
14151415

1416-
You can still retrieve the downloaded data in this case, it is stored in the
1417-
:attr:`content` attribute of the exception instance.
1416+
You can still retrieve the downloaded data in this case, it is stored in the
1417+
:attr:`!content` attribute of the exception instance.
14181418

14191419
If no *Content-Length* header was supplied, urlretrieve can not check the size
14201420
of the data it has downloaded, and just returns it. In this case you just have
@@ -1508,7 +1508,7 @@ some point in the future.
15081508
authentication is performed. For the 30x response codes, recursion is bounded
15091509
by the value of the *maxtries* attribute, which defaults to 10.
15101510

1511-
For all other response codes, the method :meth:`http_error_default` is called
1511+
For all other response codes, the method :meth:`~BaseHandler.http_error_default` is called
15121512
which you can override in subclasses to handle the error appropriately.
15131513

15141514
.. note::

Doc/tools/.nitignore

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Doc/glossary.rst
2424
Doc/howto/descriptor.rst
2525
Doc/howto/enum.rst
2626
Doc/howto/logging.rst
27-
Doc/howto/urllib2.rst
2827
Doc/library/ast.rst
2928
Doc/library/asyncio-extending.rst
3029
Doc/library/asyncio-policy.rst
@@ -52,7 +51,6 @@ Doc/library/faulthandler.rst
5251
Doc/library/fcntl.rst
5352
Doc/library/ftplib.rst
5453
Doc/library/functools.rst
55-
Doc/library/http.client.rst
5654
Doc/library/http.cookiejar.rst
5755
Doc/library/http.server.rst
5856
Doc/library/importlib.rst

Misc/NEWS.d/3.10.0a1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ class
12201220

12211221
Previously there was no way to check that without using private API. See the
12221222
`relevant issue in python/typing
1223-
<https://github.com/python/typing/issues/751>`
1223+
<https://github.com/python/typing/issues/751>`_.
12241224

12251225
..
12261226

Misc/NEWS.d/3.9.0a1.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2857,8 +2857,8 @@ Patch by Justin Blanchard.
28572857
Add formal support for UDPLITE sockets. Support was present before, but it
28582858
is now easier to detect support with ``hasattr(socket, 'IPPROTO_UDPLITE')``
28592859
and there are constants defined for each of the values needed:
2860-
:py:obj:`socket.IPPROTO_UDPLITE`, :py:obj:`UDPLITE_SEND_CSCOV`, and
2861-
:py:obj:`UDPLITE_RECV_CSCOV`. Patch by Gabe Appleton.
2860+
``socket.IPPROTO_UDPLITE``, ``UDPLITE_SEND_CSCOV``, and
2861+
``UDPLITE_RECV_CSCOV``. Patch by Gabe Appleton.
28622862

28632863
..
28642864

Misc/NEWS.d/3.9.0b1.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ Port :mod:`syslog` to multiphase initialization (:pep:`489`).
112112
Reporting a specialised error message for invalid string prefixes, which was
113113
introduced in :issue:`40246`, is being reverted due to backwards
114114
compatibility concerns for strings that immediately follow a reserved
115-
keyword without whitespace between them. Constructs like `bg="#d00" if clear
116-
else"#fca"` were failing to parse, which is not an acceptable breakage on
115+
keyword without whitespace between them. Constructs like ``bg="#d00" if clear
116+
else"#fca"`` were failing to parse, which is not an acceptable breakage on
117117
such short notice.
118118

119119
..

0 commit comments

Comments
 (0)