Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 46297:f806fd9941da | 46299:e8916c64df4c |
|---|---|
| 1465 | 1465 |
| 1466 static void | 1466 static void |
| 1467 flush_io(void) | 1467 flush_io(void) |
| 1468 { | 1468 { |
| 1469 PyObject *f, *r; | 1469 PyObject *f, *r; |
| 1470 PyObject *type, *value, *traceback; | |
| 1471 | |
| 1472 /* Save the current exception */ | |
| 1473 PyErr_Fetch(&type, &value, &traceback); | |
| 1474 | |
| 1470 f = PySys_GetObject("stderr"); | 1475 f = PySys_GetObject("stderr"); |
| 1471 if (f != NULL) { | 1476 if (f != NULL) { |
| 1472 r = PyObject_CallMethod(f, "flush", ""); | 1477 r = PyObject_CallMethod(f, "flush", ""); |
| 1473 if (r) | 1478 if (r) |
| 1474 Py_DECREF(r); | 1479 Py_DECREF(r); |
| 1481 if (r) | 1486 if (r) |
| 1482 Py_DECREF(r); | 1487 Py_DECREF(r); |
| 1483 else | 1488 else |
| 1484 PyErr_Clear(); | 1489 PyErr_Clear(); |
| 1485 } | 1490 } |
| 1491 | |
| 1492 PyErr_Restore(type, value, traceback); | |
| 1486 } | 1493 } |
| 1487 | 1494 |
| 1488 static PyObject * | 1495 static PyObject * |
| 1489 run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals, | 1496 run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals, |
| 1490 PyCompilerFlags *flags, PyArena *arena) | 1497 PyCompilerFlags *flags, PyArena *arena) |
