]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-138897: Use `_pyrepl.pager` for `_sitebuiltins._Printer` (GH-138898) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 2 Jan 2026 16:28:04 +0000 (17:28 +0100)
committerGitHub <noreply@github.com>
Fri, 2 Jan 2026 16:28:04 +0000 (17:28 +0100)
(cherry picked from commit 0417dabe3f560470eec63a2485b1741ba9c5e697)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Lib/_sitebuiltins.py
Misc/NEWS.d/next/Library/2025-09-14-22-26-50.gh-issue-138897.vnUb_L.rst [new file with mode: 0644]

index c66269a571967f89aa678e0becb30baf8b1c69b7..81b36efc6c285f0143e2555237d5e24a2b0dbaa6 100644 (file)
@@ -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 (file)
index 0000000..779c886
--- /dev/null
@@ -0,0 +1,2 @@
+Improved :data:`license`/:data:`copyright`/:data:`credits` display in the
+:term:`REPL`: now uses a pager.