[Checkins] SVN: zope.interface/branches/regebro-python3/src/zope/interface/ Python 3 doesn't have cmp() or ClassType, so we avoid this. 123 tests currently succeed, 20 fail.
Lennart Regebro
regebro at gmail.com
Wed Apr 8 07:08:44 EDT 2009
Log message for revision 99005:
Python 3 doesn't have cmp() or ClassType, so we avoid this. 123 tests currently succeed, 20 fail.
Changed:
U zope.interface/branches/regebro-python3/src/zope/interface/interface.py
U zope.interface/branches/regebro-python3/src/zope/interface/tests/odd.py
-=-
Modified: zope.interface/branches/regebro-python3/src/zope/interface/interface.py
===================================================================
--- zope.interface/branches/regebro-python3/src/zope/interface/interface.py 2009-04-08 10:47:27 UTC (rev 99004)
+++ zope.interface/branches/regebro-python3/src/zope/interface/interface.py 2009-04-08 11:08:44 UTC (rev 99005)
@@ -675,7 +675,7 @@
n2 = (getattr(o2, '__name__', ''),
getattr(getattr(o2, '__module__', None), '__name__', ''))
- return cmp(n1, n2)
+ return (n1 > n2) - (n1 < n2)
def __lt__(self, other):
c = self.__cmp(self, other)
Modified: zope.interface/branches/regebro-python3/src/zope/interface/tests/odd.py
===================================================================
--- zope.interface/branches/regebro-python3/src/zope/interface/tests/odd.py 2009-04-08 10:47:27 UTC (rev 99004)
+++ zope.interface/branches/regebro-python3/src/zope/interface/tests/odd.py 2009-04-08 11:08:44 UTC (rev 99005)
@@ -21,8 +21,8 @@
...
>>> A.__name__
'A'
- >>> A.__bases__
- (<type 'object'>,)
+ >>> A.__bases__ == (object,)
+ True
>>> class B(object):
... __metaclass__ = MetaClass
... b = 1
@@ -55,9 +55,11 @@
>>> C.c = 1
>>> c.c
1
- >>> from types import ClassType
- >>> int(isinstance(C, (type, ClassType)))
- 0
+ >>> import sys
+ >>> if sys.version[0] == '2': # This test only makes sense under Python 2.x
+ ... from types import ClassType
+ ... assert not isinstance(C, (type, ClassType))
+
>>> int(C.__class__.__class__ is C.__class__)
1
More information about the Checkins
mailing list