mirror of
https://github.com/python/cpython.git
synced 2025-07-12 05:45:15 +00:00
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...
This commit is contained in:
parent
bff533b479
commit
9ed77358d6
2 changed files with 18 additions and 0 deletions
|
@ -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 *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue