[issue6490] os.popen documentation in 2.6 is probably wrong
STINNER Victor
report at bugs.python.org
Thu Mar 3 12:56:24 CET 2011
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.
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
- Mark this function as deprecated in the doc
- Emit a deprecating warning in the code
- Start to replace os.popen() with subprocess in Python
And then maybe never drop it :-)
Note: even subprocess.getstatusoutput() is implemented using os.popen()...
----------
nosy: +haypo
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6490>
_______________________________________
More information about the Python-bugs-list
mailing list