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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -