aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.hgtags1
-rw-r--r--CHANGES.txt7
-rw-r--r--setuptools/compat.py4
-rwxr-xr-xsetuptools/package_index.py6
-rw-r--r--setuptools/tests/test_packageindex.py18
5 files changed, 30 insertions, 6 deletions
diff --git a/.hgtags b/.hgtags
index c01565ac..ab959fc3 100644
--- a/.hgtags
+++ b/.hgtags
@@ -109,3 +109,4 @@ a197b626075a8c2e393a08c42a20bd2624a41092 1.3.1
0d1bdb99a535a2c7ed4edd37141fb0b54348b713 1.4b1
a13f8c18ce742bc83c794b9eea57980cb94ae18a 1.4
9a5f26d7df8ef779cb5f40cc0389343fb4c61365 1.4.1
+274cb3beba4f22d5f461b0578b6d56e171d94f2e 1.4.2
diff --git a/CHANGES.txt b/CHANGES.txt
index d28b07be..f04f5b91 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -15,6 +15,13 @@ CHANGES
should use ``pkgutil.ImpImporter`` instead.
-----
+1.4.2
+-----
+
+* Issue #116: Correct TypeError when reading a local package index on Python
+ 3.
+
+-----
1.4.1
-----
diff --git a/setuptools/compat.py b/setuptools/compat.py
index 8af8aa74..7b824ba2 100644
--- a/setuptools/compat.py
+++ b/setuptools/compat.py
@@ -26,7 +26,7 @@ if sys.version_info[0] < 3:
unichr = unichr
unicode = unicode
bytes = str
- from urllib import url2pathname, splittag
+ from urllib import url2pathname, splittag, pathname2url
import urllib2
from urllib2 import urlopen, HTTPError, URLError, unquote, splituser
from urlparse import urlparse, urlunparse, urljoin, urlsplit, urlunsplit
@@ -58,7 +58,7 @@ else:
bytes = bytes
from urllib.error import HTTPError, URLError
import urllib.request as urllib2
- from urllib.request import urlopen, url2pathname
+ from urllib.request import urlopen, url2pathname, pathname2url
from urllib.parse import (
urlparse, urlunparse, unquote, splituser, urljoin, urlsplit,
urlunsplit, splittag,
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 12a062b5..0e51b72c 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -1039,7 +1039,7 @@ def local_open(url):
files = []
for f in os.listdir(filename):
if f=='index.html':
- fp = open(os.path.join(filename,f),'rb')
+ fp = open(os.path.join(filename,f),'r')
body = fp.read()
fp.close()
break
@@ -1053,5 +1053,5 @@ def local_open(url):
else:
status, message, body = 404, "Path not found", "Not found"
- return HTTPError(url, status, message,
- {'content-type':'text/html'}, StringIO(body))
+ headers = {'content-type': 'text/html'}
+ return HTTPError(url, status, message, headers, StringIO(body))
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
index 08969b7e..664566a3 100644
--- a/setuptools/tests/test_packageindex.py
+++ b/setuptools/tests/test_packageindex.py
@@ -1,9 +1,10 @@
"""Package Index Tests
"""
import sys
+import os
import unittest
import pkg_resources
-from setuptools.compat import urllib2, httplib, HTTPError, unicode
+from setuptools.compat import urllib2, httplib, HTTPError, unicode, pathname2url
import distutils.errors
import setuptools.package_index
from setuptools.tests.server import IndexServer
@@ -151,6 +152,21 @@ class TestPackageIndex(unittest.TestCase):
self.assertEqual(url, 'https://example.com/bar')
self.assertEqual(rev, '2995')
+ def test_local_index(self):
+ """
+ local_open should be able to read an index from the file system.
+ """
+ f = open('index.html', 'w')
+ f.write('<div>content</div>')
+ f.close()
+ try:
+ url = 'file:' + pathname2url(os.getcwd()) + '/'
+ res = setuptools.package_index.local_open(url)
+ finally:
+ os.remove('index.html')
+ assert 'content' in res.read()
+
+
class TestContentCheckers(unittest.TestCase):
def test_md5(self):