-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
bpo-12707: deprecate info(), geturl(), getcode() methods in favor of headers, url, and status properties for HTTPResponse and addinfourl #11447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
18a7eac
2e93da4
2db7e1f
beadb34
2a16f9b
f07f456
5640148
51cd8ad
c199098
58ced25
13d373f
357c8b4
b99fb9f
1cf719c
2c3a63f
c57eb8c
2174ea5
47f1656
10d4720
1a36dfc
c0e78bc
febc206
73a5a9a
1f8b27b
ac31a4a
c9e8110
61385d8
2ee88dd
d7575f0
628c2f0
5f5b2f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,16 +55,8 @@ The :mod:`urllib.request` module defines the following functions: | |
The *cadefault* parameter is ignored. | ||
|
||
This function always returns an object which can work as a | ||
:term:`context manager` and has methods such as | ||
|
||
* :meth:`~urllib.response.addinfourl.geturl` --- return the URL of the resource retrieved, | ||
commonly used to determine if a redirect was followed | ||
|
||
* :meth:`~urllib.response.addinfourl.info` --- return the meta-information of the page, such as headers, | ||
in the form of an :func:`email.message_from_string` instance (see | ||
`Quick Reference to HTTP Headers <http://jkorpela.fi/http.html>`_) | ||
|
||
* :meth:`~urllib.response.addinfourl.getcode` -- return the HTTP status code of the response. | ||
:term:`context manager` and has the properties *url*, *headers*, and *status*. | ||
See :class:`urllib.response.addinfourl` for more detail on these properties. | ||
|
||
For HTTP and HTTPS URLs, this function returns a | ||
:class:`http.client.HTTPResponse` object slightly modified. In addition | ||
|
@@ -1557,9 +1549,38 @@ some point in the future. | |
:synopsis: Response classes used by urllib. | ||
|
||
The :mod:`urllib.response` module defines functions and classes which define a | ||
minimal file like interface, including ``read()`` and ``readline()``. The | ||
typical response object is an addinfourl instance, which defines an ``info()`` | ||
method and that returns headers and a ``geturl()`` method that returns the url. | ||
Functions defined by this module are used internally by the | ||
:mod:`urllib.request` module. | ||
minimal file-like interface, including ``read()`` and ``readline()``. | ||
Functions defined by this module are used internally by the :mod:`urllib.request` module. | ||
The typical response object is a :class:`urllib.response.addinfourl` instance: | ||
|
||
.. class:: urllib.response.addinfourl | ||
merwok marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. attribute:: addinfourl.url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid repeating the class name, nest the attribute/method directives under the class directive: .. class:: addinfourl
.. attribute:: headers (adding the module name to the class is not needed because the file has a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thanks. |
||
|
||
URL of the resource retrieved, commonly used to determine if a redirect was followed. | ||
|
||
.. attribute:: addinfourl.headers | ||
|
||
Returns the headers of the response in the form of an :class:`~email.message.EmailMessage` instance. | ||
|
||
.. attribute:: addinfourl.status | ||
|
||
.. versionadded:: 3.8 | ||
|
||
Status code returned by server. | ||
|
||
.. method:: addinfourl.geturl() | ||
|
||
Deprecated method equivalent to :attr:`~addinfourl.url`. | ||
|
||
.. method:: addinfourl.info() | ||
|
||
Deprecated method equivalent to :attr:`~addinfourl.headers`. | ||
|
||
.. attribute:: addinfourl.code | ||
|
||
Deprecated attribute equivalent to :attr:`~addinfourl.status`. | ||
|
||
.. method:: addinfourl.getstatus() | ||
|
||
Deprecated method equivalent to :attr:`~addinfourl.status`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,18 +163,10 @@ def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, | |
|
||
The *cadefault* parameter is ignored. | ||
|
||
This function always returns an object which can work as a context | ||
manager and has methods such as | ||
|
||
* geturl() - return the URL of the resource retrieved, commonly used to | ||
determine if a redirect was followed | ||
|
||
* info() - return the meta-information of the page, such as headers, in the | ||
form of an email.message_from_string() instance (see Quick Reference to | ||
HTTP Headers) | ||
|
||
* getcode() - return the HTTP status code of the response. Raises URLError | ||
on errors. | ||
This function always returns an object which can work as a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation here is wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed it, thanks! |
||
:term:`context manager` and has the properties `url`, `headers`, and `status`. | ||
See `urllib.response.addinfourl` for more detail on these properties. | ||
epicfaace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse | ||
object slightly modified. In addition to the three new methods above, the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use
Check for the other attributes and the right syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree! Why generate a link to the section that we’re already in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've done something in between by starting the sentence just with "Deprecated in favor" while still keeping the
deprecated::
markup.