[pypy-svn] r12044 - in pypy/dist/pypy/objspace/std: . test
pedronis at codespeak.net
pedronis at codespeak.net
Sat May 7 01:16:33 CEST 2005
Author: pedronis
Date: Sat May 7 01:16:33 2005
New Revision: 12044
Modified:
pypy/dist/pypy/objspace/std/test/test_typeobject.py
pypy/dist/pypy/objspace/std/typeobject.py
Log:
fixes about mro state during user-defined mro computations with tests
Modified: pypy/dist/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_typeobject.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_typeobject.py Sat May 7 01:16:33 2005
@@ -288,3 +288,29 @@
class C(A):
pass
raises(TypeError, "class D(A, C): pass")
+
+ def test_user_defined_mro_cls_access(self):
+ d = []
+ class T(type):
+ def mro(cls):
+ d.append(cls.__dict__)
+ return type.mro(cls)
+ class C:
+ __metaclass__ = T
+ assert d
+ assert sorted(d[0].keys()) == ['__dict__','__metaclass__','__module__']
+ d = []
+ class T(type):
+ def mro(cls):
+ try:
+ cls.x()
+ except AttributeError:
+ d.append('miss')
+ return type.mro(cls)
+ class C:
+ def x(cls):
+ return 1
+ x = classmethod(x)
+ __metaclass__ = T
+ assert d == ['miss']
+ assert C.x() == 1
Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py (original)
+++ pypy/dist/pypy/objspace/std/typeobject.py Sat May 7 01:16:33 2005
@@ -122,6 +122,7 @@
w_type = space.type(w_self)
if not space.is_true(space.is_(w_type, space.w_type)):
+ w_self.mro_w = []
mro_func = w_type.lookup('mro')
mro_func_args = Arguments(space, [w_self])
w_mro = space.call_args(mro_func, mro_func_args)
More information about the Pypy-commit
mailing list