Index: Lib/subprocess.py =================================================================== --- Lib/subprocess.py (revision 65565) +++ Lib/subprocess.py (working copy) @@ -825,6 +825,13 @@ # translate errno using _sys_errlist (or simliar), but # how can this be done from Python? raise WindowsError(*e.args) + finally: + if p2cread is not None: + p2cread.Close() + if c2pwrite is not None: + c2pwrite.Close() + if errwrite is not None: + errwrite.Close() # Retain the process handle, but close the thread handle self._child_created = True @@ -838,12 +845,6 @@ # output pipe are maintained in this process or else the # pipe will not close when the child process exits and the # ReadFile will hang. - if p2cread is not None: - p2cread.Close() - if c2pwrite is not None: - c2pwrite.Close() - if errwrite is not None: - errwrite.Close() def _internal_poll(self, _deadstate=None):