diff options
author | Guido van Rossum <guido@python.org> | 2007-02-28 22:03:49 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-02-28 22:03:49 (GMT) |
commit | 2e65f892c2ba8b7215345c5138883c677cce76b5 (patch) | |
tree | f6b5313a4d493974b0b326aea3e0756e0a05e042 /Lib/pydoc.py | |
parent | 4b7f3179ea451f491908ea1a775e4136b479e889 (diff) | |
download | cpython-2e65f892c2ba8b7215345c5138883c677cce76b5.zip cpython-2e65f892c2ba8b7215345c5138883c677cce76b5.tar.gz cpython-2e65f892c2ba8b7215345c5138883c677cce76b5.tar.bz2 |
Final part of SF# 1607548 by Tony Lownds: fix pydoc and inspect.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 63bd2f7..9551982 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -875,11 +875,17 @@ class HTMLDoc(Doc): title = '<a name="%s"><strong>%s</strong></a> = %s' % ( anchor, name, reallink) if inspect.isfunction(object): - args, varargs, varkw, defaults = inspect.getargspec(object) + args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann = \ + inspect.getfullargspec(object) argspec = inspect.formatargspec( - args, varargs, varkw, defaults, formatvalue=self.formatvalue) + args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann, + formatvalue=self.formatvalue, + formatannotation=inspect.formatannotationrelativeto(object)) if realname == '<lambda>': title = '<strong>%s</strong> <em>lambda</em> ' % name + # XXX lambda's won't usually have func_annotations['return'] + # since the syntax doesn't support but it is possible. + # So removing parentheses isn't truly safe. argspec = argspec[1:-1] # remove parentheses else: argspec = '(...)' @@ -1241,11 +1247,17 @@ class TextDoc(Doc): skipdocs = 1 title = self.bold(name) + ' = ' + realname if inspect.isfunction(object): - args, varargs, varkw, defaults = inspect.getargspec(object) + args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann = \ + inspect.getfullargspec(object) argspec = inspect.formatargspec( - args, varargs, varkw, defaults, formatvalue=self.formatvalue) + args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann, + formatvalue=self.formatvalue, + formatannotation=inspect.formatannotationrelativeto(object)) if realname == '<lambda>': title = self.bold(name) + ' lambda ' + # XXX lambda's won't usually have func_annotations['return'] + # since the syntax doesn't support but it is possible. + # So removing parentheses isn't truly safe. argspec = argspec[1:-1] # remove parentheses else: argspec = '(...)' |