[Python-checkins] gh-98374: Suppress ImportError for invalid query for help() command. (gh-98450)

corona10 webhook-mailer at python.org
Wed Oct 19 21:56:28 EDT 2022


https://github.com/python/cpython/commit/4156b2fc1378531bdd9459cd131fb9fa25a5af34
commit: 4156b2fc1378531bdd9459cd131fb9fa25a5af34
branch: main
author: Dong-hee Na <donghee.na at python.org>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-10-20T10:56:21+09:00
summary:

gh-98374: Suppress ImportError for invalid query for help() command. (gh-98450)

files:
A Misc/NEWS.d/next/Core and Builtins/2022-10-19-23-48-46.gh-issue-98374.eOBh8M.rst
M Lib/pydoc.py

diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index a4dc910c8a8e..c79ec77a8c09 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1997,7 +1997,10 @@ def __repr__(self):
     _GoInteractive = object()
     def __call__(self, request=_GoInteractive):
         if request is not self._GoInteractive:
-            self.help(request)
+            try:
+                self.help(request)
+            except ImportError as e:
+                self.output.write(f'{e}\n')
         else:
             self.intro()
             self.interact()
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-10-19-23-48-46.gh-issue-98374.eOBh8M.rst b/Misc/NEWS.d/next/Core and Builtins/2022-10-19-23-48-46.gh-issue-98374.eOBh8M.rst
new file mode 100644
index 000000000000..56a41e3883d1
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-10-19-23-48-46.gh-issue-98374.eOBh8M.rst	
@@ -0,0 +1,2 @@
+Suppress ImportError for invalid query for help() command. Patch by Dong-hee
+Na.



More information about the Python-checkins mailing list