diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-27 10:40:20 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-27 10:40:20 (GMT) |
commit | ff737954f3ee3005236133fc51b55a508b11aa06 (patch) | |
tree | b65ae9e39e774bd73674b5088e549d09a7bfd7d6 /Lib/test/test_descr.py | |
parent | 0d3fb8a944a810f421377d5823cbc006700b3c1d (diff) | |
download | cpython-ff737954f3ee3005236133fc51b55a508b11aa06.zip cpython-ff737954f3ee3005236133fc51b55a508b11aa06.tar.gz cpython-ff737954f3ee3005236133fc51b55a508b11aa06.tar.bz2 |
Removed the API to create unbound methods and simplified the API for bound methods. The signature is PyMethod_New(func, instance).
Also removed im_class and renamed im_self to __self__ and im_func to __func__. im_class can be substituted with method.__self__.__class__.
I've also updated some parts of the documenation.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index e093ce8..a518f16 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -280,12 +280,12 @@ def test_dir(): c = C() vereq(interesting(dir(c)), cstuff) - #verify('im_self' in dir(C.Cmethod)) + #verify('__self__' in dir(C.Cmethod)) c.cdata = 2 c.cmethod = lambda self: 0 vereq(interesting(dir(c)), cstuff + ['cdata', 'cmethod']) - #verify('im_self' in dir(c.Cmethod)) + #verify('__self__' in dir(c.Cmethod)) class A(C): Adata = 1 @@ -293,13 +293,13 @@ def test_dir(): astuff = ['Adata', 'Amethod'] + cstuff vereq(interesting(dir(A)), astuff) - #verify('im_self' in dir(A.Amethod)) + #verify('__self__' in dir(A.Amethod)) a = A() vereq(interesting(dir(a)), astuff) a.adata = 42 a.amethod = lambda self: 3 vereq(interesting(dir(a)), astuff + ['adata', 'amethod']) - #verify('im_self' in dir(a.Amethod)) + #verify('__self__' in dir(a.Amethod)) # Try a module subclass. import sys @@ -1418,10 +1418,10 @@ def classmethods(): vereq(ff.__get__(0)(42), (int, 42)) # Test super() with classmethods (SF bug 535444) - veris(C.goo.im_self, C) - veris(D.goo.im_self, D) - veris(super(D,D).goo.im_self, D) - veris(super(D,d).goo.im_self, D) + veris(C.goo.__self__, C) + veris(D.goo.__self__, D) + veris(super(D,D).goo.__self__, D) + veris(super(D,d).goo.__self__, D) vereq(super(D,D).goo(), (D,)) vereq(super(D,d).goo(), (D,)) @@ -1507,7 +1507,7 @@ def classic(): r = repr(E().foo) verify(r.startswith("<bound method E.foo "), r) r = repr(C.foo.__get__(C())) - verify(r.startswith("<bound method ?.foo "), r) + verify(r.startswith("<bound method "), r) def compattr(): if verbose: print("Testing computed attributes...") @@ -1687,7 +1687,7 @@ def methods(): vereq(d2.goo(), 1) class E(object): foo = C.foo - vereq(E().foo.im_func, C.foo) # i.e., unbound + vereq(E().foo.__func__, C.foo) # i.e., unbound r = repr(C.foo.__get__(C(1))) verify(r.startswith("<bound method "), r) @@ -1864,17 +1864,6 @@ def recursions(): ## raise TestFailed, "expected a RuntimeError for print recursion" ## sys.stdout = test_stdout - # Bug #1202533. - class A(object): - pass - A.__mul__ = new.instancemethod(lambda self, x: self * x, None, A) - try: - A()*2 - except RuntimeError: - pass - else: - raise TestFailed("expected a RuntimeError") - def weakrefs(): if verbose: print("Testing weak references...") import weakref |