gh-87901: Remove the encoding argument from os.popen (GH-92836)

(cherry picked from commit 96f65835f8)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
This commit is contained in:
Miss Islington (bot) 2022-05-18 20:12:47 -07:00 committed by GitHub
parent 849963598f
commit aa55985aa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View file

@ -974,15 +974,14 @@ otherwise return -SIG, where SIG is the signal that killed it. """
# command in a shell can't be supported.
if sys.platform != 'vxworks':
# Supply os.popen()
def popen(cmd, mode="r", buffering=-1, encoding=None):
def popen(cmd, mode="r", buffering=-1):
if not isinstance(cmd, str):
raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))
if mode not in ("r", "w"):
raise ValueError("invalid mode %r" % mode)
if buffering == 0 or buffering is None:
raise ValueError("popen() does not support unbuffered streams")
import subprocess, io
encoding = io.text_encoding(encoding)
import subprocess
if mode == "r":
proc = subprocess.Popen(cmd,
shell=True, text=True,