diff --git a/Lib/_pyrepl/pager.py b/Lib/_pyrepl/pager.py index d6f20fe7557e6b3..eee4e3675fc36ee 100644 --- a/Lib/_pyrepl/pager.py +++ b/Lib/_pyrepl/pager.py @@ -36,7 +36,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.