Commits

Jason R. Coombs committed d0dfd2f

Correct 404 errors when URLs contain fragments. Fixes #69.

Comments (0)

Files changed (3)

setuptools/compat.py

     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
     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
 

setuptools/package_index.py

         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)

setuptools/py26compat.py

+"""
+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