Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 41043:728c60e85efa legacy-trunk
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)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Wed, 07 Mar 2007 00:34:46 +0000 |
| parents | 5c08e6460dc5 |
| children | c8ed4aea6c58 |
comparison
equal
deleted
inserted
replaced
| 41041:757e93a4096c | 41043:728c60e85efa |
|---|---|
| 67 #endif /* WITH_THREAD */ | 67 #endif /* WITH_THREAD */ |
| 68 | 68 |
| 69 int Py_DebugFlag; /* Needed by parser.c */ | 69 int Py_DebugFlag; /* Needed by parser.c */ |
| 70 int Py_VerboseFlag; /* Needed by import.c */ | 70 int Py_VerboseFlag; /* Needed by import.c */ |
| 71 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ | 71 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ |
| 72 int Py_InspectFlag; /* Needed to determine whether to exit at SystemError */ | |
| 72 int Py_NoSiteFlag; /* Suppress 'import site' */ | 73 int Py_NoSiteFlag; /* Suppress 'import site' */ |
| 73 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ | 74 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ |
| 74 int Py_FrozenFlag; /* Needed by getpath.c */ | 75 int Py_FrozenFlag; /* Needed by getpath.c */ |
| 75 int Py_UnicodeFlag = 0; /* Needed by compile.c */ | 76 int Py_UnicodeFlag = 0; /* Needed by compile.c */ |
| 76 int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ | 77 int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ |
| 1016 static void | 1017 static void |
| 1017 handle_system_exit(void) | 1018 handle_system_exit(void) |
| 1018 { | 1019 { |
| 1019 PyObject *exception, *value, *tb; | 1020 PyObject *exception, *value, *tb; |
| 1020 int exitcode = 0; | 1021 int exitcode = 0; |
| 1022 | |
| 1023 if (Py_InspectFlag) | |
| 1024 /* Don't exit if -i flag was given. This flag is set to 0 | |
| 1025 * when entering interactive mode for inspecting. */ | |
| 1026 return; | |
| 1021 | 1027 |
| 1022 PyErr_Fetch(&exception, &value, &tb); | 1028 PyErr_Fetch(&exception, &value, &tb); |
| 1023 if (Py_FlushLine()) | 1029 if (Py_FlushLine()) |
| 1024 PyErr_Clear(); | 1030 PyErr_Clear(); |
| 1025 fflush(stdout); | 1031 fflush(stdout); |
