Skip to content

Commit 10e73ba

Browse files
Improve #19204: Improved cross-references in the urllib package documentation.
2 parents ef1605a + 5e1c053 commit 10e73ba

4 files changed

Lines changed: 30 additions & 25 deletions

File tree

Doc/library/urllib.error.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
3131

3232
Though being an exception (a subclass of :exc:`URLError`), an
3333
:exc:`HTTPError` can also function as a non-exceptional file-like return
34-
value (the same thing that :func:`urlopen` returns). This is useful when
35-
handling exotic HTTP errors, such as requests for authentication.
34+
value (the same thing that :func:`~urllib.request.urlopen` returns). This
35+
is useful when handling exotic HTTP errors, such as requests for
36+
authentication.
3637

3738
.. attribute:: code
3839

@@ -54,7 +55,8 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
5455

5556
.. exception:: ContentTooShortError(msg, content)
5657

57-
This exception is raised when the :func:`urlretrieve` function detects that
58+
This exception is raised when the :func:`~urllib.request.urlretrieve`
59+
function detects that
5860
the amount of the downloaded data is less than the expected amount (given by
5961
the *Content-Length* header). The :attr:`content` attribute stores the
6062
downloaded (and supposedly truncated) data.

Doc/library/urllib.parse.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ task isn't already covered by the URL parsing functions above.
518518
Convert a mapping object or a sequence of two-element tuples, which may
519519
either be a :class:`str` or a :class:`bytes`, to a "percent-encoded"
520520
string. If the resultant string is to be used as a *data* for POST
521-
operation with :func:`urlopen` function, then it should be properly encoded
522-
to bytes, otherwise it would result in a :exc:`TypeError`.
521+
operation with :func:`~urllib.request.urlopen` function, then it should be
522+
properly encoded to bytes, otherwise it would result in a :exc:`TypeError`.
523523

524524
The resulting string is a series of ``key=value`` pairs separated by ``'&'``
525525
characters, where both *key* and *value* are quoted using :func:`quote_plus`

Doc/library/urllib.request.rst

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The :mod:`urllib.request` module defines the following functions:
8181

8282
* :meth:`~urllib.response.addinfourl.getcode` -- return the HTTP status code of the response.
8383

84-
Raises :exc:`URLError` on errors.
84+
Raises :exc:`~urllib.error.URLError` on errors.
8585

8686
Note that ``None`` may be returned if no handler handles the request (though
8787
the default installed global :class:`OpenerDirector` uses
@@ -144,14 +144,14 @@ The :mod:`urllib.request` module defines the following functions:
144144

145145
Convert the pathname *path* from the local syntax for a path to the form used in
146146
the path component of a URL. This does not produce a complete URL. The return
147-
value will already be quoted using the :func:`quote` function.
147+
value will already be quoted using the :func:`~urllib.parse.quote` function.
148148

149149

150150
.. function:: url2pathname(path)
151151

152152
Convert the path component *path* from a percent-encoded URL to the local syntax for a
153-
path. This does not accept a complete URL. This function uses :func:`unquote`
154-
to decode *path*.
153+
path. This does not accept a complete URL. This function uses
154+
:func:`~urllib.parse.unquote` to decode *path*.
155155

156156
.. function:: getproxies()
157157

@@ -245,7 +245,7 @@ The following classes are provided:
245245
.. class:: HTTPDefaultErrorHandler()
246246

247247
A class which defines a default handler for HTTP error responses; all responses
248-
are turned into :exc:`HTTPError` exceptions.
248+
are turned into :exc:`~urllib.error.HTTPError` exceptions.
249249

250250

251251
.. class:: HTTPRedirectHandler()
@@ -582,8 +582,8 @@ sorting the handler instances.
582582

583583
#. Handlers with a method named like :meth:`protocol_open` are called to handle
584584
the request. This stage ends when a handler either returns a non-\ :const:`None`
585-
value (ie. a response), or raises an exception (usually :exc:`URLError`).
586-
Exceptions are allowed to propagate.
585+
value (ie. a response), or raises an exception (usually
586+
:exc:`~urllib.error.URLError`). Exceptions are allowed to propagate.
587587

588588
In fact, the above algorithm is first tried for methods named
589589
:meth:`default_open`. If all such methods return :const:`None`, the algorithm
@@ -642,8 +642,9 @@ The following attribute and methods should only be used by classes derived from
642642
This method, if implemented, will be called by the parent
643643
:class:`OpenerDirector`. It should return a file-like object as described in
644644
the return value of the :meth:`open` of :class:`OpenerDirector`, or ``None``.
645-
It should raise :exc:`URLError`, unless a truly exceptional thing happens (for
646-
example, :exc:`MemoryError` should not be mapped to :exc:`URLError`).
645+
It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional
646+
thing happens (for example, :exc:`MemoryError` should not be mapped to
647+
:exc:`URLError`).
647648

648649
This method will be called before any protocol-specific open method.
649650

@@ -729,8 +730,8 @@ HTTPRedirectHandler Objects
729730
.. note::
730731

731732
Some HTTP redirections require action from this module's client code. If this
732-
is the case, :exc:`HTTPError` is raised. See :rfc:`2616` for details of the
733-
precise meanings of the various redirection codes.
733+
is the case, :exc:`~urllib.error.HTTPError` is raised. See :rfc:`2616` for
734+
details of the precise meanings of the various redirection codes.
734735

735736
An :class:`HTTPError` exception raised as a security consideration if the
736737
HTTPRedirectHandler is presented with a redirected url which is not an HTTP,
@@ -743,9 +744,9 @@ HTTPRedirectHandler Objects
743744
by the default implementations of the :meth:`http_error_30\*` methods when a
744745
redirection is received from the server. If a redirection should take place,
745746
return a new :class:`Request` to allow :meth:`http_error_30\*` to perform the
746-
redirect to *newurl*. Otherwise, raise :exc:`HTTPError` if no other handler
747-
should try to handle this URL, or return ``None`` if you can't but another
748-
handler might.
747+
redirect to *newurl*. Otherwise, raise :exc:`~urllib.error.HTTPError` if
748+
no other handler should try to handle this URL, or return ``None`` if you
749+
can't but another handler might.
749750

750751
.. note::
751752

@@ -947,7 +948,7 @@ FileHandler Objects
947948

948949
.. versionchanged:: 3.2
949950
This method is applicable only for local hostnames. When a remote
950-
hostname is given, an :exc:`URLError` is raised.
951+
hostname is given, an :exc:`~urllib.error.URLError` is raised.
951952

952953

953954
.. _data-handler-objects:
@@ -1004,7 +1005,7 @@ UnknownHandler Objects
10041005

10051006
.. method:: UnknownHandler.unknown_open()
10061007

1007-
Raise a :exc:`URLError` exception.
1008+
Raise a :exc:`~urllib.error.URLError` exception.
10081009

10091010

10101011
.. _http-error-processor-objects:
@@ -1021,7 +1022,7 @@ HTTPErrorProcessor Objects
10211022
For non-200 error codes, this simply passes the job on to the
10221023
:meth:`protocol_error_code` handler methods, via :meth:`OpenerDirector.error`.
10231024
Eventually, :class:`HTTPDefaultErrorHandler` will raise an
1024-
:exc:`HTTPError` if no other handler handles the error.
1025+
:exc:`~urllib.error.HTTPError` if no other handler handles the error.
10251026

10261027

10271028
.. method:: HTTPErrorProcessor.https_response()
@@ -1234,7 +1235,7 @@ some point in the future.
12341235
argument may be given to specify a ``POST`` request (normally the request
12351236
type is ``GET``). The *data* argument must be a bytes object in standard
12361237
:mimetype:`application/x-www-form-urlencoded` format; see the
1237-
:func:`urlencode` function below.
1238+
:func:`urllib.parse.urlencode` function.
12381239

12391240
:func:`urlretrieve` will raise :exc:`ContentTooShortError` when it detects that
12401241
the amount of data available was less than the expected amount (which is the
@@ -1316,8 +1317,8 @@ some point in the future.
13161317
If the *url* uses the :file:`http:` scheme identifier, the optional *data*
13171318
argument may be given to specify a ``POST`` request (normally the request type
13181319
is ``GET``). The *data* argument must in standard
1319-
:mimetype:`application/x-www-form-urlencoded` format; see the :func:`urlencode`
1320-
function below.
1320+
:mimetype:`application/x-www-form-urlencoded` format; see the
1321+
:func:`urllib.parse.urlencode` function.
13211322

13221323

13231324
.. attribute:: version

Doc/library/urllib.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
:mod:`urllib` --- URL handling modules
22
======================================
33

4+
.. module:: urllib
5+
46
``urllib`` is a package that collects several modules for working with URLs:
57

68
* :mod:`urllib.request` for opening and reading URLs

0 commit comments

Comments
 (0)