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/inspect.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/inspect.py')
-rw-r--r-- | Lib/inspect.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 3a95796..a1910e4 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -55,9 +55,8 @@ def ismethod(object): Instance method objects provide these attributes: __doc__ documentation string __name__ name with which this method was defined - im_class class object in which this method belongs - im_func function object containing implementation of method - im_self instance to which this method is bound""" + __func__ function object containing implementation of method + __self__ instance to which this method is bound""" return isinstance(object, types.MethodType) def ismethoddescriptor(object): @@ -73,7 +72,7 @@ def ismethoddescriptor(object): Methods implemented via descriptors that also pass one of the other tests return false from the ismethoddescriptor() test, simply because the other tests promise more -- you can, e.g., count on having the - im_func attribute (etc) when an object passes ismethod().""" + __func__ attribute (etc) when an object passes ismethod().""" return (hasattr(object, "__get__") and not hasattr(object, "__set__") # else it's a data descriptor and not ismethod(object) # mutual exclusion @@ -351,7 +350,7 @@ def getfile(object): return object.__file__ raise TypeError('arg is a built-in class') if ismethod(object): - object = object.im_func + object = object.__func__ if isfunction(object): object = object.__code__ if istraceback(object): @@ -494,7 +493,7 @@ def findsource(object): raise IOError('could not find class definition') if ismethod(object): - object = object.im_func + object = object.__func__ if isfunction(object): object = object.__code__ if istraceback(object): @@ -744,7 +743,7 @@ def getfullargspec(func): """ if ismethod(func): - func = func.im_func + func = func.__func__ if not isfunction(func): raise TypeError('arg is not a Python function') args, varargs, kwonlyargs, varkw = _getfullargs(func.__code__) |