New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a new subprocess.call which raises an error on non-zero rc #41218
Comments
The attached patch introduces a 3rd utility function - This saves writing if call(...):
raise OSError(...) It is most useful for shell script replacement When you've moved up to python because shell is too I consider raising an exception to be much more Eg # An easy to miss error >>> subprocess.call(["mkdir", "a/b"])
mkdir: cannot create directory `a/b': No such file or
directory
1
>>> # user forgot to check non-zero return code # becomes an impossible to miss exception >>> subprocess.xcall(["mkdir", "a/b"])
mkdir: cannot create directory `a/b': No such file or
directory
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "subprocess.py", line 462, in xcall
raise CalledProcessError(rc, "Command %s returned
non zero exit status" % args[0])
subprocess.CalledProcessError: [Errno 1] Command
['mkdir', 'a/b'] returned non zero exit status
>>> See attached patch for more! Its been tested under |
Logged In: YES Since this is a new feature, the patch will go into trunk, |
Logged In: YES My suggested name is "check_call". |
Logged In: YES If there are no objections, I will commit the "Adapted patch |
Logged In: YES Patch applied. New revisions: subprocess.py 1.12 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: