aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--setuptools/compat.py5
-rwxr-xr-xsetuptools/package_index.py2
-rw-r--r--setuptools/py26compat.py19
3 files changed, 23 insertions, 3 deletions
diff --git a/setuptools/compat.py b/setuptools/compat.py
index e2f64de2..6094ca74 100644
--- a/setuptools/compat.py
+++ b/setuptools/compat.py
@@ -26,7 +26,7 @@ if sys.version_info[0] < 3:
reduce = reduce
unichr = unichr
unicode = unicode
- from urllib import url2pathname
+ from urllib import url2pathname, splittag
import urllib2
from urllib2 import urlopen, HTTPError, URLError, unquote, splituser
from urlparse import urlparse, urlunparse, urljoin
@@ -72,7 +72,8 @@ else:
from urllib.error import HTTPError, URLError
import urllib.request as urllib2
from urllib.request import urlopen, url2pathname
- from urllib.parse import urlparse, urlunparse, unquote, splituser, urljoin
+ from urllib.parse import (urlparse, urlunparse, unquote, splituser,
+ urljoin, splittag)
xrange = range
filterfalse = itertools.filterfalse
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 4c4a647d..a09048b4 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -657,7 +657,7 @@ class PackageIndex(Environment):
fp, tfp, info = None, None, None
try:
checker = HashChecker.from_url(url)
- fp = self.open_url(url)
+ fp = self.open_url(strip_fragment(url))
if isinstance(fp, HTTPError):
raise DistutilsError(
"Can't download %s: %s %s" % (url, fp.code,fp.msg)
diff --git a/setuptools/py26compat.py b/setuptools/py26compat.py
new file mode 100644
index 00000000..6fc00883
--- /dev/null
+++ b/setuptools/py26compat.py
@@ -0,0 +1,19 @@
+"""
+Compatibility Support for Python 2.6 and earlier
+"""
+
+import sys
+
+from setuptools.compat import splittag
+
+def strip_fragment(url):
+ """
+ In `Python 8280 <http://bugs.python.org/issue8280>`_, Python 2.7 and
+ later was patched to disregard the fragment when making URL requests.
+ Do the same for Python 2.6 and earlier.
+ """
+ url, fragment = splittag(url)
+ return url
+
+if sys.version_info < (2,7):
+ strip_fragment = lambda x: x