[issue6490] os.popen documentation in 2.6 is probably wrong

Marc-Andre Lemburg report at bugs.python.org
Wed Mar 9 12:24:07 CET 2011


Marc-Andre Lemburg <mal at egenix.com> added the comment:

STINNER Victor wrote:
> 
> STINNER Victor <victor.stinner at haypocalc.com> added the comment:
> 
> r55334 removed popen2, popen3 and popen4 from the os module from Python 3 (before the 3.0 release), but not os.popen.
> 
> Python 3.2 has now convenience functions in subprocess to get the output of a program:
> 
> - check_output()
> - getstatusoutput()
> - getoutput()
> 
> They have a better API then os.popen because you can:
> 
>  - avoid the shell process and use a list of arguments (to avoid ugly shell quoting using ' or ")
>  - change the current directory
>  - decide if signal are restored or not
>  - get easily the exit code (not >> 8 magical operation on the close() output)
>  - use a different executable name
>  - pass file descriptor
>  - etc.

Right, but not all applications need all those features and
os.popen() has a nice, simple and well-known interface.

Since os.popen() is already implemented using subprocess, all
applications using os.popen() will benefit from any bug fixes
immediately, so the support effort in keeping it around is very low.

> I think that it's time to move forward and remove os.popen(). But... there are 66 calls to os.popen() in:
> 
> Doc/tools/docutils/writers/odf_odt
> Lib
> Lib/ctypes
> Lib/distutils
> Lib/distutils/command
> Lib/distutils/tests
> Lib/idlelib
> Lib/multiprocessing
> Lib/pydoc_data
> Lib/test
> Lib/tkinter/test/test_tkinter
> Mac/BuildScript
> Mac/Tools
> PCbuild
> PC/VC6
> PC/VS7.1
> PC/VS8.0
> Tools/msi
> Tools/scripts
> 
> So we can maybe start with:
>  - Restore the documentation

+1

As for the other popen() variants: those are already gone and are
indeed better implemented using subprocess directly.

----------
nosy: +lemburg

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6490>
_______________________________________


More information about the Python-bugs-list mailing list