subprocess considered harmfull?

Fredrik Lundh fredrik at pythonware.com
Sun Sep 25 15:59:20 EDT 2005


Steven Bethard wrote:

> >  Using the following snippet:
> >   p =
> > subprocess.Popen(nmake,stderr=subprocess.PIPE,stdout=subprocess.PIPE, \
> >                        universal_newlines=True, bufsize=1)
> >   os.sys.stdout.writelines(p.stdout)
> >   os.sys.stdout.writelines(p.stderr)
> >  Works fine on the command line, but fails when called from within
> > Visual Studio, with the following error:
> >   File "C:\Python24\lib\subprocess.py", line 549, in __init__
> >     (p2cread, p2cwrite,
> >   File "C:\Python24\lib\subprocess.py", line 609, in _get_handles
> >     p2cread = self._make_inheritable(p2cread)
> >   File "C:\Python24\lib\subprocess.py", line 650, in _make_inheritable
> >     DUPLICATE_SAME_ACCESS)
> > TypeError: an integer is required
>
> This looks like these known bugs:
>      http://python.org/sf/1124861
>      http://python.org/sf/1126208
>
> Try setting stderr to subprocess.PIPE.  I think that was what worked for
> me.  (You might also try setting shell=True.  That's what I currently
> have in my code that didn't work before.)

if someone wants to investigate, is seeing this problem, and have the win32
extensions on their machine, try changing this line in subprocess.py:

    if 0: # <-- change this to use pywin32 instead of the _subprocess driver

to:

    if 1: # <-- change this to use _subprocess instead of the pywin32 driver

and see if it either fixes the problem (not very likely) or gives you a better
error message (very likely).

</F>






More information about the Python-list mailing list