summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl
diff options
context:
space:
mode:
authorStefano Rivera <stefano@rivera.za.net>2024-09-19 13:18:24 (GMT)
committerGitHub <noreply@github.com>2024-09-19 13:18:24 (GMT)
commit426569eb8ca1edaa68026aa2bab6b8d1c9105f93 (patch)
tree4f9683bd2d3f24630b19cb44d03e1bf7896690c1 /Lib/_pyrepl
parent4420cf4dc9ef7bd3c1c9b5465fa9397304bf0110 (diff)
downloadcpython-426569eb8ca1edaa68026aa2bab6b8d1c9105f93.zip
cpython-426569eb8ca1edaa68026aa2bab6b8d1c9105f93.tar.gz
cpython-426569eb8ca1edaa68026aa2bab6b8d1c9105f93.tar.bz2
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
Diffstat (limited to 'Lib/_pyrepl')
-rw-r--r--Lib/_pyrepl/pager.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/_pyrepl/pager.py b/Lib/_pyrepl/pager.py
index 66dcd99..1fddc63 100644
--- a/Lib/_pyrepl/pager.py
+++ b/Lib/_pyrepl/pager.py
@@ -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)