From 8ebfe7ab55ade53963042ae55908bec74eb8d20f Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sun, 14 Sep 2025 22:24:07 +0100 Subject: [PATCH 1/6] Commit --- Lib/_sitebuiltins.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/Lib/_sitebuiltins.py b/Lib/_sitebuiltins.py index c66269a571967f..709c8daae82c5a 100644 --- a/Lib/_sitebuiltins.py +++ b/Lib/_sitebuiltins.py @@ -9,6 +9,7 @@ # globals. import sys +from _pyrepl.pager import get_pager class Quitter(object): def __init__(self, name, eof): @@ -66,23 +67,9 @@ def __repr__(self): def __call__(self): self.__setup() - prompt = 'Hit Return for more, or q (and Return) to quit: ' - lineno = 0 - while 1: - try: - for i in range(lineno, lineno + self.MAXLINES): - print(self.__lines[i]) - except IndexError: - break - else: - lineno += self.MAXLINES - key = None - while key is None: - key = input(prompt) - if key not in ('', 'q'): - key = None - if key == 'q': - break + pager = get_pager() + text = "\n".join(self.__lines) + pager(text, title=self.__name) class _Helper(object): From 5aeac23ab4966a4bb41c008bd2fbf33af1c33f4b Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sun, 14 Sep 2025 22:26:53 +0100 Subject: [PATCH 2/6] Commit --- .../next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst diff --git a/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst b/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst new file mode 100644 index 00000000000000..1cfa717254a716 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst @@ -0,0 +1 @@ +Improving ``license()`` prompting in repl. From 448ec45be348c57a7dc59666eee2a0465d6d53c1 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 15 Sep 2025 07:52:35 +0100 Subject: [PATCH 3/6] Commit --- Lib/_sitebuiltins.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Lib/_sitebuiltins.py b/Lib/_sitebuiltins.py index 709c8daae82c5a..61967bfdbe2627 100644 --- a/Lib/_sitebuiltins.py +++ b/Lib/_sitebuiltins.py @@ -9,7 +9,6 @@ # globals. import sys -from _pyrepl.pager import get_pager class Quitter(object): def __init__(self, name, eof): @@ -66,10 +65,31 @@ def __repr__(self): return "Type %s() to see the full %s text" % ((self.__name,)*2) def __call__(self): + import os self.__setup() - pager = get_pager() - text = "\n".join(self.__lines) - pager(text, title=self.__name) + if "PYTHON_BASIC_REPL" in os.environ: + prompt = 'Hit Return for more, or q (and Return) to quit: ' + lineno = 0 + while 1: + try: + for i in range(lineno, lineno + self.MAXLINES): + print(self.__lines[i]) + except IndexError: + break + else: + lineno += self.MAXLINES + key = None + while key is None: + key = input(prompt) + if key not in ('', 'q'): + key = None + if key == 'q': + break + else: + from _pyrepl.pager import get_pager + pager = get_pager() + text = "\n".join(self.__lines) + pager(text, title=self.__name) class _Helper(object): From 32078b1e16e3a4c3904b1cc9de6a3a0c9e87f746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 16 Sep 2025 12:33:27 +0200 Subject: [PATCH 4/6] Always use the pager --- Lib/_sitebuiltins.py | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/Lib/_sitebuiltins.py b/Lib/_sitebuiltins.py index 61967bfdbe2627..81b36efc6c285f 100644 --- a/Lib/_sitebuiltins.py +++ b/Lib/_sitebuiltins.py @@ -36,7 +36,7 @@ def __init__(self, name, data, files=(), dirs=()): import os self.__name = name self.__data = data - self.__lines = None + self.__lines = [] self.__filenames = [os.path.join(dir, filename) for dir in dirs for filename in files] @@ -65,31 +65,12 @@ def __repr__(self): return "Type %s() to see the full %s text" % ((self.__name,)*2) def __call__(self): - import os + from _pyrepl.pager import get_pager self.__setup() - if "PYTHON_BASIC_REPL" in os.environ: - prompt = 'Hit Return for more, or q (and Return) to quit: ' - lineno = 0 - while 1: - try: - for i in range(lineno, lineno + self.MAXLINES): - print(self.__lines[i]) - except IndexError: - break - else: - lineno += self.MAXLINES - key = None - while key is None: - key = input(prompt) - if key not in ('', 'q'): - key = None - if key == 'q': - break - else: - from _pyrepl.pager import get_pager - pager = get_pager() - text = "\n".join(self.__lines) - pager(text, title=self.__name) + + pager = get_pager() + text = "\n".join(self.__lines) + pager(text, title=self.__name) class _Helper(object): From 5f737883f700f15981f614ee9b32e4c995307f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 16 Sep 2025 12:35:46 +0200 Subject: [PATCH 5/6] Improve blurb --- .../Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst b/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst index 1cfa717254a716..0360a73a455783 100644 --- a/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst +++ b/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst @@ -1 +1,2 @@ -Improving ``license()`` prompting in repl. +Improved ``license()``/``copyright()``/``credits()`` display in the REPL +to use a pager. From d2e3e77390e60e34e0fba456472129a22385a06e Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Tue, 16 Sep 2025 16:32:34 +0100 Subject: [PATCH 6/6] Add links --- .../Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst b/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst index 0360a73a455783..779c886fdd94c1 100644 --- a/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst +++ b/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst @@ -1,2 +1,2 @@ -Improved ``license()``/``copyright()``/``credits()`` display in the REPL -to use a pager. +Improved :data:`license`/:data:`copyright`/:data:`credits` display in the +:term:`REPL`: now uses a pager.