Skip to content

Commit 5e1c053

Browse files
Improve #19204: Improved cross-references in the urllib package documentation.
1 parent b7117af commit 5e1c053

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

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

@@ -47,7 +48,8 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
4748

4849
.. exception:: ContentTooShortError(msg, content)
4950

50-
This exception is raised when the :func:`urlretrieve` function detects that
51+
This exception is raised when the :func:`~urllib.request.urlretrieve`
52+
function detects that
5153
the amount of the downloaded data is less than the expected amount (given by
5254
the *Content-Length* header). The :attr:`content` attribute stores the
5355
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

@@ -240,7 +240,7 @@ The following classes are provided:
240240
.. class:: HTTPDefaultErrorHandler()
241241

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

245245

246246
.. class:: HTTPRedirectHandler()
@@ -614,8 +614,8 @@ sorting the handler instances.
614614

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

620620
In fact, the above algorithm is first tried for methods named
621621
:meth:`default_open`. If all such methods return :const:`None`, the algorithm
@@ -674,8 +674,9 @@ The following attribute and methods should only be used by classes derived from
674674
This method, if implemented, will be called by the parent
675675
:class:`OpenerDirector`. It should return a file-like object as described in
676676
the return value of the :meth:`open` of :class:`OpenerDirector`, or ``None``.
677-
It should raise :exc:`URLError`, unless a truly exceptional thing happens (for
678-
example, :exc:`MemoryError` should not be mapped to :exc:`URLError`).
677+
It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional
678+
thing happens (for example, :exc:`MemoryError` should not be mapped to
679+
:exc:`URLError`).
679680

680681
This method will be called before any protocol-specific open method.
681682

@@ -761,8 +762,8 @@ HTTPRedirectHandler Objects
761762
.. note::
762763

763764
Some HTTP redirections require action from this module's client code. If this
764-
is the case, :exc:`HTTPError` is raised. See :rfc:`2616` for details of the
765-
precise meanings of the various redirection codes.
765+
is the case, :exc:`~urllib.error.HTTPError` is raised. See :rfc:`2616` for
766+
details of the precise meanings of the various redirection codes.
766767

767768
An :class:`HTTPError` exception raised as a security consideration if the
768769
HTTPRedirectHandler is presented with a redirected url which is not an HTTP,
@@ -775,9 +776,9 @@ HTTPRedirectHandler Objects
775776
by the default implementations of the :meth:`http_error_30\*` methods when a
776777
redirection is received from the server. If a redirection should take place,
777778
return a new :class:`Request` to allow :meth:`http_error_30\*` to perform the
778-
redirect to *newurl*. Otherwise, raise :exc:`HTTPError` if no other handler
779-
should try to handle this URL, or return ``None`` if you can't but another
780-
handler might.
779+
redirect to *newurl*. Otherwise, raise :exc:`~urllib.error.HTTPError` if
780+
no other handler should try to handle this URL, or return ``None`` if you
781+
can't but another handler might.
781782

782783
.. note::
783784

@@ -979,7 +980,7 @@ FileHandler Objects
979980

980981
.. versionchanged:: 3.2
981982
This method is applicable only for local hostnames. When a remote
982-
hostname is given, an :exc:`URLError` is raised.
983+
hostname is given, an :exc:`~urllib.error.URLError` is raised.
983984

984985

985986
.. _ftp-handler-objects:
@@ -1021,7 +1022,7 @@ UnknownHandler Objects
10211022

10221023
.. method:: UnknownHandler.unknown_open()
10231024

1024-
Raise a :exc:`URLError` exception.
1025+
Raise a :exc:`~urllib.error.URLError` exception.
10251026

10261027

10271028
.. _http-error-processor-objects:
@@ -1038,7 +1039,7 @@ HTTPErrorProcessor Objects
10381039
For non-200 error codes, this simply passes the job on to the
10391040
:meth:`protocol_error_code` handler methods, via :meth:`OpenerDirector.error`.
10401041
Eventually, :class:`HTTPDefaultErrorHandler` will raise an
1041-
:exc:`HTTPError` if no other handler handles the error.
1042+
:exc:`~urllib.error.HTTPError` if no other handler handles the error.
10421043

10431044

10441045
.. method:: HTTPErrorProcessor.https_response()
@@ -1251,7 +1252,7 @@ some point in the future.
12511252
argument may be given to specify a ``POST`` request (normally the request
12521253
type is ``GET``). The *data* argument must be a bytes object in standard
12531254
:mimetype:`application/x-www-form-urlencoded` format; see the
1254-
:func:`urlencode` function below.
1255+
:func:`urllib.parse.urlencode` function.
12551256

12561257
:func:`urlretrieve` will raise :exc:`ContentTooShortError` when it detects that
12571258
the amount of data available was less than the expected amount (which is the
@@ -1333,8 +1334,8 @@ some point in the future.
13331334
If the *url* uses the :file:`http:` scheme identifier, the optional *data*
13341335
argument may be given to specify a ``POST`` request (normally the request type
13351336
is ``GET``). The *data* argument must in standard
1336-
:mimetype:`application/x-www-form-urlencoded` format; see the :func:`urlencode`
1337-
function below.
1337+
:mimetype:`application/x-www-form-urlencoded` format; see the
1338+
:func:`urllib.parse.urlencode` function.
13381339

13391340

13401341
.. 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)