bpo-31904: Disable os.popen and popen test cases on VxWorks (GH-21687) · python/cpython@e1e3c2d (original) (raw)

`@@ -36,7 +36,7 @@

`

36

36

`all = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",

`

37

37

`"defpath", "name", "path", "devnull", "SEEK_SET", "SEEK_CUR",

`

38

38

`"SEEK_END", "fsencode", "fsdecode", "get_exec_path", "fdopen",

`

39

``

`-

"popen", "extsep"]

`

``

39

`+

"extsep"]

`

40

40

``

41

41

`def _exists(name):

`

42

42

`return name in globals()

`

`@@ -969,51 +969,55 @@ def spawnlpe(mode, file, *args):

`

969

969

``

970

970

`all.extend(["spawnlp", "spawnlpe"])

`

971

971

``

972

``

-

973

``

`-

Supply os.popen()

`

974

``

`-

def popen(cmd, mode="r", buffering=-1):

`

975

``

`-

if not isinstance(cmd, str):

`

976

``

`-

raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))

`

977

``

`-

if mode not in ("r", "w"):

`

978

``

`-

raise ValueError("invalid mode %r" % mode)

`

979

``

`-

if buffering == 0 or buffering is None:

`

980

``

`-

raise ValueError("popen() does not support unbuffered streams")

`

981

``

`-

import subprocess, io

`

982

``

`-

if mode == "r":

`

983

``

`-

proc = subprocess.Popen(cmd,

`

984

``

`-

shell=True,

`

985

``

`-

stdout=subprocess.PIPE,

`

986

``

`-

bufsize=buffering)

`

987

``

`-

return _wrap_close(io.TextIOWrapper(proc.stdout), proc)

`

988

``

`-

else:

`

989

``

`-

proc = subprocess.Popen(cmd,

`

990

``

`-

shell=True,

`

991

``

`-

stdin=subprocess.PIPE,

`

992

``

`-

bufsize=buffering)

`

993

``

`-

return _wrap_close(io.TextIOWrapper(proc.stdin), proc)

`

994

``

-

995

``

`-

Helper for popen() -- a proxy for a file whose close waits for the process

`

996

``

`-

class _wrap_close:

`

997

``

`-

def init(self, stream, proc):

`

998

``

`-

self._stream = stream

`

999

``

`-

self._proc = proc

`

1000

``

`-

def close(self):

`

1001

``

`-

self._stream.close()

`

1002

``

`-

returncode = self._proc.wait()

`

1003

``

`-

if returncode == 0:

`

1004

``

`-

return None

`

1005

``

`-

if name == 'nt':

`

1006

``

`-

return returncode

`

``

972

`+

VxWorks has no user space shell provided. As a result, running

`

``

973

`+

command in a shell can't be supported.

`

``

974

`+

if sys.platform != 'vxworks':

`

``

975

`+

Supply os.popen()

`

``

976

`+

def popen(cmd, mode="r", buffering=-1):

`

``

977

`+

if not isinstance(cmd, str):

`

``

978

`+

raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))

`

``

979

`+

if mode not in ("r", "w"):

`

``

980

`+

raise ValueError("invalid mode %r" % mode)

`

``

981

`+

if buffering == 0 or buffering is None:

`

``

982

`+

raise ValueError("popen() does not support unbuffered streams")

`

``

983

`+

import subprocess, io

`

``

984

`+

if mode == "r":

`

``

985

`+

proc = subprocess.Popen(cmd,

`

``

986

`+

shell=True,

`

``

987

`+

stdout=subprocess.PIPE,

`

``

988

`+

bufsize=buffering)

`

``

989

`+

return _wrap_close(io.TextIOWrapper(proc.stdout), proc)

`

1007

990

`else:

`

1008

``

`-

return returncode << 8 # Shift left to match old behavior

`

1009

``

`-

def enter(self):

`

1010

``

`-

return self

`

1011

``

`-

def exit(self, *args):

`

1012

``

`-

self.close()

`

1013

``

`-

def getattr(self, name):

`

1014

``

`-

return getattr(self._stream, name)

`

1015

``

`-

def iter(self):

`

1016

``

`-

return iter(self._stream)

`

``

991

`+

proc = subprocess.Popen(cmd,

`

``

992

`+

shell=True,

`

``

993

`+

stdin=subprocess.PIPE,

`

``

994

`+

bufsize=buffering)

`

``

995

`+

return _wrap_close(io.TextIOWrapper(proc.stdin), proc)

`

``

996

+

``

997

`+

Helper for popen() -- a proxy for a file whose close waits for the process

`

``

998

`+

class _wrap_close:

`

``

999

`+

def init(self, stream, proc):

`

``

1000

`+

self._stream = stream

`

``

1001

`+

self._proc = proc

`

``

1002

`+

def close(self):

`

``

1003

`+

self._stream.close()

`

``

1004

`+

returncode = self._proc.wait()

`

``

1005

`+

if returncode == 0:

`

``

1006

`+

return None

`

``

1007

`+

if name == 'nt':

`

``

1008

`+

return returncode

`

``

1009

`+

else:

`

``

1010

`+

return returncode << 8 # Shift left to match old behavior

`

``

1011

`+

def enter(self):

`

``

1012

`+

return self

`

``

1013

`+

def exit(self, *args):

`

``

1014

`+

self.close()

`

``

1015

`+

def getattr(self, name):

`

``

1016

`+

return getattr(self._stream, name)

`

``

1017

`+

def iter(self):

`

``

1018

`+

return iter(self._stream)

`

``

1019

+

``

1020

`+

all.append("popen")

`

1017

1021

``

1018

1022

`# Supply os.fdopen()

`

1019

1023

`def fdopen(fd, *args, **kwargs):

`