Skip to content

Support new iPython system_raise_on_error flag in ZMQInteractiveShell#1496

Open
adityawasudeo wants to merge 3 commits intoipython:mainfrom
adityawasudeo:add-system-raise-on-error
Open

Support new iPython system_raise_on_error flag in ZMQInteractiveShell#1496
adityawasudeo wants to merge 3 commits intoipython:mainfrom
adityawasudeo:add-system-raise-on-error

Conversation

@adityawasudeo
Copy link

This PR complements iPython PR ipython/ipython#15073 which adds a new 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/ipython#11287.

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.

Changes:

  • Import CalledProcessError from subprocess
  • Capture exit_code from system() call
  • Raise CalledProcessError when system_raise_on_error is True
    and exit_code is non-zero

This enables Jupyter notebook users to halt execution on shell
command failures when they opt-in via:
get_ipython().system_raise_on_error = True

@adityawasudeo adityawasudeo marked this pull request as ready for review February 19, 2026 16:26
@adityawasudeo
Copy link
Author

@ianthomas23 or @JohanMabille , would love to get a review on this when you have a couple of minutes. system_raise_on_error was merged into ipython last week and this PR will allow folks to start using it in their Jupyter notebooks. Many thanks!

@ianthomas23
Copy link
Collaborator

Can you rebase this on main as there were some CI problems that I think I have now fixed? Then I will take a look at it.

@adityawasudeo adityawasudeo force-pushed the add-system-raise-on-error branch from 5acbbb9 to 196605f Compare February 27, 2026 15:17
adityawasudeo and others added 3 commits February 27, 2026 07:19
Add support for IPython's system_raise_on_error configuration option
in ZMQInteractiveShell.system_piped() override.

This complements the IPython PR that adds the system_raise_on_error
config option (see ipython/ipython PR). 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.

Changes:
- Import CalledProcessError from subprocess
- Capture exit_code from system() call
- Raise CalledProcessError when system_raise_on_error is True
  and exit_code is non-zero

This enables Jupyter notebook users to halt execution on shell
command failures when they opt-in via:
  get_ipython().system_raise_on_error = True
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 adityawasudeo force-pushed the add-system-raise-on-error branch from 196605f to 4467887 Compare February 27, 2026 15:19
@adityawasudeo
Copy link
Author

Can you rebase this on main as there were some CI problems that I think I have now fixed? Then I will take a look at it.

@ianthomas23 Done. It looks like one of the windows tests is potentially flaky? I see it failed with an asyncio issue which seems unrelated to my changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants