[Zodb-checkins] CVS: Zope3/src/zope/interface - interface.py:1.25 declarations.py:1.22 adapter.py:1.19

Itamar Shtull-Trauring zope at itamarst.org
Fri Apr 30 13:37:12 EDT 2004


Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv9779

Modified Files:
	interface.py declarations.py adapter.py 
Log Message:
Python 2.2 backwards compatability

to test - copy doctest.py from Python 2.3, and apply this patch:

1208c1208
<     if isinstance(doc, basestring) and '>>>' in doc:
---
>     if isinstance(doc, (str, unicode)) and doc.find('>>>') != -1:

then when you run test.py make sure it uses this doctest.py.

Note you will get some false failures right now due to new bool type in 2.3, but this shouldn't affect actual behaviour.


=== Zope3/src/zope/interface/interface.py 1.24 => 1.25 ===
--- Zope3/src/zope/interface/interface.py:1.24	Mon Mar  8 12:26:56 2004
+++ Zope3/src/zope/interface/interface.py	Fri Apr 30 13:37:10 2004
@@ -15,6 +15,9 @@
 
 $Id$
 """
+
+from __future__ import generators
+
 import sys
 import warnings
 import weakref
@@ -397,8 +400,12 @@
             __doc__ = ''
 
         Element.__init__(self, name, __doc__)
-        
-        tagged_data = attrs.pop(TAGGED_DATA, None)
+
+        if attrs.has_key(TAGGED_DATA):
+            tagged_data = attrs[TAGGED_DATA]
+            del attrs[TAGGED_DATA]
+        else:
+            tagged_data = None
         if tagged_data is not None:
             for key, val in tagged_data.items():
                 self.setTaggedValue(key, val)


=== Zope3/src/zope/interface/declarations.py 1.21 => 1.22 ===
--- Zope3/src/zope/interface/declarations.py:1.21	Mon Apr  5 15:43:59 2004
+++ Zope3/src/zope/interface/declarations.py	Fri Apr 30 13:37:10 2004
@@ -822,7 +822,12 @@
     if cls is None:
         cls = type(object)
 
-    if issubclass(cls, DescriptorAwareMetaClasses):
+    issub = False
+    for damc in DescriptorAwareMetaClasses:
+        if issubclass(cls, damc):
+            issub = True
+            break
+    if issub:
         # we have a class or type.  We'll use a special descriptor
         # that provides some extra caching
         object.__provides__ = ClassProvides(object, cls, *interfaces)


=== Zope3/src/zope/interface/adapter.py 1.18 => 1.19 ===
--- Zope3/src/zope/interface/adapter.py:1.18	Fri Apr 30 12:45:33 2004
+++ Zope3/src/zope/interface/adapter.py	Fri Apr 30 13:37:10 2004
@@ -18,7 +18,6 @@
 $Id$
 """
 
-
 # Implementation notes
 
 # We keep a collection of surrogates.
@@ -80,6 +79,7 @@
 # {('s', specification, order) -> {with -> tuple([object])}}
 
 
+from __future__ import generators
 
 import weakref
 from zope.interface.ro import ro
@@ -88,6 +88,21 @@
 
 Default = InterfaceClass("Default", (), {})
 Null = InterfaceClass("Null", (), {})
+
+# 2.2 backwards compatability
+try:
+    enumerate
+except NameError:
+    def enumerate(l):
+        i = 0
+        for o in l:
+            yield i, o
+            i += 1
+try:
+    basestring
+except NameError:
+    basestring = (str, unicode)
+
 
 class ReadProperty(object):
 




More information about the Zodb-checkins mailing list