bpo-43651: Fix EncodingWarning in `pydoc`. (GH-25644)

This commit is contained in:
Inada Naoki 2021-04-27 12:46:20 +09:00 committed by GitHub
parent 284c52da09
commit 9dfefbe3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1594,9 +1594,10 @@ def plain(text):
def pipepager(text, cmd):
"""Page through text by feeding it to another program."""
import subprocess
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
errors='backslashreplace')
try:
with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
with proc.stdin as pipe:
try:
pipe.write(text)
except KeyboardInterrupt: