summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorAshwin Ramaswami <aramaswamis@gmail.com>2019-09-13 11:40:08 (GMT)
committerStéphane Wirtel <stephane@wirtel.be>2019-09-13 11:40:07 (GMT)
commitff2e18286560e981f4e09afb0d2448ea994414d8 (patch)
tree9a339486705cfbc5d6b183ffdf11ad686b256b1d /Lib/urllib
parentbb41147eab15a2958f4ad38261e5bf608f6ace1b (diff)
downloadcpython-ff2e18286560e981f4e09afb0d2448ea994414d8.zip
cpython-ff2e18286560e981f4e09afb0d2448ea994414d8.tar.gz
cpython-ff2e18286560e981f4e09afb0d2448ea994414d8.tar.bz2
bpo-12707: deprecate info(), geturl(), getcode() methods in favor of headers, url, and status properties for HTTPResponse and addinfourl (GH-11447)
Co-Authored-By: epicfaace <aramaswamis@gmail.com>
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/request.py14
-rw-r--r--Lib/urllib/response.py4
2 files changed, 7 insertions, 11 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index f6ce9cb..267a90d 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -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
+ context manager and has the properties url, headers, and status.
+ See urllib.response.addinfourl for more detail on these properties.
For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse
object slightly modified. In addition to the three new methods above, the
diff --git a/Lib/urllib/response.py b/Lib/urllib/response.py
index 4778118..5a2c3cc 100644
--- a/Lib/urllib/response.py
+++ b/Lib/urllib/response.py
@@ -73,6 +73,10 @@ class addinfourl(addinfo):
self.url = url
self.code = code
+ @property
+ def status(self):
+ return self.code
+
def getcode(self):
return self.code