diff Python/pythonrun.c @ 46299:e8916c64df4c

Issue2221: in Idle, exec('xx') raised a SystemError('error return without exception set') instead of the expected NameError This happens when sys.stdout is redirected to something that cannot flush(). the flush_io() function must be exception-neutral: don't raise, and don't clear exceptions. Next step: exec() is not supposed to flush sys.stdout...
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Fri, 04 Apr 2008 23:25:27 +0000
parents b06a15efdc6d
children 22a74eaf6b22
line wrap: on
line diff
--- a/Python/pythonrun.c	Fri Apr 04 19:53:14 2008 +0000
+++ b/Python/pythonrun.c	Fri Apr 04 23:25:27 2008 +0000
@@ -1467,6 +1467,11 @@
 flush_io(void)
 {
 	PyObject *f, *r;
+	PyObject *type, *value, *traceback;
+
+	/* Save the current exception */
+	PyErr_Fetch(&type, &value, &traceback);
+
 	f = PySys_GetObject("stderr");
 	if (f != NULL) {
 		r = PyObject_CallMethod(f, "flush", "");
@@ -1483,6 +1488,8 @@
 		else
 			PyErr_Clear();
 	}
+
+	PyErr_Restore(type, value, traceback);
 }
 
 static PyObject *