[Python-Dev] new popen for win32! [status update]

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Sun, 9 Jul 2000 19:37:35 +0200

following up on myself:

> > - first, a stupid question: is the popen2 and popen3
> >   versions replacements for the corresponding functions
> >   in the popen2 module.
> >=20
> >   (or to put it another way: should the popen2 module
> >   be modified to use these functions on Windows?)
> the new posix code exports popen2, popen3, and popen4
> on windows.  I'll provide patches for popen2.py later (gotta
> do some more testing first).

the current api is:

    popen2.popen2(command, bufsize=3Ddefault)
    popen2.popen3(command, bufsize=3Ddefault)


    nt.popen2(command, mode=3D"t")
    nt.popen3(command, mode=3D"t")

the perfect compromise would of course be

    popen2(command, mode=3D"t", bufsize=3Ddefault)

(similar to plain open).

I suggest the popen2 api's to:

    def popen2.popen2(command, mode=3D"t", bufsize=3D-1):
        if type(mode) is type(0) and bufsize=3D=3D-1:
            bufsize =3D mode
            mode =3D "t"

    def nt.popen2(command, mode, bufsize=3D-1):
        if bufsize !=3D -1:
            raise ValueError, "cannot set buffer size on windows"