[Python-bugs-list] [ python-Bugs-602245 ] os.popen() negative error code IOError
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 30 Aug 2002 07:05:27 -0700
Bugs item #602245, was opened at 2002-08-30 02:25
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=602245&group_id=5470
>Category: Windows
>Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Delaney (tcdelaney)
>Assigned to: Mark Hammond (mhammond)
Summary: os.popen() negative error code IOError
Initial Comment:
Windows 2000, Python 2.0.1, 2.1.1, 2.2.
When a negative return code is received by the os.popen
() family, an IOError is raised when the last pipe from the
process is closed.
The following code demonstrates the problem:
import sys
import os
import traceback
if __name__ == '__main__':
if len(sys.argv) == 1:
try:
r = os.popen('%s %s %s' % (sys.executable,
sys.argv[0], -1,))
r.close()
except IOError:
traceback.print_exc()
try:
w, r = os.popen2('%s %s %s' %
(sys.executable, sys.argv[0], -1,))
w.close()
r.close()
except IOError:
traceback.print_exc()
try:
w, r, e = os.popen3('%s %s %s' %
(sys.executable, sys.argv[0], -1,))
w.close()
r.close()
e.close()
except IOError:
traceback.print_exc()
else:
sys.exit(int(sys.argv[1]))
---------- Run ----------
Traceback (most recent call last):
File "Q:\Viper\src\webvis\tests\test.py", line 11, in ?
r.close()
IOError: (0, 'Error')
Traceback (most recent call last):
File "Q:\Viper\src\webvis\tests\test.py", line 18, in ?
r.close()
IOError: (0, 'Error')
Traceback (most recent call last):
File "Q:\Viper\src\webvis\tests\test.py", line 26, in ?
e.close()
IOError: (0, 'Error')
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-30 10:05
Message:
Logged In: YES
user_id=6380
I suppose this is one for Mark Hammond...
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2002-08-30 08:38
Message:
Logged In: YES
user_id=44345
Attached Tim's code so it's more readily accessible to testers.
BTW, works fine for me on Linux.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=602245&group_id=5470