[Zope3-checkins] CVS: Zope3/lib/python/Interface - _InterfaceClass.py:1.8

Jeremy Hylton jeremy@zope.com
Mon, 22 Jul 2002 13:01:40 -0400


Update of /cvs-repository/Zope3/lib/python/Interface
In directory cvs.zope.org:/tmp/cvs-serv13304

Modified Files:
	_InterfaceClass.py 
Log Message:
Make sure that __bases__ is a tuple (and some code reformatting).

It doesn't seem to affect Interface, but at least issubclass() cares
about whether __bases__ is a tuple.  If it is a list, then
issubclass() will complain that the object isn't a class.  

XXX One might argue that an Inteface is not a class.  I'm not sure if
that's a sound position, but this change makes issubclass() happy.


=== Zope3/lib/python/Interface/_InterfaceClass.py 1.7 => 1.8 ===
         for b in bases:
             if not isinstance(b, Interface):
                 raise TypeError, 'Expected base interfaces'
-        self.__bases__=bases
+        # Python expects __bases__ to be a tuple.
+        self.__bases__ = tuple(bases)
 
-        if attrs is None: attrs={}
+        if attrs is None:
+            attrs = {}
         if '__doc__' in attrs:
-            if __doc__ is None: __doc__=attrs['__doc__']
+            if __doc__ is None:
+                __doc__ = attrs['__doc__']
             del attrs['__doc__']
 
         if __doc__ is not None:
-            self.__doc__=__doc__
+            self.__doc__ = __doc__
         else:
             self.__doc__ = ""
 
@@ -69,14 +72,13 @@
 
         for k, v in attrs.items():
             if isinstance(v, Attribute):
-                v.interface=name
+                v.interface = name
                 if not v.__name__:
                     v.__name__ = k
             elif isinstance(v, FunctionType):
-                attrs[k]=fromFunction(v, name, name=k)
+                attrs[k] = fromFunction(v, name, name=k)
             else:
-                raise Exceptions.InvalidInterface(
-                    "Concrete attribute, %s" % k)
+                raise Exceptions.InvalidInterface("Concrete attribute, %s" % k)
 
         self.__attrs = attrs