Skip to content

Commit 67fb193

Browse files
committed
gh-161039: Fix detection of less >= 706 in _pyrepl.pager.get_pager
Since less tag v706¹, less exits with a failure status when no filename is provided. Pass the `-?` option and redirect both stdout and stderr to /dev/null. Failure to detect `less` results in using `more` for users who don't have MANPAGER or PAGER set, which is unexpected. ¹ gwsw/less@7c85230 (Exit with a failure status in more cases, 2026-06-14)
1 parent 410fdda commit 67fb193

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎Lib/_pyrepl/pager.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_pager() -> Pager:
3636
return lambda text, title='': tempfile_pager(plain(text), 'more <')
3737
if hasattr(os, 'system') and os.system('(pager) 2>/dev/null') == 0:
3838
return lambda text, title='': pipe_pager(text, 'pager', title)
39-
if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
39+
if hasattr(os, 'system') and os.system('(less -?) >/dev/null 2>&1') == 0:
4040
return lambda text, title='': pipe_pager(text, 'less', title)
4141

4242
import tempfile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix detection of ``less >= 706`` in :func:`_pyrepl.pager.get_pager`.

0 commit comments

Comments
 (0)