Author: Carl Friedrich Bolz <[email protected]>
Branch:
Changeset: r82785:03f7d9255635
Date: 2016-03-05 13:37 +0100
http://bitbucket.org/pypy/pypy/changeset/03f7d9255635/
Log: implement super.__thisclass__
diff --git a/pypy/module/__builtin__/descriptor.py
b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -79,6 +79,7 @@
W_Super.typedef = TypeDef(
'super',
__new__ = interp2app(descr_new_super),
+ __thisclass__ = interp_attrproperty_w("w_starttype", W_Super),
__getattribute__ = interp2app(W_Super.getattribute),
__get__ = interp2app(W_Super.get),
__doc__ = """super(type) -> unbound super object
diff --git a/pypy/module/__builtin__/test/test_descriptor.py
b/pypy/module/__builtin__/test/test_descriptor.py
--- a/pypy/module/__builtin__/test/test_descriptor.py
+++ b/pypy/module/__builtin__/test/test_descriptor.py
@@ -214,7 +214,7 @@
c = C()
assert C.goo(1) == (C, 1)
assert c.goo(1) == (C, 1)
-
+
assert c.foo(1) == (c, 1)
class D(C):
pass
@@ -238,6 +238,12 @@
meth = classmethod(1).__get__(1)
raises(TypeError, meth)
+ def test_super_thisclass(self):
+ class A(object):
+ pass
+
+ assert super(A, A()).__thisclass__ is A
+
def test_property_docstring(self):
assert property.__doc__.startswith('property')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit