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 vstinner
Recipients Neil Muller, amaury.forgeotdarc, benjamin.peterson, eric.araujo, ezio.melotti, georg.brandl, gvanrossum, krawyoti, vstinner
Date 2011-03-03.11:56:23
SpamBayes Score 2.220446e-16
Marked as misclassified No
Message-id <1299153384.58.0.61614979473.issue6490@psf.upfronthosting.co.za>
In-reply-to
Content
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()...
History
Date User Action Args
2011-03-03 11:56:24vstinnersetrecipients: + vstinner, gvanrossum, georg.brandl, amaury.forgeotdarc, benjamin.peterson, ezio.melotti, Neil Muller, eric.araujo, krawyoti
2011-03-03 11:56:24vstinnersetmessageid: <1299153384.58.0.61614979473.issue6490@psf.upfronthosting.co.za>
2011-03-03 11:56:24vstinnerlinkissue6490 messages
2011-03-03 11:56:23vstinnercreate