Message129958
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()... |
|
Date |
User |
Action |
Args |
2011-03-03 11:56:24 | vstinner | set | recipients:
+ vstinner, gvanrossum, georg.brandl, amaury.forgeotdarc, benjamin.peterson, ezio.melotti, Neil Muller, eric.araujo, krawyoti |
2011-03-03 11:56:24 | vstinner | set | messageid: <1299153384.58.0.61614979473.issue6490@psf.upfronthosting.co.za> |
2011-03-03 11:56:24 | vstinner | link | issue6490 messages |
2011-03-03 11:56:23 | vstinner | create | |
|