summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-04-18 17:13:21 +0300
committerGitHub <noreply@github.com>2020-04-18 17:13:21 +0300
commit7e64414f57b70dc5bc0ab19a3162a0735f9bfabf (patch)
tree89751f89c42a08b7335098b470ba6ddc395b184c /Lib/pydoc.py
parentc606624af8d4cb3b4a052fb263bb983b3f87585b (diff)
downloadcpython-git-7e64414f57b70dc5bc0ab19a3162a0735f9bfabf.tar.gz
bpo-40257: Improve help for the typing module (GH-19546)
* Show docstring for special forms. * Show docstring for special generic aliases. * Show documentation for __origin__ for generic aliases.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index a89b804570..898cc44b29 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1445,7 +1445,7 @@ location listed above.
if not doc:
doc = getdoc(object)
if doc:
- line += '\n' + self.indent(str(doc))
+ line += '\n' + self.indent(str(doc)) + '\n'
return line
class _PlainTextDoc(TextDoc):
@@ -1672,8 +1672,11 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
inspect.getdoc(object)):
# If the passed object is a piece of data or an instance,
# document its available methods instead of its value.
- object = type(object)
- desc += ' object'
+ if hasattr(object, '__origin__'):
+ object = object.__origin__
+ else:
+ object = type(object)
+ desc += ' object'
return title % desc + '\n\n' + renderer.document(object, name)
def doc(thing, title='Python Library Documentation: %s', forceload=0,