Mercurial > cpython-lru_cache-weakref
diff Lib/inspect.py @ 40910:eaaee785eb86
Change all the function attributes from func_* -> __*__. This gets rid
of func_name, func_dict and func_doc as they already exist as __name__,
__dict__ and __doc__.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sun, 25 Feb 2007 20:55:47 +0000 |
| parents | cc992d75d5b3 |
| children | e16268c273bb |
line wrap: on
line diff
--- a/Lib/inspect.py Sun Feb 25 20:39:11 2007 +0000 +++ b/Lib/inspect.py Sun Feb 25 20:55:47 2007 +0000 @@ -2,7 +2,7 @@ """Get useful information from live Python objects. This module encapsulates the interface provided by the internal special -attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion. +attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion. It also provides some help for examining source code and class layout. Here are some of the useful functions provided by this module: @@ -129,11 +129,11 @@ Function objects provide these attributes: __doc__ documentation string __name__ name with which this function was defined - func_code code object containing compiled function bytecode - func_defaults tuple of any default values for arguments - func_doc (same as __doc__) - func_globals global namespace in which this function was defined - func_name (same as __name__)""" + __code__ code object containing compiled function bytecode + __defaults__ tuple of any default values for arguments + __globals__ global namespace in which this function was defined + __annotations__ dict of parameter annotations + __kwdefaults__ dict of keyword only parameters with defaults""" return isinstance(object, types.FunctionType) def istraceback(object): @@ -353,7 +353,7 @@ if ismethod(object): object = object.im_func if isfunction(object): - object = object.func_code + object = object.__code__ if istraceback(object): object = object.tb_frame if isframe(object): @@ -496,7 +496,7 @@ if ismethod(object): object = object.im_func if isfunction(object): - object = object.func_code + object = object.__code__ if istraceback(object): object = object.tb_frame if isframe(object): @@ -741,8 +741,8 @@ func = func.im_func if not isfunction(func): raise TypeError('arg is not a Python function') - args, varargs, varkw = getargs(func.func_code) - return args, varargs, varkw, func.func_defaults + args, varargs, varkw = getargs(func.__code__) + return args, varargs, varkw, func.__defaults__ def getargvalues(frame): """Get information about arguments passed into a particular frame.
