[New-bugs-announce] [issue2947] subprocess (Replacing popen) - add a warning / hint

Helmut Jarausch report at bugs.python.org
Thu May 22 17:18:06 CEST 2008


New submission from Helmut Jarausch <jarausch at skynet.be>:

Background:
I (as many others, too) have used the following code in the past

ARC='MyDumpFile'
tar_inp= os.popen('/bin/tar cjf '+ARC+' -T -','w')
....
tar_exit_code= tar_inp.close()
if  tar_exit_code != None and tar_exit_code % 256 :
  print "some error messages"

When replacing this - as suggested - by

TAR= Popen(('/bin/tar','cjf',ARC,'-T','-'),stdin=PIPE)
tar_inp= TAR.stdin
....
tar_inp.close() always returns None which was an indication
of NO ERROR when used together with popen.

So this has proabaly to be replaced by

tar_inp.close()
tar_exit_code= TAR.wait()

if  tar_exit_code != 0 :
  print "some error messages"


I suggest a warning / hint to change checking for errors
when upgrading to subprocess.Popen

----------
assignee: georg.brandl
components: Documentation
messages: 67195
nosy: HWJ, georg.brandl
severity: normal
status: open
title: subprocess (Replacing popen) - add a warning / hint
versions: Python 2.6

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2947>
__________________________________


More information about the New-bugs-announce mailing list