mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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__.
This commit is contained in:
parent
27d517b21b
commit
221085de89
37 changed files with 160 additions and 184 deletions
|
@ -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 @@ def isfunction(object):
|
|||
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 @@ def getfile(object):
|
|||
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 @@ def findsource(object):
|
|||
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 @@ def getargspec(func):
|
|||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue