[pypy-dev] Unbound method must be called with instance as first argument

Seo Sanghyeon tinuviel at fluid.sparcs.net
Sat Jul 3 15:12:41 CEST 2004

Consider following testcase:

class C: pass
class D(C): pass
def m(self): return self
C.m = m
D.m = C.m
print C().m()
print D().m()

CPython runs it okay, but PyPy baffles and raises TypeError, with
message ${SUBJ}.

Changing 5th line to "D.m = m" and it runs fine. The point is,
"D.m = C.m" should transform C.m from unbound method of class C to
unbound method of class D...

This breaks mailbox.py, among other things. Read how
PortableUnixMailbox is implemented there.


More information about the Pypy-dev mailing list