Skip to content

Commit c280843

Browse files
authored
gh-101100: Fix Sphinx warnings in howto/urllib2.rst and library/http.client.rst (#114060)
1 parent 5dbcdfd commit c280843

File tree

9 files changed

+49
-49
lines changed

9 files changed

+49
-49
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
@@ -92,7 +92,7 @@ The module provides the following classes:
9292
.. versionchanged:: 3.4.3
9393
This class now performs all the necessary certificate and hostname checks
9494
by default. To revert to the previous, unverified, behavior
95-
:func:`ssl._create_unverified_context` can be passed to the *context*
95+
:func:`!ssl._create_unverified_context` can be passed to the *context*
9696
parameter.
9797

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

108108
.. versionchanged:: 3.12
109109
The deprecated *key_file*, *cert_file* and *check_hostname* parameters
@@ -124,7 +124,7 @@ This module provides the following function:
124124
.. function:: parse_headers(fp)
125125

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

130130
This function returns an instance of :class:`http.client.HTTPMessage`
@@ -416,7 +416,7 @@ HTTPConnection Objects
416416
.. versionadded:: 3.7
417417

418418

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

422422

@@ -648,6 +648,8 @@ method attribute. Here is an example session that uses the ``PUT`` method::
648648
HTTPMessage Objects
649649
-------------------
650650

651+
.. class:: HTTPMessage(email.message.Message)
652+
651653
An :class:`http.client.HTTPMessage` instance holds the headers from an HTTP
652654
response. It is implemented using the :class:`email.message.Message` class.
653655

Doc/library/urllib.request.rst

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

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

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

118118
.. versionchanged:: 3.13
119119
Remove *cafile*, *capath* and *cadefault* parameters: use the *context*
@@ -618,25 +618,25 @@ OpenerDirector Objects
618618
the actual HTTP code, for example :meth:`http_error_404` would handle HTTP
619619
404 errors.
620620

621-
* :meth:`<protocol>_open` --- signal that the handler knows how to open *protocol*
621+
* :meth:`!<protocol>_open` --- signal that the handler knows how to open *protocol*
622622
URLs.
623623

624624
See |protocol_open|_ for more information.
625625

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

629629
See |http_error_nnn|_ for more information.
630630

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

634-
* :meth:`<protocol>_request` --- signal that the handler knows how to pre-process
634+
* :meth:`!<protocol>_request` --- signal that the handler knows how to pre-process
635635
*protocol* requests.
636636

637637
See |protocol_request|_ for more information.
638638

639-
* :meth:`<protocol>_response` --- signal that the handler knows how to
639+
* :meth:`!<protocol>_response` --- signal that the handler knows how to
640640
post-process *protocol* responses.
641641

642642
See |protocol_response|_ for more information.
@@ -663,7 +663,7 @@ OpenerDirector Objects
663663
Handle an error of the given protocol. This will call the registered error
664664
handlers for the given protocol with the given arguments (which are protocol
665665
specific). The HTTP protocol is a special case which uses the HTTP response
666-
code to determine the specific error handler; refer to the :meth:`http_error_\<type\>`
666+
code to determine the specific error handler; refer to the :meth:`!http_error_\<type\>`
667667
methods of the handler classes.
668668

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

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

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

684684
In fact, the above algorithm is first tried for methods named
685-
:meth:`default_open`. If all such methods return :const:`None`, the algorithm
686-
is repeated for methods named like :meth:`<protocol>_open`. If all such methods
685+
:meth:`~BaseHandler.default_open`. If all such methods return :const:`None`, the algorithm
686+
is repeated for methods named like :meth:`!<protocol>_open`. If all such methods
687687
return :const:`None`, the algorithm is repeated for methods named
688-
:meth:`unknown_open`.
688+
:meth:`~BaseHandler.unknown_open`.
689689

690690
Note that the implementation of these methods may involve calls of the parent
691691
:class:`OpenerDirector` instance's :meth:`~OpenerDirector.open` and
692692
:meth:`~OpenerDirector.error` methods.
693693

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

697697

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

745745
This method will be called before any protocol-specific open method.
746746

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

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

758758

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

795795
Arguments, return values and exceptions raised should be the same as for
796-
:meth:`http_error_default`.
796+
:meth:`~BaseHandler.http_error_default`.
797797

798798

799799
.. _protocol_request:
@@ -833,7 +833,7 @@ HTTPRedirectHandler Objects
833833
is the case, :exc:`~urllib.error.HTTPError` is raised. See :rfc:`2616` for
834834
details of the precise meanings of the various redirection codes.
835835

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

@@ -910,7 +910,7 @@ ProxyHandler Objects
910910
.. method:: ProxyHandler.<protocol>_open(request)
911911
:noindex:
912912

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

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

@@ -1273,7 +1273,7 @@ Use of Basic HTTP Authentication::
12731273
:func:`build_opener` provides many handlers by default, including a
12741274
:class:`ProxyHandler`. By default, :class:`ProxyHandler` uses the environment
12751275
variables named ``<scheme>_proxy``, where ``<scheme>`` is the URL scheme
1276-
involved. For example, the :envvar:`http_proxy` environment variable is read to
1276+
involved. For example, the :envvar:`!http_proxy` environment variable is read to
12771277
obtain the HTTP proxy's URL.
12781278

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

13741374
The second argument, if present, specifies the file location to copy to (if
@@ -1393,7 +1393,7 @@ some point in the future.
13931393
:mimetype:`application/x-www-form-urlencoded` format; see the
13941394
:func:`urllib.parse.urlencode` function.
13951395

1396-
:func:`urlretrieve` will raise :exc:`ContentTooShortError` when it detects that
1396+
:func:`urlretrieve` will raise :exc:`~urllib.error.ContentTooShortError` when it detects that
13971397
the amount of data available was less than the expected amount (which is the
13981398
size reported by a *Content-Length* header). This can occur, for example, when
13991399
the download is interrupted.
@@ -1402,8 +1402,8 @@ some point in the future.
14021402
urlretrieve reads more data, but if less data is available, it raises the
14031403
exception.
14041404

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

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

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

15031503
.. 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
@@ -49,7 +48,6 @@ Doc/library/faulthandler.rst
4948
Doc/library/fcntl.rst
5049
Doc/library/ftplib.rst
5150
Doc/library/functools.rst
52-
Doc/library/http.client.rst
5351
Doc/library/http.cookiejar.rst
5452
Doc/library/http.server.rst
5553
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.12.0a2.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ Use the frame bound builtins when offering a name suggestion in
584584
.. nonce: qtm-9T
585585
.. section: Library
586586
587-
In :mod:`importlib._bootstrap`, enhance namespace package repr to `<module
588-
'x' (namespace) from ['path']>`.
587+
In :mod:`importlib._bootstrap`, enhance namespace package repr to ``<module
588+
'x' (namespace) from ['path']>``.
589589

590590
..
591591

Misc/NEWS.d/3.13.0a2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ their debugging to ``PYTHON_UOPS`` and ``PYTHON_LLTRACE``.
199199
.. nonce: 11h6Mc
200200
.. section: Core and Builtins
201201
202-
Speed up :obj:`Traceback` object creation by lazily compute the line number.
202+
Speed up :class:`Traceback` object creation by lazily compute the line number.
203203
Patch by Pablo Galindo
204204

205205
..

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)