[TransWarp] peak.interface doesn't coop with class-attributes that are classic classes

Ulrich Eck ueck at net-labs.de
Mon May 12 05:24:51 EDT 2003


Hi Phillip,

while running the unit-tests for our nll-library i found a bug in the
new peak.interface package.

the line:

 mro = type('tmp', (typ,), {}).__mro__

raises a:
 
TypeError: a new-style class can't have only classic bases

i could fix it temporarily by adding a new-style class to the bases:

Index: interface.py
===================================================================
RCS file: /cvsroot/PEAK/src/peak/interface.py,v
retrieving revision 1.9
diff -u -r1.9 interface.py
--- interface.py        2003/05/11 20:45:49     1.9
+++ interface.py        2003/05/12 09:20:55
@@ -123,6 +123,9 @@

 # Trivial interface implementation

+# Helper for Adapt-Protocol
+class _marker(object): pass
+
 class Protocol:

     """Generic protocol w/type-based adapter registry"""
@@ -175,9 +178,10 @@
         try:
             mro = typ.__mro__
         except AttributeError:
-            mro = type('tmp',(typ,),{}).__mro__
+            mro = type('tmp',(typ,_marker,),{}).__mro__

         for klass in mro:
+           if klass is _marker: continue
             factory=get(klass)
             if factory is not None:
                 return factory(obj,self)


cheers 

Ulrich

-- 
---------------------------------------

Ulrich Eck
net-labs Systemhaus GmbH
Ebersberger Str. 46
85570 Markt Schwaben - Germany

eMail: ueck <at> net-labs.de
phone: +49 8121 4747 10
fax:   +49 8121 4747 77




More information about the PEAK mailing list