diff options
author | Kirill Podoprigora <kirill.bast9@mail.ru> | 2023-07-01 22:46:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-01 22:46:06 (GMT) |
commit | 0530f4f64629ff97f3feb7524da0833b9535e8b6 (patch) | |
tree | d09678bc0a0c06f6b20640d5372ae89dbd396059 /Lib/pydoc.py | |
parent | 46d77610fc77088bceac720a13d9f2df3a50f29e (diff) | |
download | cpython-0530f4f64629ff97f3feb7524da0833b9535e8b6.zip cpython-0530f4f64629ff97f3feb7524da0833b9535e8b6.tar.gz cpython-0530f4f64629ff97f3feb7524da0833b9535e8b6.tar.bz2 |
gh-102541: Fix Helper.help("mod") for non-existent mod (#105934)
If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index d69369d..185f09e 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1790,7 +1790,11 @@ def doc(thing, title='Python Library Documentation: %s', forceload=0, raise print(exc) else: - output.write(render_doc(thing, title, forceload, plaintext)) + try: + s = render_doc(thing, title, forceload, plaintext) + except ImportError as exc: + s = str(exc) + output.write(s) def writedoc(thing, forceload=0): """Write HTML documentation to a file in the current directory.""" |