On Jan 28, 2015, at 07:34 AM, Gregory P. Smith wrote:
On Tue Jan 27 2015 at 4:44:32 PM Thomas Kluyver firstname.lastname@example.org wrote:
- Add a CompletedProcess class:
- Attributes stdout and stderr are bytes if the relevant stream was piped,
None otherwise, like the return value of Popen.communicate()
Note that in Python 3, if universal_newlines=True is given, the output will be a str, not bytes. (The input is also switched from bytes to str, but that seems less common, at least in my use cases.) You'll probably build the new APIs on the existing ones, so I don't expect that to change. I just wanted to point that out.
- Attribute returncode is the exit status
- ? Attribute cmd is the list of arguments the process ran with (not sure
if this should be there or not)
- Method cp.check_returncode() raises CalledProcessError if returncode !=
0, inspired by requests' Response.raise_for_status()
- Add a run() function - like call/check_call/check_output, but returns a
I like #1 and #2 here.
- Deprecate call/check_call/check_output, but leave them around
indefinitely, since lots of existing code relies on them.
We need to keep those. They are too widely used and are the long term stable API for 2.7. They are useful for many simple cases which they were designed for.
Agreed that this seems like a nice improvement, but that we need to keep the old APIs around probably forever.