summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-04 23:25:27 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-04 23:25:27 +0000
commita80cb64a1a6c2f2c886b4b7e36c971cf975d8111 (patch)
treefa4a3f3dc0e52fea9b15d0790dcf8fb7741b6b0d /Python/pythonrun.c
parentd69aba1271a0b882e27877f9873ca7c349bb4422 (diff)
downloadcpython-a80cb64a1a6c2f2c886b4b7e36c971cf975d8111.tar.gz
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...
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 74e3430e97..3207fb8b81 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1467,6 +1467,11 @@ static void
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 @@ flush_io(void)
else
PyErr_Clear();
}
+
+ PyErr_Restore(type, value, traceback);
}
static PyObject *