[Zope3-checkins] CVS: Zope3/src/zope/interface - implements.py:1.3
Stephan Richter
srichter@cbu.edu
Tue, 7 Jan 2003 07:15:27 -0500
Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv9036/interface
Modified Files:
implements.py
Log Message:
The flattenInterface() method was buggy, but since no code used it so far,
it was unnoticed. I added tests checking for the correct functionality.
=== Zope3/src/zope/interface/implements.py 1.2 => 1.3 ===
--- Zope3/src/zope/interface/implements.py:1.2 Wed Dec 25 09:13:42 2002
+++ Zope3/src/zope/interface/implements.py Tue Jan 7 07:14:53 2003
@@ -122,16 +122,19 @@
return r
def _flatten(i, append):
- append(i)
- bases = i.getBases()
- if bases:
- for b in bases:
- _flatten(b, append)
+ if isinstance(i, (list, tuple)):
+ for iface in i:
+ _flatten(iface, append)
+ else:
+ append(i)
+ bases = i.getBases()
+ if bases:
+ for b in bases:
+ _flatten(b, append)
def flattenInterfaces(interfaces, remove_duplicates=1):
res = []
- for i in interfaces:
- _flatten(i, res.append)
+ _flatten(interfaces, res.append)
if remove_duplicates:
# Remove duplicates in reverse.
# Similar to Python 2.2's method resolution order.