From 0417dabe3f560470eec63a2485b1741ba9c5e697 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Fri, 2 Jan 2026 15:24:48 +0000 Subject: [PATCH] gh-138897: Use `_pyrepl.pager` for `_sitebuiltins._Printer` (GH-138898) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Co-authored-by: Łukasz Langa --- Lib/_sitebuiltins.py | 24 +++++-------------- ...-09-14-22-26-50.gh-issue-138897.vnUb_L.rst | 2 ++ 2 files changed, 8 insertions(+), 18 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst diff --git a/Lib/_sitebuiltins.py b/Lib/_sitebuiltins.py index c66269a57196..81b36efc6c28 100644 --- a/Lib/_sitebuiltins.py +++ b/Lib/_sitebuiltins.py @@ -36,7 +36,7 @@ class _Printer(object): 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,24 +65,12 @@ class _Printer(object): return "Type %s() to see the full %s text" % ((self.__name,)*2) def __call__(self): + from _pyrepl.pager import get_pager 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): 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 000000000000..779c886fdd94 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst @@ -0,0 +1,2 @@ +Improved :data:`license`/:data:`copyright`/:data:`credits` display in the +:term:`REPL`: now uses a pager. -- 2.47.3