Skip to content

Document how to raise on failed ! shell commands - #15497

Open
sujairibrahim wants to merge 1 commit into
ipython:mainfrom
sujairibrahim:docs-9657-system-raise-on-error
Open

sujairibrahim wants to merge 1 commit into
ipython:mainfrom
sujairibrahim:docs-9657-system-raise-on-error

Conversation

@sujairibrahim

Copy link
Copy Markdown

Before you open this pull request, read AGENTS.md. It was written with AI assistance, so check its advice against the project's own guidelines. It covers linting, tests, and pull request rules.

Summary

The shell access guide did not say what happens when a ! command fails, or how to make that failure raise an exception.

This adds that to docs/source/interactive/reference.rst: by default the exit status is stored in _exit_code; InteractiveShell.system_raise_on_error makes ! and !! raise subprocess.CalledProcessError; the option can be set with %config or in a config file; %%script is separate and uses --no-raise-error. 🤖🤖

References

Fixes #9657

Closed PR #15483 tried to document the same setting but was closed for missing AGENTS.md and the PR template. This PR is not a copy of that one: it also covers the default _exit_code behavior, captured !! / ! output, the config-file form, and the difference from %%script.

AI usage

  • Tool: Grok Bot (Cursor)
  • Model: I do not know the underlying model name
  • Effort level: I do not know the effort level
  • [ ]: Human supervision (did a person direct the work, read the whole diff and run the change?)

Opened as a draft until I have read the whole diff myself.

Checklist

  • I understand that if I submit a pull request similar to an earlier one, without strongly arguing for a different implementation, I risk a 30-day ban (see Bans).
  • I understand that if I open a pull request while more than 30 pull requests are open on the repository, without also helping to review other pull requests, I risk a temporary ban as well (see Bans). I reviewed DOC: Fix typo in whatsnew v8 #15492.

The shell access guide did not say how `!` commands treat a non-zero
exit status, or how to make failures raise an exception.

Document the default `_exit_code` behavior, that `!!` and captured `!`
output are covered, how to enable InteractiveShell.system_raise_on_error
in a session or a config file, and that %%script uses --no-raise-error
instead.

Fixes ipython#9657
@sujairibrahim
sujairibrahim marked this pull request as ready for review December 1, 2026 15:59
Copilot AI balanced review requested due to automatic review settings December 1, 2026 16:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

Treat subprocess errors as exceptions

2 participants