summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorRĂ©mi Lapeyre <remi.lapeyre@henki.fr>2019-05-27 13:43:45 (GMT)
committerCheryl Sabella <cheryl.sabella@gmail.com>2019-05-27 13:43:45 (GMT)
commit674ee1260025ff36f27e5d70ff6b66e3aab880bf (patch)
tree454d232beffc625bac7a51a9b2ae5e63818e774a /Lib/urllib
parent1f39c28e489cca0397fc4c3675d13569318122ac (diff)
downloadcpython-674ee1260025ff36f27e5d70ff6b66e3aab880bf.zip
cpython-674ee1260025ff36f27e5d70ff6b66e3aab880bf.tar.gz
cpython-674ee1260025ff36f27e5d70ff6b66e3aab880bf.tar.bz2
bpo-35397: Remove deprecation and document urllib.parse.unwrap (GH-11481)
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/parse.py12
-rw-r--r--Lib/urllib/request.py8
2 files changed, 9 insertions, 11 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index dfba704..daefb20 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -979,17 +979,15 @@ def _to_bytes(url):
def unwrap(url):
- warnings.warn("urllib.parse.unwrap() is deprecated as of 3.8",
- DeprecationWarning, stacklevel=2)
- return _unwrap(url)
-
+ """Transform a string like '<URL:scheme://host/path>' into 'scheme://host/path'.
-def _unwrap(url):
- """unwrap('<URL:type://host/path>') --> 'type://host/path'."""
+ The string is returned unchanged if it's not a wrapped URL.
+ """
url = str(url).strip()
if url[:1] == '<' and url[-1:] == '>':
url = url[1:-1].strip()
- if url[:4] == 'URL:': url = url[4:].strip()
+ if url[:4] == 'URL:':
+ url = url[4:].strip()
return url
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index afce8eb..f6ce9cb 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -101,7 +101,7 @@ import warnings
from urllib.error import URLError, HTTPError, ContentTooShortError
from urllib.parse import (
- urlparse, urlsplit, urljoin, _unwrap, quote, unquote,
+ urlparse, urlsplit, urljoin, unwrap, quote, unquote,
_splittype, _splithost, _splitport, _splituser, _splitpasswd,
_splitattr, _splitquery, _splitvalue, _splittag, _to_bytes,
unquote_to_bytes, urlunparse)
@@ -349,7 +349,7 @@ class Request:
@full_url.setter
def full_url(self, url):
# unwrap('<URL:type://host/path>') --> 'type://host/path'
- self._full_url = _unwrap(url)
+ self._full_url = unwrap(url)
self._full_url, self.fragment = _splittag(self._full_url)
self._parse()
@@ -1727,7 +1727,7 @@ class URLopener:
# External interface
def open(self, fullurl, data=None):
"""Use URLopener().open(file) instead of open(file, 'r')."""
- fullurl = _unwrap(_to_bytes(fullurl))
+ fullurl = unwrap(_to_bytes(fullurl))
fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
if self.tempcache and fullurl in self.tempcache:
filename, headers = self.tempcache[fullurl]
@@ -1775,7 +1775,7 @@ class URLopener:
def retrieve(self, url, filename=None, reporthook=None, data=None):
"""retrieve(url) returns (filename, headers) for a local object
or (tempfilename, headers) for a remote object."""
- url = _unwrap(_to_bytes(url))
+ url = unwrap(_to_bytes(url))
if self.tempcache and url in self.tempcache:
return self.tempcache[url]
type, url1 = _splittype(url)