Skip to content

Commit 2ed41f3

Browse files
committed
Issue #22989, #21228: Merge urlopen() doc from 3.5
2 parents 7a9d325 + 9e87f3d commit 2ed41f3

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Doc/library/urllib.request.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,7 @@ The :mod:`urllib.request` module defines the following functions:
5959

6060
The *cadefault* parameter is ignored.
6161

62-
For http and https urls, this function returns a
63-
:class:`http.client.HTTPResponse` object which has the following
64-
:ref:`httpresponse-objects` methods.
65-
66-
For ftp, file, and data urls and requests explicitly handled by legacy
67-
:class:`URLopener` and :class:`FancyURLopener` classes, this function
68-
returns a :class:`urllib.response.addinfourl` object which can work as
62+
This function always returns an object which can work as
6963
:term:`context manager` and has methods such as
7064

7165
* :meth:`~urllib.response.addinfourl.geturl` --- return the URL of the resource retrieved,
@@ -77,6 +71,18 @@ The :mod:`urllib.request` module defines the following functions:
7771

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

74+
For http and https urls, this function returns a
75+
:class:`http.client.HTTPResponse` object slightly modified. In addition
76+
to the three new methods above, the msg attribute contains the
77+
same information as the :attr:`~http.client.HTTPResponse.reason`
78+
attribute --- the reason phrase returned by server --- instead of
79+
the response headers as it is specified in the documentation for
80+
:class:`~http.client.HTTPResponse`.
81+
82+
For ftp, file, and data urls and requests explicitly handled by legacy
83+
:class:`URLopener` and :class:`FancyURLopener` classes, this function
84+
returns a :class:`urllib.response.addinfourl` object.
85+
8086
Raises :exc:`~urllib.error.URLError` on errors.
8187

8288
Note that ``None`` may be returned if no handler handles the request (though

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ Arnaud Fontaine
444444
Michael Foord
445445
Amaury Forgeot d'Arc
446446
Doug Fort
447+
Evens Fortuné
447448
Chris Foster
448449
John Fouhy
449450
Andrew Francis

0 commit comments

Comments
 (0)