Skip to content

Add system_raise_on_error config option for ! shell operator#15073

Merged
Carreau merged 1 commit intoipython:mainfrom
adityawasudeo:add-system-raise-on-error
Feb 19, 2026
Merged

Add system_raise_on_error config option for ! shell operator#15073
Carreau merged 1 commit intoipython:mainfrom
adityawasudeo:add-system-raise-on-error

Conversation

@adityawasudeo
Copy link
Copy Markdown
Contributor

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().

Fixes ipython#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 ipython#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().
@adityawasudeo adityawasudeo marked this pull request as ready for review November 14, 2025 02:48
@adityawasudeo
Copy link
Copy Markdown
Contributor Author

Bumping this. @Carreau would you be able to review it if you have a few minutes to spare? Many thanks!

@adityawasudeo
Copy link
Copy Markdown
Contributor Author

Pinging this, is there any interest in this PR? Would be nice to at least get some feedback on why this didn't make the cut

@Carreau Carreau added this to the 9.10 milestone Feb 19, 2026
@Carreau
Copy link
Copy Markdown
Member

Carreau commented Feb 19, 2026

Sorry, thanks for pinging me.

@Carreau Carreau merged commit cf9f2b2 into ipython:main Feb 19, 2026
20 checks passed
adityawasudeo added a commit to adityawasudeo/ipykernel that referenced this pull request Feb 19, 2026
configuration option in ZMQInteractiveShell.system_piped() override.

This complements IPython PR #15073
(ipython/ipython#15073) that adds
the system_raise_on_error config option. Since ZMQInteractiveShell overrides system_piped() for Windows UNC path handling, it
needs to also check the system_raise_on_error config and raise CalledProcessError on non-zero exit status.
adityawasudeo added a commit to adityawasudeo/ipykernel that referenced this pull request Feb 27, 2026
configuration option in ZMQInteractiveShell.system_piped() override.

This complements IPython PR #15073
(ipython/ipython#15073) that adds
the system_raise_on_error config option. Since ZMQInteractiveShell overrides system_piped() for Windows UNC path handling, it
needs to also check the system_raise_on_error config and raise CalledProcessError on non-zero exit status.
adityawasudeo added a commit to adityawasudeo/ipykernel that referenced this pull request Feb 27, 2026
configuration option in ZMQInteractiveShell.system_piped() override.

This complements IPython PR #15073
(ipython/ipython#15073) that adds
the system_raise_on_error config option. Since ZMQInteractiveShell overrides system_piped() for Windows UNC path handling, it
needs to also check the system_raise_on_error config and raise CalledProcessError on non-zero exit status.
adityawasudeo added a commit to adityawasudeo/ipykernel that referenced this pull request Mar 2, 2026
configuration option in ZMQInteractiveShell.system_piped() override.

This complements IPython PR #15073
(ipython/ipython#15073) that adds
the system_raise_on_error config option. Since ZMQInteractiveShell overrides system_piped() for Windows UNC path handling, it
needs to also check the system_raise_on_error config and raise CalledProcessError on non-zero exit status.
@Carreau Carreau modified the milestones: 9.10, 9.11 Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell command via bang doesn't have an error on status code

2 participants