You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add system_raise_on_error config option for ! shell operator (#15073)
Fixes#12264
Add system_raise_on_error configuration option that raises
CalledProcessError when shell commands executed via the ! operator
return non-zero exit status. This brings similar error-handling behavior
to the ! operator as was added to %%bash magic in PR #11287.
Changes:
- Add system_raise_on_error Bool traitlet config (default: False)
- Import CalledProcessError from subprocess
- Modify system_piped() to raise on non-zero exit when enabled
- Modify system_raw() to raise on non-zero exit when enabled
- Modify getoutput() to raise on non-zero exit when enabled (uses
get_output_error_code to capture exit status)
When enabled, users can halt notebook execution on command failures:
get_ipython().system_raise_on_error = True
!false # Now raises CalledProcessError
Note: A follow-up PR to ipykernel will be needed to support this in
Jupyter notebooks, as ZMQInteractiveShell overrides system_piped().
0 commit comments