diff options
author | Inada Naoki <songofacandy@gmail.com> | 2022-05-06 05:48:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-06 05:48:36 (GMT) |
commit | 2b563f1ad31af0bb0a9947e6f1f76e58dbf170f0 (patch) | |
tree | cb37aa7795169c2b095ebbc7f67316ff0aca215c /Lib/os.py | |
parent | 926854e8583125eaadd2a19b580c09d7c12389e9 (diff) | |
download | cpython-2b563f1ad31af0bb0a9947e6f1f76e58dbf170f0.zip cpython-2b563f1ad31af0bb0a9947e6f1f76e58dbf170f0.tar.gz cpython-2b563f1ad31af0bb0a9947e6f1f76e58dbf170f0.tar.bz2 |
gh-87901: Add encoding to os.popen (GH-92374)
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -974,7 +974,7 @@ 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): + def popen(cmd, mode="r", buffering=-1, encoding=None): if not isinstance(cmd, str): raise TypeError("invalid cmd type (%s, expected string)" % type(cmd)) if mode not in ("r", "w"): @@ -982,6 +982,7 @@ if sys.platform != 'vxworks': if buffering == 0 or buffering is None: raise ValueError("popen() does not support unbuffered streams") import subprocess, io + encoding = io.text_encoding(encoding) if mode == "r": proc = subprocess.Popen(cmd, shell=True, text=True, |