From: Dong-hee Na Date: Thu, 20 Oct 2022 02:43:21 +0000 (+0900) Subject: [3.11] gh-98374: Suppress ImportError for invalid query for help() co… (gh-98472) X-Git-Tag: v3.11.1~250 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2af980e19794adb36647396c74a7e5aa96ba90e;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-98374: Suppress ImportError for invalid query for help() co… (gh-98472) --- diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 434316635d48..088a3ba8817c 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1998,7 +1998,10 @@ class Helper: _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.