Added proper reflection on instances of <type 'method-wrapper'>, e.g.

'[].__add__', to match what the other internal descriptor types provide:
'__objclass__' attribute, '__self__' member, and reasonable repr and
comparison.

Added a test.
This commit is contained in:
Armin Rigo 2005-11-07 08:38:00 +00:00
parent 64b414ad4c
commit c6686b7c7e
2 changed files with 59 additions and 13 deletions

View file

@ -3977,6 +3977,18 @@ def test_init():
else:
raise TestFailed, "did not test __init__() for None return"
def methodwrapper():
# <type 'method-wrapper'> did not support any reflection before 2.5
if verbose:
print "Testing method-wrapper objects..."
l = []
vereq(l.__add__, l.__add__)
verify(l.__add__ != [].__add__)
verify(l.__add__.__name__ == '__add__')
verify(l.__add__.__self__ is l)
verify(l.__add__.__objclass__ is list)
vereq(l.__add__.__doc__, list.__add__.__doc__)
def test_main():
weakref_segfault() # Must be first, somehow
@ -4071,6 +4083,7 @@ def test_main():
filefault()
vicious_descriptor_nonsense()
test_init()
methodwrapper()
if verbose: print "All OK"