From 137c5e5936800ee13467a8c6b69114c69b1b1f9a Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 17 Jul 2020 10:17:07 -0600 Subject: [PATCH] bpo-21625: Improve help() when MANPAGER and PAGER variables are not set Display "(q to quit)" when using help(). Use the --quit-at-eof option to make less quit if enter is pressed on the last line. --- Lib/pydoc.py | 3 ++- .../next/Library/2020-07-17-10-15-59.bpo-21625.cKVDj2.rst | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2020-07-17-10-15-59.bpo-21625.cKVDj2.rst diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 628f9fc7d1d1ef..93e72c92dcd0ad 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1574,7 +1574,8 @@ def getpager(): if sys.platform == 'win32': return lambda text: tempfilepager(plain(text), 'more <') if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0: - return lambda text: pipepager(text, 'less') + cmd = 'less "-P?e(END) .(q to quit)" --quit-at-eof' + return lambda text: pipepager(text, cmd) import tempfile (fd, filename) = tempfile.mkstemp() diff --git a/Misc/NEWS.d/next/Library/2020-07-17-10-15-59.bpo-21625.cKVDj2.rst b/Misc/NEWS.d/next/Library/2020-07-17-10-15-59.bpo-21625.cKVDj2.rst new file mode 100644 index 00000000000000..aa3f88a6c2af10 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-07-17-10-15-59.bpo-21625.cKVDj2.rst @@ -0,0 +1,2 @@ +When the ``MANPAGER`` and ``PAGER`` environment variables are not set, +interactive :func:`help` now quits if enter is pressed on the last line.