Support the "pager" binary in _pyrepl (#122878)

Debian (and derivatives) provide a /usr/bin/pager binary, managed by the
alternatives system, that always points to an available pager utility.
Allow _pyrepl to use it, to follow system policy.

This is a very trivial change, from a patch that Debian has been
carrying since 2.7 era. Seems appropriate to upstream.
https://bugs.debian.org/799555
This commit is contained in:
Stefano Rivera 2024-09-19 06:18:24 -07:00 committed by GitHub
parent 4420cf4dc9
commit 426569eb8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View File

@ -36,6 +36,8 @@ def get_pager() -> Pager:
return plain_pager
if sys.platform == 'win32':
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:
return lambda text, title='': pipe_pager(text, 'less', title)

View File

@ -0,0 +1 @@
Use the ``pager`` binary, if available (e.g. on Debian and derivatives), to display REPL ``help()``.