Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stderr_w = stdout_w
elif stderr == PIPE:
stderr_r, stderr_w = os.pipe()
stderr_w = os.fdopen(stderr_w, 'wb')
if encoding:
stderr_r = io.open(stderr_r, 'r', encoding=encoding)
else:
stderr_r = os.fdopen(stderr_r, 'rb')
stderr_pipe = True
else:
stderr_r = stderr_w = stderr
if stdout_pipe or stderr_pipe:
capture_encoding = None
else:
capture_encoding = encoding
w = Wurlitzer(stdout=stdout_w, stderr=stderr_w, encoding=capture_encoding)
try:
with w:
yield stdout_r, stderr_r
finally:
# close pipes
if stdout_pipe:
stdout_w.close()
if stderr_pipe:
stderr_w.close()