mirror of
https://github.com/python/cpython.git
synced 2025-07-18 00:35:17 +00:00
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:
parent
849963598f
commit
aa55985aa8
3 changed files with 13 additions and 7 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue