From 2e04f867ac9b05dd30a386f4af2b8212a29bdd80 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sat, 10 Aug 2024 17:20:56 +0900 Subject: [PATCH 1/4] Support the "pager" binary in _pyrepl 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 --- Lib/_pyrepl/pager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/_pyrepl/pager.py b/Lib/_pyrepl/pager.py index 66dcd99111adfc..1fddc63e3ee3ad 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) From eaf8ae09ca923780837a300f0e66409f2af6706a Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Thu, 19 Sep 2024 13:17:37 +0200 Subject: [PATCH 2/4] NEWS.d entry --- .../2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst new file mode 100644 index 00000000000000..e86944214afe6a --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst @@ -0,0 +1 @@ +Use the `pager` binary on Debian and derivatives, to display REPL `help()`. From d57c91ce952606a17e90bbc4a68047d0e1cbd9f8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 19 Sep 2024 13:22:58 +0200 Subject: [PATCH 3/4] Update Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst --- .../2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst index e86944214afe6a..8a2ecf15194b6b 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst @@ -1 +1 @@ -Use the `pager` binary on Debian and derivatives, to display REPL `help()`. +Use the ``pager`` binary on Debian and derivatives, to display REPL ``help()``. From 1f824a25f863177dda96177b4e402b80f3f5dc15 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 19 Sep 2024 14:50:42 +0200 Subject: [PATCH 4/4] Update Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst Co-authored-by: Sergey B Kirpichev --- .../2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst index 8a2ecf15194b6b..85dd0fd769be68 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-19-13-17-31.gh-issue-122878.4iFpsB.rst @@ -1 +1 @@ -Use the ``pager`` binary on Debian and derivatives, to display REPL ``help()``. +Use the ``pager`` binary, if available (e.g. on Debian and derivatives), to display REPL ``help()``.