Thanks Tim, very helpful again.
I've now reported this as http://bugs.python.org/issue3210
and implemented your suggested workaround.
Regards,
Geoff
On Jun 25, 9:19 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> geoffbache wrote:
> > Am currently being very confused over the following code on Windows
>
> > import subprocess, os
>
> > file = open("filename", "w")
> > try:
> > proc = subprocess.Popen("nosuchprogram", stdout=file)
> > except OSError:
> > file.close()
> > os.remove("filename")
>
> Forgot to say: slightly awkward, but you can work around
> it like this:
>
> <code>
> import os
> import subprocess
>
> f = open ("filename", "w")
> try:
> proc = subprocess.Popen ("blah", stdout=f)
> except OSError:
> os.close (f.fileno ())
>
> os.remove ("filename")
>
> </code>
>
> TJG
--
http://mail.python.org/mailman/listinfo/python-list