fix: preserve sys.exit() exit codes in non-interactive mode by Sarah-2003 · Pull Request #15158 · ipython/ipython
added 2 commits
March 15, 2026 20:54When running `ipython -c "import sys;sys.exit(2)"`, IPython incorrectly returned exit code 1 instead of 2. The exit code was hardcoded to 1 in the start() method of TerminalIPythonApp regardless of the actual code passed to sys.exit(). Extract the original exit code from the stored SystemExit exception in last_execution_result.error_in_exec. Also handle SystemExit separately in the file execution path in _run_cmd_line_code(). Fixes ipython#15132
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters