Mercurial > hg
changeset 31399:1ed169c5e235
pycompat: alias urllib symbols directly
urllib.request imports a bunch of symbols from other urllib
modules. We should map to the original symbols not the
re-exported ones because this is more correct. Also, it
will prevent an import of urllib.request if only one of
the lower-level symbols/modules is needed.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 13 Mar 2017 12:14:17 -0700 |
parents | d785fed7c115 |
children | fb1f70331ee6 |
files | mercurial/pycompat.py |
diffstat | 1 files changed, 14 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pycompat.py Mon Mar 13 13:08:11 2017 -0700 +++ b/mercurial/pycompat.py Mon Mar 13 12:14:17 2017 -0700 @@ -267,11 +267,18 @@ )) else: + import urllib.parse + urlreq._registeraliases(urllib.parse, ( + "quote", + "splitattr", + "splitpasswd", + "splitport", + "splituser", + "unquote", + )) import urllib.request urlreq._registeraliases(urllib.request, ( "AbstractHTTPHandler", - "addclosehook", - "addinfourl", "BaseHandler", "build_opener", "FileHandler", @@ -285,16 +292,15 @@ "HTTPDigestAuthHandler", "HTTPPasswordMgrWithDefaultRealm", "ProxyHandler", - "quote", "Request", - "splitattr", - "splitpasswd", - "splitport", - "splituser", - "unquote", "url2pathname", "urlopen", )) + import urllib.response + urlreq._registeraliases(urllib.response, ( + "addclosehook", + "addinfourl", + )) import urllib.error urlerr._registeraliases(urllib.error, ( "HTTPError",