[pypy-svn] r22773 - in pypy/dist/pypy/annotation: . test
pedronis at codespeak.net
pedronis at codespeak.net
Sat Jan 28 12:53:46 CET 2006
Author: pedronis
Date: Sat Jan 28 12:53:44 2006
New Revision: 22773
Modified:
pypy/dist/pypy/annotation/pairtype.py
pypy/dist/pypy/annotation/test/test_pairtype.py
Log:
(arre, arigo, pedronis)
support extending many classes in one __extend__ pseudo-class definition.
Modified: pypy/dist/pypy/annotation/pairtype.py
==============================================================================
--- pypy/dist/pypy/annotation/pairtype.py (original)
+++ pypy/dist/pypy/annotation/pairtype.py Sat Jan 28 12:53:44 2006
@@ -7,12 +7,12 @@
the definition of 't' instead of creating a new subclass."""
def __new__(cls, name, bases, dict):
if name == '__extend__':
- cls = bases[0] # override data into the existing base
- for key, value in dict.items():
- if key == '__module__':
- continue
+ for cls in bases:
+ for key, value in dict.items():
+ if key == '__module__':
+ continue
# XXX do we need to provide something more for pickling?
- setattr(cls, key, value)
+ setattr(cls, key, value)
return None
else:
return super(extendabletype, cls).__new__(cls, name, bases, dict)
Modified: pypy/dist/pypy/annotation/test/test_pairtype.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_pairtype.py (original)
+++ pypy/dist/pypy/annotation/test/test_pairtype.py Sat Jan 28 12:53:44 2006
@@ -1,5 +1,5 @@
-from pypy.annotation.pairtype import pairtype, pair
+from pypy.annotation.pairtype import pairtype, pair, extendabletype
def test_binop():
### Binary operation example
@@ -91,3 +91,20 @@
g = Lisp_Generator()
pair(g, Block(Switch())).emit(['v1', 'v2'])
assert g.progn == ["(do 'something)"]
+
+def test_multiple_extend():
+ class A:
+ __metaclass__ = extendabletype
+ class B:
+ __metaclass__ = extendabletype
+
+ class __extend__(A,B):
+
+ def f(self):
+ pass
+
+ assert hasattr(A, 'f')
+ assert hasattr(B, 'f')
+
+
+
More information about the Pypy-commit
mailing list