This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: subprocess on Windows 2: unexpected failure
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: astrand, josiahcarlson, reowen
Priority: normal Keywords:

Created on 2004-10-29 21:35 by reowen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg22944 - (view) Author: Russell Owen (reowen) Date: 2004-10-29 21:35
My understanding was that subprocess.py was supposed to be 
backwards compatible with at least Python 2.3 if not 2.2. Wanting 
subprocess and backwards compatibility, I grabbed the subprocess.py 
from 2.4b1, changed the import if so that win32api was used (since I 
had no _subprocess library!) and found several problems, of which 
this is one (one per bug report):

The following code fails when run as a program on Windows Python 
2.3.
However, the exact same code works perfectly on a unix build of
Python 2.4b1 on MacOS X. It also works on Windows if I use
an interactive interpreter and type each line in by hand (skipping 
some irrelevant bits).

import subprocess
def xpaget(cmd, template="ds9"):
	fullCmd = '"xpaget" %s %s' % (template, cmd,)

	p = subprocess.Popen(
#		executable = _XPADir + "xpaget",  # use if bug in 
subprocess gets fixed
		args = fullCmd,
		shell = True,
		stdin = subprocess.PIPE,
		stdout = subprocess.PIPE,
		stderr = subprocess.PIPE,
		cwd = _XPADir,
	)
	try:
		p.stdin.close()
		errMsg = p.stderr.read()
		if errMsg:
			raise RuntimeError('%r failed: %s' % (fullCmd, errMsg))
		reply = p.stdin.read()  # the code fails here; the next print 
statement never executes
		print "xpaget read %r" % reply
		return reply
	finally:
		p.stdout.close()
		p.stderr.close()
msg22945 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2004-10-30 15:46
Logged In: YES 
user_id=341410

You may want to repost that with indentation (the original
bug report always loses indentation).
msg22946 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-11-07 16:00
Logged In: YES 
user_id=344921

The bug report doesn't actually say which kind of traceback
or error message is generated, but the problem is most
likely caused by the application: It tries to read from
p.stdin after it has been closed. 

Closing. 
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41104
2004-10-29 21:35:22reowencreate