summaryrefslogtreecommitdiff
path: root/pkg_resources
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-12-09 08:16:33 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-12-09 08:53:50 -0500
commitf14930e66601b462699c44384c482cd966f53b8f (patch)
treebea29134419118c1bcb95ca589da5a8e2372e089 /pkg_resources
parentac9997648d89131412eacbb198e2d3a7c97f69e4 (diff)
downloadpython-setuptools-git-f14930e66601b462699c44384c482cd966f53b8f.tar.gz
Drop support for Python 2.6, removing lots of compatibility code for a leaner, cleaner codebase. Fixes #878.
Diffstat (limited to 'pkg_resources')
-rw-r--r--pkg_resources/__init__.py24
-rw-r--r--pkg_resources/api_tests.txt4
-rw-r--r--pkg_resources/tests/test_resources.py28
3 files changed, 14 insertions, 42 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 92503288..d8000b00 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -1611,7 +1611,7 @@ class ZipManifests(dict):
Use a platform-specific path separator (os.sep) for the path keys
for compatibility with pypy on Windows.
"""
- with ContextualZipFile(path) as zfile:
+ with zipfile.ZipFile(path) as zfile:
items = (
(
name.replace('/', os.sep),
@@ -1644,26 +1644,6 @@ class MemoizedZipManifests(ZipManifests):
return self[path].manifest
-class ContextualZipFile(zipfile.ZipFile):
- """
- Supplement ZipFile class to support context manager for Python 2.6
- """
-
- def __enter__(self):
- return self
-
- def __exit__(self, type, value, traceback):
- self.close()
-
- def __new__(cls, *args, **kwargs):
- """
- Construct a ZipFile or ContextualZipFile as appropriate
- """
- if hasattr(zipfile.ZipFile, '__exit__'):
- return zipfile.ZipFile(*args, **kwargs)
- return super(ContextualZipFile, cls).__new__(cls)
-
-
class ZipProvider(EggProvider):
"""Resource support for zips and eggs"""
@@ -1861,7 +1841,7 @@ class FileMetadata(EmptyProvider):
return metadata
def _warn_on_replacement(self, metadata):
- # Python 2.6 and 3.2 compat for: replacement_char = '�'
+ # Python 2.7 compat for: replacement_char = '�'
replacement_char = b'\xef\xbf\xbd'.decode('utf-8')
if replacement_char in metadata:
tmpl = "{self.path} could not be properly decoded in UTF-8"
diff --git a/pkg_resources/api_tests.txt b/pkg_resources/api_tests.txt
index 4fbd3d23..0a75170e 100644
--- a/pkg_resources/api_tests.txt
+++ b/pkg_resources/api_tests.txt
@@ -385,10 +385,10 @@ Environment Markers
>>> em("sys_platform=='win32'") == (sys.platform=='win32')
True
- >>> em("python_version >= '2.6'")
+ >>> em("python_version >= '2.7'")
True
- >>> em("python_version > '2.5'")
+ >>> em("python_version > '2.6'")
True
>>> im("implementation_name=='cpython'")
diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py
index 00ca7426..8223963c 100644
--- a/pkg_resources/tests/test_resources.py
+++ b/pkg_resources/tests/test_resources.py
@@ -206,12 +206,10 @@ class TestDistro:
"""Extras are also evaluated as markers at resolution time."""
ad = pkg_resources.Environment([])
ws = WorkingSet([])
- # Metadata needs to be native strings due to cStringIO behaviour in
- # 2.6, so use str().
Foo = Distribution.from_filename(
"/foo_dir/Foo-1.2.dist-info",
- metadata=Metadata(("METADATA", str("Provides-Extra: baz\n"
- "Requires-Dist: quux; extra=='baz'")))
+ metadata=Metadata(("METADATA", "Provides-Extra: baz\n"
+ "Requires-Dist: quux; extra=='baz'"))
)
ad.add(Foo)
assert list(ws.resolve(parse_requirements("Foo"), ad)) == [Foo]
@@ -224,12 +222,10 @@ class TestDistro:
"""Extras are also evaluated as markers at resolution time."""
ad = pkg_resources.Environment([])
ws = WorkingSet([])
- # Metadata needs to be native strings due to cStringIO behaviour in
- # 2.6, so use str().
Foo = Distribution.from_filename(
"/foo_dir/Foo-1.2.dist-info",
- metadata=Metadata(("METADATA", str("Provides-Extra: baz-lightyear\n"
- "Requires-Dist: quux; extra=='baz-lightyear'")))
+ metadata=Metadata(("METADATA", "Provides-Extra: baz-lightyear\n"
+ "Requires-Dist: quux; extra=='baz-lightyear'"))
)
ad.add(Foo)
assert list(ws.resolve(parse_requirements("Foo"), ad)) == [Foo]
@@ -241,14 +237,12 @@ class TestDistro:
def test_marker_evaluation_with_multiple_extras(self):
ad = pkg_resources.Environment([])
ws = WorkingSet([])
- # Metadata needs to be native strings due to cStringIO behaviour in
- # 2.6, so use str().
Foo = Distribution.from_filename(
"/foo_dir/Foo-1.2.dist-info",
- metadata=Metadata(("METADATA", str("Provides-Extra: baz\n"
+ metadata=Metadata(("METADATA", "Provides-Extra: baz\n"
"Requires-Dist: quux; extra=='baz'\n"
"Provides-Extra: bar\n"
- "Requires-Dist: fred; extra=='bar'\n")))
+ "Requires-Dist: fred; extra=='bar'\n"))
)
ad.add(Foo)
quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info")
@@ -261,22 +255,20 @@ class TestDistro:
def test_marker_evaluation_with_extras_loop(self):
ad = pkg_resources.Environment([])
ws = WorkingSet([])
- # Metadata needs to be native strings due to cStringIO behaviour in
- # 2.6, so use str().
a = Distribution.from_filename(
"/foo_dir/a-0.2.dist-info",
- metadata=Metadata(("METADATA", str("Requires-Dist: c[a]")))
+ metadata=Metadata(("METADATA", "Requires-Dist: c[a]"))
)
b = Distribution.from_filename(
"/foo_dir/b-0.3.dist-info",
- metadata=Metadata(("METADATA", str("Requires-Dist: c[b]")))
+ metadata=Metadata(("METADATA", "Requires-Dist: c[b]"))
)
c = Distribution.from_filename(
"/foo_dir/c-1.0.dist-info",
- metadata=Metadata(("METADATA", str("Provides-Extra: a\n"
+ metadata=Metadata(("METADATA", "Provides-Extra: a\n"
"Requires-Dist: b;extra=='a'\n"
"Provides-Extra: b\n"
- "Requires-Dist: foo;extra=='b'")))
+ "Requires-Dist: foo;extra=='b'"))
)
foo = Distribution.from_filename("/foo_dir/foo-0.1.dist-info")
for dist in (a, b, c, foo):