From b2938c306bb18175614aa30d1d233fffb34bd456 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Sun, 1 Nov 2026 14:36:53 -0500 Subject: [PATCH] gh-161039: Fix detection of `less` 706 and later by the `pydoc` pager (GH-161040) (cherry picked from commit 2f2051287f0c24c7bb99a7f570e5a6178ba1f8de) Co-authored-by: Todd Zullinger Co-authored-by: Stan Ulbrych --- Lib/_pyrepl/pager.py | 2 +- .../next/Library/2026-10-31-21-34-00.gh-issue-161039.k7_pTD.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2026-10-31-21-34-00.gh-issue-161039.k7_pTD.rst diff --git a/Lib/_pyrepl/pager.py b/Lib/_pyrepl/pager.py index 1fddc63e3ee3ad0..2914755f435d86b 100644 --- a/Lib/_pyrepl/pager.py +++ b/Lib/_pyrepl/pager.py @@ -38,7 +38,7 @@ def get_pager() -> Pager: return lambda text, title='': tempfile_pager(plain(text), 'more <') if hasattr(os, 'system') and os.system('(pager) 2>/dev/null') == 0: return lambda text, title='': pipe_pager(text, 'pager', title) - if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0: + if hasattr(os, 'system') and os.system('(less -V) >/dev/null 2>&1') == 0: return lambda text, title='': pipe_pager(text, 'less', title) import tempfile diff --git a/Misc/NEWS.d/next/Library/2026-10-31-21-34-00.gh-issue-161039.k7_pTD.rst b/Misc/NEWS.d/next/Library/2026-10-31-21-34-00.gh-issue-161039.k7_pTD.rst new file mode 100644 index 000000000000000..3b697fb155b7aca --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-31-21-34-00.gh-issue-161039.k7_pTD.rst @@ -0,0 +1 @@ +Fix the :mod:`pydoc` pager not detecting ``less`` 706 and newer.