From edaefa4982e0aac7b07048c4761446ed66fec524 Mon Sep 17 00:00:00 2001 From: Alex Clark Date: Sun, 14 Aug 2011 19:18:17 -0400 Subject: Remove extraneous 2nd argument in call to open_url, apparently intended to issue a warning (looks like open_url takes an optional `warning` argument, but I couldn't get that to work either). Fixes #135. This fix is better than the status quo, but probably not as good as issuing a warning instead of failure. --HG-- branch : distribute extra : rebase_source : 39889bf4dd21abbd57207bfafe6f8bad68b1e46f --- setuptools/package_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/package_index.py') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index f064b110..c9e3d637 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -198,7 +198,7 @@ class PackageIndex(Environment): return self.info("Reading %s", url) - f = self.open_url(url, "Download error: %s -- Some packages may not be found!") + f = self.open_url(url) if f is None: return self.fetched_urls[url] = self.fetched_urls[f.url] = True -- cgit v1.2.3 From e6a12bbf1a51bb572145fd46715e2a20e54bfc52 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 17 Aug 2011 03:44:27 -0400 Subject: Include url in warning when processing URL. Fixes #135. --HG-- branch : distribute extra : rebase_source : 1241e1cb548adad562fcf61ce33538712a64aaed --- setuptools/package_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/package_index.py') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index f064b110..1dccabcb 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -198,7 +198,7 @@ class PackageIndex(Environment): return self.info("Reading %s", url) - f = self.open_url(url, "Download error: %s -- Some packages may not be found!") + f = self.open_url(url, "Download error on %s: %%s -- Some packages may not be found!" % url) if f is None: return self.fetched_urls[url] = self.fetched_urls[f.url] = True -- cgit v1.2.3 From bbe00513be4b20a82eb844dab52c15ca5e8e7113 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Dec 2011 12:55:33 -0500 Subject: Fix issue #262 - package_index.open_with_auth no longer throws LookupError on Python 3. --HG-- branch : distribute extra : rebase_source : ae4a0886ff89d3679f495f51171f94d3770e5d47 --- setuptools/package_index.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'setuptools/package_index.py') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index bb0ae129..d0896feb 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -1,5 +1,6 @@ """PyPI and direct package downloading""" import sys, os.path, re, urlparse, urllib, urllib2, shutil, random, socket, cStringIO +import base64 import httplib from pkg_resources import * from distutils import log @@ -756,6 +757,22 @@ def socket_timeout(timeout=15): return _socket_timeout return _socket_timeout +def _encode_auth(auth): + """ + A function compatible with Python 2.3-3.3 that will encode + auth from a URL suitable for an HTTP header. + >>> _encode_auth('username%3Apassword') + u'dXNlcm5hbWU6cGFzc3dvcmQ=' + """ + auth_s = urllib2.unquote(auth) + # convert to bytes + auth_bytes = auth_s.encode() + # use the legacy interface for Python 2.3 support + encoded_bytes = base64.encodestring(auth_bytes) + # convert back to a string + encoded = encoded_bytes.decode() + # strip the trailing carriage return + return encoded.rstrip() def open_with_auth(url): """Open a urllib2 request, handling HTTP authentication""" @@ -768,7 +785,7 @@ def open_with_auth(url): auth = None if auth: - auth = "Basic " + urllib2.unquote(auth).encode('base64').strip() + auth = "Basic " + _encode_auth(auth) new_url = urlparse.urlunparse((scheme,host,path,params,query,frag)) request = urllib2.Request(new_url) request.add_header("Authorization", auth) -- cgit v1.2.3 From 95907bcc8ddc3f87e46fdc6b9518d3c2f2a015ed Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Tue, 9 Oct 2012 18:38:21 +0200 Subject: Fix cause of test failure on Mac OS X. Refs #20. --HG-- branch : distribute extra : rebase_source : 92ba8151d6dfa3755b31139a9b5ada570183731d --- setuptools/package_index.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'setuptools/package_index.py') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index d0896feb..ffbffa99 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -779,6 +779,12 @@ def open_with_auth(url): scheme, netloc, path, params, query, frag = urlparse.urlparse(url) + # Double scheme does not raise on Mac OS X as revealed by a + # failing test. We would expect "nonnumeric port". Refs #20. + if sys.platform == 'darwin': + if netloc.endswith(':'): + raise httplib.InvalidURL("nonnumeric port: ''") + if scheme in ('http', 'https'): auth, host = urllib2.splituser(netloc) else: @@ -859,4 +865,4 @@ def local_open(url): -# this line is a kludge to keep the trailing blank lines for pje's editor \ No newline at end of file +# this line is a kludge to keep the trailing blank lines for pje's editor -- cgit v1.2.3