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_funcattrs.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_funcattrs.py')
-rw-r--r-- | Lib/test/test_funcattrs.py | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index b9b2e6e..3d0d4aa 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -104,11 +104,12 @@ else: raise TestFailed if f2.a.one != f1.a.one != F.a.one != 11: raise TestFailed -# im_func may not be a Python method! +# __func__ may not be a Python method! import new -F.id = new.instancemethod(id, None, F) +F.id = id eff = F() +eff.id = new.instancemethod(id, eff) if eff.id() != id(eff): raise TestFailed @@ -296,32 +297,32 @@ def test_func_dict(): verify(f.__dict__ == {'world': 'hello'}) cantset(f, "__dict__", None) -def test_im_class(): +def test___self__(): class C: def foo(self): pass - #verify(C.foo.im_class is C) - verify(C().foo.im_class is C) - #cantset(C.foo, "im_class", C) - cantset(C().foo, "im_class", C) + #verify(C.foo.__self__.__class__ is C) + verify(C().foo.__self__.__class__ is C) + #cantset(C.foo, "__self__.__class__", C) + cantset(C().foo, "__self__.__class__", C) -def test_im_func(): +def test___func__(): def foo(self): pass class C: pass C.foo = foo - #verify(C.foo.im_func is foo) - verify(C().foo.im_func is foo) - #cantset(C.foo, "im_func", foo) - cantset(C().foo, "im_func", foo) + #verify(C.foo.__func__ is foo) + verify(C().foo.__func__ is foo) + #cantset(C.foo, "__func__", foo) + cantset(C().foo, "__func__", foo) -def test_im_self(): +def test___self__(): class C: def foo(self): pass - #verify(C.foo.im_self is None) + #verify(C.foo.__self__ is None) c = C() - #verify(c.foo.im_self is c) - #cantset(C.foo, "im_self", None) - #cantset(c.foo, "im_self", c) + #verify(c.foo.__self__ is c) + #cantset(C.foo, "__self__", None) + #cantset(c.foo, "__self__", c) def test_im_dict(): class C: @@ -358,9 +359,9 @@ def testmore(): test_func_defaults() test_func_dict() # Tests for instance method attributes - test_im_class() - test_im_func() - test_im_self() + test___self__() + test___func__() + test___self__() test_im_dict() test_im_doc() test_im_name() |