summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-03-07 00:34:46 (GMT)
committerGeorg Brandl <georg@python.org>2007-03-07 00:34:46 (GMT)
commit49aafc9f2ce7d41be677cdefbcf0af6d9bd1e752 (patch)
treea5bcc5b8ae7b3a3c639510619726f680cf241c37 /Python
parent8537c303c796f42b0375922d2d8a17f3ebcb465a (diff)
downloadcpython-49aafc9f2ce7d41be677cdefbcf0af6d9bd1e752.zip
cpython-49aafc9f2ce7d41be677cdefbcf0af6d9bd1e752.tar.gz
cpython-49aafc9f2ce7d41be677cdefbcf0af6d9bd1e752.tar.bz2
Variant of patch #697613: don't exit the interpreter on a SystemExit
exception if the -i command line option or PYTHONINSPECT environment variable is given, but break into the interactive interpreter just like on other exceptions or normal program exit. (backport)
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 3d0c68f..aa7e624 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -69,6 +69,7 @@ extern void _PyGILState_Fini(void);
int Py_DebugFlag; /* Needed by parser.c */
int Py_VerboseFlag; /* Needed by import.c */
int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */
+int Py_InspectFlag; /* Needed to determine whether to exit at SystemError */
int Py_NoSiteFlag; /* Suppress 'import site' */
int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
int Py_FrozenFlag; /* Needed by getpath.c */
@@ -1019,6 +1020,11 @@ handle_system_exit(void)
PyObject *exception, *value, *tb;
int exitcode = 0;
+ if (Py_InspectFlag)
+ /* Don't exit if -i flag was given. This flag is set to 0
+ * when entering interactive mode for inspecting. */
+ return;
+
PyErr_Fetch(&exception, &value, &tb);
if (Py_FlushLine())
PyErr_Clear();