aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-02-03 09:22:19 -0500
committerJason R. Coombs <jaraco@jaraco.com>2019-02-03 09:22:19 -0500
commit0830a69efde3d561c2025bdfa1fae10dcbbcc8ed (patch)
treef468ca98bbbfe928db7057a35426949c5bd15830
parent28605704049b638d9a71c010b7cbe8dc6a8d37fc (diff)
downloadexternal_python_setuptools-0830a69efde3d561c2025bdfa1fae10dcbbcc8ed.tar.gz
external_python_setuptools-0830a69efde3d561c2025bdfa1fae10dcbbcc8ed.tar.bz2
external_python_setuptools-0830a69efde3d561c2025bdfa1fae10dcbbcc8ed.zip
Revert to using a copy of splituser from Python 3.8. Using urllib.parse.urlparse is clumsy and causes problems as reported in #1663 and #1668. Alternative to #1499 and fixes #1668.
-rw-r--r--setuptools/package_index.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index ea76c005..05c9e341 100644
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -850,16 +850,13 @@ class PackageIndex(Environment):
def _download_svn(self, url, filename):
warnings.warn("SVN download support is deprecated", UserWarning)
- def splituser(host):
- user, delim, host = host.rpartition('@')
- return user, host
url = url.split('#', 1)[0] # remove any fragment for svn's sake
creds = ''
if url.lower().startswith('svn:') and '@' in url:
scheme, netloc, path, p, q, f = urllib.parse.urlparse(url)
if not netloc and path.startswith('//') and '/' in path[2:]:
netloc, path = path[2:].split('/', 1)
- auth, host = splituser(netloc)
+ auth, host = _splituser(netloc)
if auth:
if ':' in auth:
user, pw = auth.split(':', 1)
@@ -1058,8 +1055,8 @@ def open_with_auth(url, opener=urllib.request.urlopen):
if netloc.endswith(':'):
raise http_client.InvalidURL("nonnumeric port: ''")
- if scheme in ('http', 'https') and parsed.username:
- auth = ':'.join((parsed.username, parsed.password))
+ if scheme in ('http', 'https'):
+ auth, address = _splituser(netloc)
else:
auth = None
@@ -1072,7 +1069,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
if auth:
auth = "Basic " + _encode_auth(auth)
- parts = scheme, netloc, path, params, query, frag
+ parts = scheme, address, path, params, query, frag
new_url = urllib.parse.urlunparse(parts)
request = urllib.request.Request(new_url)
request.add_header("Authorization", auth)
@@ -1093,6 +1090,13 @@ def open_with_auth(url, opener=urllib.request.urlopen):
return fp
+# copy of urllib.parse._splituser from Python 3.8
+def _splituser(host):
+ """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
+ user, delim, host = host.rpartition('@')
+ return (user if delim else None), host
+
+
# adding a timeout to avoid freezing package_index
open_with_auth = socket_timeout(_SOCKET_TIMEOUT)(open_with_auth)