diff Python/pythonrun.c @ 17212:215dc725db84 legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Fri, 23 Mar 2001 17:54:43 +0000
parents 16f145aac2ec
children 32fb6643adf1
line wrap: on
line diff
--- a/Python/pythonrun.c	Fri Mar 23 17:53:49 2001 +0000
+++ b/Python/pythonrun.c	Fri Mar 23 17:54:43 2001 +0000
@@ -798,9 +798,11 @@
 	PyFile_WriteString("^\n", f);
 }
 
-void
-PyRun_HandleSystemExit(PyObject* value)
+static void
+handle_system_exit(void)
 {
+        PyObject *exception, *value, *tb;
+	PyErr_Fetch(&exception, &value, &tb);
 	if (Py_FlushLine())
 		PyErr_Clear();
 	fflush(stdout);
@@ -831,15 +833,14 @@
 PyErr_PrintEx(int set_sys_last_vars)
 {
 	PyObject *exception, *v, *tb, *hook;
+
+	if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
+		handle_system_exit();
+	}
 	PyErr_Fetch(&exception, &v, &tb);
 	PyErr_NormalizeException(&exception, &v, &tb);
-
 	if (exception == NULL)
 		return;
-
-	if (PyErr_GivenExceptionMatches(exception, PyExc_SystemExit)) {
-		PyRun_HandleSystemExit(v);
-	}
 	if (set_sys_last_vars) {
 		PySys_SetObject("last_type", exception);
 		PySys_SetObject("last_value", v);
@@ -852,12 +853,11 @@
 		PyObject *result = PyEval_CallObject(hook, args);
 		if (result == NULL) {
 			PyObject *exception2, *v2, *tb2;
+			if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
+				handle_system_exit();
+			}
 			PyErr_Fetch(&exception2, &v2, &tb2);
 			PyErr_NormalizeException(&exception2, &v2, &tb2);
-			if (PyErr_GivenExceptionMatches(
-				exception2, PyExc_SystemExit)) {
-				PyRun_HandleSystemExit(v2);
-			}
 			if (Py_FlushLine())
 				PyErr_Clear();
 			fflush(stdout);