mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Finishing touch to Ping's changes. This is a patch that Ping sent me
but apparently he had to go to school, so I am checking it in for him. This makes PyRun_HandleSystemExit() a static instead, called handle_system_exit(), and let it use the current exception rather than passing in an exception. This slightly simplifies the code.
This commit is contained in:
parent
62d248892f
commit
66e8e86cf8
1 changed files with 11 additions and 11 deletions
|
@ -798,9 +798,11 @@ print_error_text(PyObject *f, int offset, char *text)
|
||||||
PyFile_WriteString("^\n", f);
|
PyFile_WriteString("^\n", f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
PyRun_HandleSystemExit(PyObject* value)
|
handle_system_exit(void)
|
||||||
{
|
{
|
||||||
|
PyObject *exception, *value, *tb;
|
||||||
|
PyErr_Fetch(&exception, &value, &tb);
|
||||||
if (Py_FlushLine())
|
if (Py_FlushLine())
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -831,15 +833,14 @@ void
|
||||||
PyErr_PrintEx(int set_sys_last_vars)
|
PyErr_PrintEx(int set_sys_last_vars)
|
||||||
{
|
{
|
||||||
PyObject *exception, *v, *tb, *hook;
|
PyObject *exception, *v, *tb, *hook;
|
||||||
|
|
||||||
|
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||||
|
handle_system_exit();
|
||||||
|
}
|
||||||
PyErr_Fetch(&exception, &v, &tb);
|
PyErr_Fetch(&exception, &v, &tb);
|
||||||
PyErr_NormalizeException(&exception, &v, &tb);
|
PyErr_NormalizeException(&exception, &v, &tb);
|
||||||
|
|
||||||
if (exception == NULL)
|
if (exception == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PyErr_GivenExceptionMatches(exception, PyExc_SystemExit)) {
|
|
||||||
PyRun_HandleSystemExit(v);
|
|
||||||
}
|
|
||||||
if (set_sys_last_vars) {
|
if (set_sys_last_vars) {
|
||||||
PySys_SetObject("last_type", exception);
|
PySys_SetObject("last_type", exception);
|
||||||
PySys_SetObject("last_value", v);
|
PySys_SetObject("last_value", v);
|
||||||
|
@ -852,12 +853,11 @@ PyErr_PrintEx(int set_sys_last_vars)
|
||||||
PyObject *result = PyEval_CallObject(hook, args);
|
PyObject *result = PyEval_CallObject(hook, args);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
PyObject *exception2, *v2, *tb2;
|
PyObject *exception2, *v2, *tb2;
|
||||||
|
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||||
|
handle_system_exit();
|
||||||
|
}
|
||||||
PyErr_Fetch(&exception2, &v2, &tb2);
|
PyErr_Fetch(&exception2, &v2, &tb2);
|
||||||
PyErr_NormalizeException(&exception2, &v2, &tb2);
|
PyErr_NormalizeException(&exception2, &v2, &tb2);
|
||||||
if (PyErr_GivenExceptionMatches(
|
|
||||||
exception2, PyExc_SystemExit)) {
|
|
||||||
PyRun_HandleSystemExit(v2);
|
|
||||||
}
|
|
||||||
if (Py_FlushLine())
|
if (Py_FlushLine())
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue