[Python-checkins] r53871 - in sandbox/branches/setuptools-0.6: pkg_resources.py setuptools/tests/test_resources.py
phillip.eby
python-checkins at python.org
Fri Feb 23 20:28:26 CET 2007
Author: phillip.eby
Date: Fri Feb 23 20:28:25 2007
New Revision: 53871
Modified:
sandbox/branches/setuptools-0.6/pkg_resources.py
sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py
Log:
Get rid of 'sets' module usage under Python 2.4+, so that no warnings
are issued by Python 2.6. (backport from trunk)
Modified: sandbox/branches/setuptools-0.6/pkg_resources.py
==============================================================================
--- sandbox/branches/setuptools-0.6/pkg_resources.py (original)
+++ sandbox/branches/setuptools-0.6/pkg_resources.py Fri Feb 23 20:28:25 2007
@@ -14,10 +14,31 @@
"""
import sys, os, zipimport, time, re, imp, new
-from sets import ImmutableSet
+
+try:
+ frozenset
+except NameError:
+ from sets import ImmutableSet as frozenset
+
from os import utime, rename, unlink # capture these to bypass sandboxing
from os import open as os_open
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
def get_supported_platform():
"""Return this platform's maximum compatible version.
@@ -39,6 +60,26 @@
pass # not Mac OS X
return plat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
__all__ = [
# Basic resource access and distribution/entry point discovery
'require', 'run_script', 'get_provider', 'get_distribution',
@@ -2387,7 +2428,7 @@
self.index, self.extras = index, tuple(map(safe_extra,extras))
self.hashCmp = (
self.key, tuple([(op,parsed) for parsed,trans,op,ver in index]),
- ImmutableSet(self.extras)
+ frozenset(self.extras)
)
self.__hash = hash(self.hashCmp)
Modified: sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py Fri Feb 23 20:28:25 2007
@@ -1,7 +1,10 @@
from unittest import TestCase, makeSuite
from pkg_resources import *
import pkg_resources, sys
-from sets import ImmutableSet
+try:
+ frozenset
+except NameError:
+ from sets import ImmutableSet as frozenset
class Metadata(EmptyProvider):
"""Mock object to return metadata as if from an on-disk distribution"""
@@ -18,7 +21,6 @@
def get_metadata_lines(self,name):
return yield_lines(self.get_metadata(name))
-
class DistroTests(TestCase):
def testCollection(self):
@@ -337,7 +339,7 @@
self.assertEqual(hash(r1), hash(r2))
self.assertEqual(
hash(r1), hash(("twisted", ((">=",parse_version("1.2")),),
- ImmutableSet(["foo","bar"])))
+ frozenset(["foo","bar"])))
)
def testVersionEquality(self):
More information about the Python-checkins
mailing list