[pypy-svn] r72966 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

xoraxax at codespeak.net xoraxax at codespeak.net
Sat Mar 27 20:07:55 CET 2010


Author: xoraxax
Date: Sat Mar 27 20:07:53 2010
New Revision: 72966

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py
Log:
Implement and test __repr__ of slot wrapper objects.

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py	Sat Mar 27 20:07:53 2010
@@ -37,7 +37,7 @@
         self.w_objclass = from_ref(space, pto)
 
     def __repr__(self):
-        return "method %r of %r objects" % (self.name, self.w_objclass.getname(self.space, '?'))
+        return "<method %r of %r objects>" % (self.name, self.w_objclass.getname(self.space, '?'))
 
     def descr_method_repr(self):
         return self.space.wrap(self.__repr__())
@@ -64,6 +64,9 @@
                                  self.method_name)
         return self.wrapper_func(self.space, w_self, w_args, self.func)
 
+    def descr_method_repr(self):
+        return self.space.wrap("<slot wrapper %r of %r objects>" % (self.method_name,
+            self.w_objclass.getname(self.space, '?')))
 
 @unwrap_spec(ObjSpace, W_Root, Arguments)
 def cwrapper_descr_call(space, w_self, __args__):
@@ -134,6 +137,7 @@
     __name__ = interp_attrproperty('method_name', cls=W_PyCWrapperObject),
     __doc__ = interp_attrproperty('doc', cls=W_PyCWrapperObject),
     __objclass__ = interp_attrproperty_w('w_objclass', cls=W_PyCWrapperObject),
+    __repr__ = interp2app(W_PyCWrapperObject.descr_method_repr),
     # XXX missing: __getattribute__, __repr__
     )
 W_PyCWrapperObject.typedef.acceptable_as_base_class = False

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py	Sat Mar 27 20:07:53 2010
@@ -21,5 +21,5 @@
         assert "copy" in repr(module.fooType.copy)
         assert repr(module.fooType) == "<type 'foo.foo'>"
         assert repr(obj2) == "<Foo>"
-        print module.fooType.__call__
+        assert repr(module.fooType.__call__) == "<slot wrapper '__call__' of 'foo' objects>"
         assert obj2(foo=1, bar=2) == dict(foo=1, bar=2)



More information about the Pypy-commit mailing list