File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1450,11 +1450,18 @@ def pipepager(text, cmd):
14501450 import subprocess
14511451 proc = subprocess .Popen (cmd , shell = True , stdin = subprocess .PIPE )
14521452 try :
1453- with proc :
1454- with io .TextIOWrapper (proc .stdin , errors = 'backslashreplace' ) as pipe :
1455- pipe .write (text )
1453+ with io .TextIOWrapper (proc .stdin , errors = 'backslashreplace' ) as pipe :
1454+ pipe .write (text )
14561455 except OSError :
14571456 pass # Ignore broken pipes caused by quitting the pager program.
1457+ while True :
1458+ try :
1459+ proc .wait ()
1460+ break
1461+ except KeyboardInterrupt :
1462+ # Ignore ctl-c like the pager itself does. Otherwise the pager is
1463+ # left running and the terminal is in raw mode and unusable.
1464+ pass
14581465
14591466def tempfilepager (text , cmd ):
14601467 """Page through text by invoking a program on a temporary file."""
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ Core and Builtins
3030Library
3131-------
3232
33+ - Issue #23792: Ignore KeyboardInterrupt when the pydoc pager is active.
34+ This mimics the behavior of the standard unix pagers, and prevents
35+ pipepager from shutting down while the pager itself is still running.
36+
3337- Issue #23775: pprint() of OrderedDict now outputs the same representation
3438 as repr().
3539
You can’t perform that action at this time.
0 commit comments