Python subprocess stderr/stdout field is None if created -
when create python subprocess file stream stderr (or stdout), corresponding field none:
s = subprocess.popen(['ls','qwer'], stdout=subprocess.pipe, stdin=subprocess.pipe, stderr=open("zzzzz",'wb')) s.stderr none ==> true (i expected s.stderr file stream).
- is documented/intentional?
- what rationale?
yes, intentional. when provide stdout/stdin/stderr kwargs popen constructor, you're telling direct pipes in child process:
stdin, stdout , stderr specify executed program’s standard input, standard output , standard error file handles, respectively.
but stdout/stdin/stderr properties on popen object are documented having value when use pipe:
popen.stdin
if stdin argument pipe, attribute file object provides input child process. otherwise, none.
popen.stdout
if stdout argument pipe, attribute file object provides output child process. otherwise, none.
popen.stderr
if stderr argument pipe, attribute file object provides error output child process. otherwise, none.
as why popen.std* none when pass handle other pipe, i'm not certain. perhaps because considered redundant, since had pass open handle constructor begin with?
Comments
Post a Comment