SF Bug #602245: os.popen() negative error code IOError
I just submitted a bug at SF entitled 'os.popen() negative error code IOError'. However, not knowing SF too well, I've messed up the formatting of the test code, so here it is. 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 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') Tim Delaney
Tim> I just submitted a bug at SF entitled 'os.popen() negative error Tim> code IOError'. However, not knowing SF too well, I've messed up the Tim> formatting of the test code, so here it is. It's actually formatted okay, if you save or view source you can cut out your test pretty easily. Still, anytime you want to include more than two or three lines of code, you're going to be much better off attaching the code (which I just did). -- Skip Montanaro skip@pobox.com consulting: http://manatee.mojam.com/~skip/resume.html
participants (2)
-
Delaney, Timothy
-
Skip Montanaro