diff options
author | Guido van Rossum <guido@python.org> | 2007-05-14 22:03:55 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-14 22:03:55 (GMT) |
commit | a8add0ec5ef05c26e1641b8310b65ddd75c0fec3 (patch) | |
tree | 1626110463ca617ab105990ee1923f6ee65c7476 /Lib/inspect.py | |
parent | 827b055ffe8060ac229cda8d75eb24176cc697c0 (diff) | |
download | cpython-a8add0ec5ef05c26e1641b8310b65ddd75c0fec3.zip cpython-a8add0ec5ef05c26e1641b8310b65ddd75c0fec3.tar.gz cpython-a8add0ec5ef05c26e1641b8310b65ddd75c0fec3.tar.bz2 |
Merged revisions 55270-55324 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
........
r55271 | fred.drake | 2007-05-11 10:14:47 -0700 (Fri, 11 May 2007) | 3 lines
remove jpeg, panel libraries for SGI; there is more IRIX stuff left over,
I guess that should be removed too, but will leave for someone who is sure
........
r55280 | fred.drake | 2007-05-11 19:11:37 -0700 (Fri, 11 May 2007) | 1 line
remove mention of file that has been removed
........
r55301 | brett.cannon | 2007-05-13 17:38:05 -0700 (Sun, 13 May 2007) | 4 lines
Remove rexec and Bastion from the stdlib. This also eliminates the need for
f_restricted on frames. This in turn negates the need for
PyEval_GetRestricted() and PyFrame_IsRestricted().
........
r55303 | brett.cannon | 2007-05-13 19:22:22 -0700 (Sun, 13 May 2007) | 2 lines
Remove the md5 and sha modules.
........
r55305 | george.yoshida | 2007-05-13 19:45:55 -0700 (Sun, 13 May 2007) | 2 lines
fix markup
........
r55306 | neal.norwitz | 2007-05-13 19:47:57 -0700 (Sun, 13 May 2007) | 1 line
Get the doc building again after some removals.
........
r55307 | neal.norwitz | 2007-05-13 19:50:45 -0700 (Sun, 13 May 2007) | 1 line
Get test_pyclbr passing again after getstatus was removed from commands. This "test case" was weird since it was just importing a seemingly random module. Remove the import
........
r55322 | brett.cannon | 2007-05-14 14:09:20 -0700 (Mon, 14 May 2007) | 3 lines
Remove the compiler package. Will eventually need a mechanism to byte compile
an AST.
........
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 0be0419..ff25be7 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -161,7 +161,6 @@ def isframe(object): f_lasti index of last attempted instruction in bytecode f_lineno current line number in Python source code f_locals local namespace seen by this frame - f_restricted 0 or 1 if frame is in restricted execution mode f_trace tracing function for this frame, or None""" return isinstance(object, types.FrameType) @@ -674,7 +673,7 @@ def getargs(co): """Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where - 'args' is the list of argument names, possibly containing nested + 'args' is the list of argument names, possibly containing nested lists. Keyword-only arguments are appended. 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" args, varargs, kwonlyargs, varkw = _getfullargs(co) @@ -751,7 +750,7 @@ def getargspec(func): 'args' will include keyword-only argument names. 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'defaults' is an n-tuple of the default values of the last n arguments. - + Use the getfullargspec() API for Python-3000 code, as annotations and keyword arguments are supported. getargspec() will raise ValueError if the func has either annotations or keyword arguments. @@ -767,7 +766,7 @@ def getargspec(func): def getfullargspec(func): """Get the names and default values of a function's arguments. - A tuple of seven things is returned: (args, varargs, kwonlyargs, + A tuple of seven things is returned: (args, varargs, kwonlyargs, kwonlydefaults, varkw, defaults, annotations). 'args' is a list of the argument names (it may contain nested lists). 'varargs' and 'varkw' are the names of the * and ** arguments or None. @@ -775,7 +774,7 @@ def getfullargspec(func): 'kwonlyargs' is a list of keyword-only argument names. 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults. 'annotations' is a dictionary mapping argument names to annotations. - + The first four items in the tuple correspond to getargspec(). """ @@ -784,7 +783,7 @@ def getfullargspec(func): if not isfunction(func): raise TypeError('arg is not a Python function') args, varargs, kwonlyargs, varkw = _getfullargs(func.__code__) - return (args, varargs, varkw, func.__defaults__, + return (args, varargs, varkw, func.__defaults__, kwonlyargs, func.__kwdefaults__, func.__annotations__) def getargvalues(frame): @@ -816,12 +815,12 @@ def formatannotation(annotation, base_module=None): return annotation.__name__ return annotation.__module__+'.'+annotation.__name__ return repr(annotation) - + def formatannotationrelativeto(object): - module = getattr(object, '__module__', None) - def _formatannotation(annotation): - return formatannotation(annotation, module) - return _formatannotation + module = getattr(object, '__module__', None) + def _formatannotation(annotation): + return formatannotation(annotation, module) + return _formatannotation def formatargspec(args, varargs=None, varkw=None, defaults=None, kwonlyargs=(), kwonlydefaults={}, annotations={}, @@ -832,7 +831,7 @@ def formatargspec(args, varargs=None, varkw=None, defaults=None, formatreturns=lambda text: ' -> ' + text, formatannotation=formatannotation, join=joinseq): - """Format an argument spec from the values returned by getargspec + """Format an argument spec from the values returned by getargspec or getfullargspec. The first seven arguments are (args, varargs, varkw, defaults, |