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.

Author lemburg
Recipients lemburg, vstinner
Date 2011-03-02.22:42:28
SpamBayes Score 1.4824e-11
Marked as misclassified No
Message-id <>
In-reply-to <>
STINNER Victor wrote:
> STINNER Victor <> added the comment:
> os.popen() is deprecated since Python 2.6 ("Use the subprocess module.") and it is no more documented in Python 3. The following documentation explains how to replace os.popen() by subprocess:
>> Does it prevent a shell window from opening on Windows ?
> Yes, but only if shell=True.
>> Does subprocess.Popen() use the system's PATH for finding the
> executable ?
> Yes. The subprocess module calls os.get_exec_path() which reads PATH environment variable.

One more question:

Doe subprocess work from inside Windows GUI applications ?

(I added the _popen class to work around issues with those
 a long while back)

>> Since it's a documented API, we could replace it with an
>> implementation that uses subprocess.Popen(),
> platform_popen.patch patchs platform.popen() to reuse os.popen() (which uses subprocess). It adds also tests (there was no test for platform.popen)

Hmm, but if os.popen() is no longer supported in Python 3, how can
we still use it in platform ?

The os module still provides an popen() function which uses subprocess.

The documentation for the os module says:


    Run child processes, returning opened pipes for communications. These functions are described in
section File Object Creation.

If you then go to the suggested section, there's no mention of os.popen().
popen() is also referenced in a few other places in the os module

The documentation should either be removed completely, or restored to
match the existing os module function popen().

>> but not remove it.
> Can't we at deprecate platform.popen in favor of subprocess, with a documentation to explain how to port code to subprocess?

Sure, just not remove it immediately.

> My patch doesn't touch platform documentation.

> --
> os.popen() does still exist in Python 3.2, but it is no more documented. Its documentation should be fixed or the function should be removed.

Indeed. See above.

Marc-Andre Lemburg


::: Try our new mxODBC.Connect Python Database Interface for free ! :::: Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
Date User Action Args
2011-03-02 22:42:30lemburgsetrecipients: + lemburg, vstinner
2011-03-02 22:42:28lemburglinkissue11377 messages
2011-03-02 22:42:28lemburgcreate