Skip to content

Commit 7fedbe5

Browse files
committed
Add a NEWS entry for issue2221.
Also don't flush stdout on each call to exec() or eval(). Only interactive input really needs it.
1 parent 7852000 commit 7fedbe5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Misc/NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ What's New in Python 3.0a5?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #2221: Corrected a SystemError "error return without exception set",
16+
when the code executed by exec() raises an exception, and sys.stdout.flush()
17+
also raises an error.
18+
1519
- Bug #2565: The repr() of type objects now calls them 'class',
1620
not 'type' - whether they are builtin types or not.
1721

Python/pythonrun.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern grammar _PyParser_Grammar; /* From graminit.c */
5454
static void initmain(void);
5555
static void initsite(void);
5656
static int initstdio(void);
57+
static void flush_io(void);
5758
static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *,
5859
PyCompilerFlags *, PyArena *);
5960
static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *,
@@ -992,6 +993,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
992993
d = PyModule_GetDict(m);
993994
v = run_mod(mod, filename, d, d, flags, arena);
994995
PyArena_Free(arena);
996+
flush_io();
995997
if (v == NULL) {
996998
PyErr_Print();
997999
return -1;
@@ -1082,6 +1084,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
10821084
v = PyRun_FileExFlags(fp, filename, Py_file_input, d, d,
10831085
closeit, flags);
10841086
}
1087+
flush_io();
10851088
if (v == NULL) {
10861089
PyErr_Print();
10871090
ret = -1;
@@ -1513,7 +1516,6 @@ run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals,
15131516
return NULL;
15141517
v = PyEval_EvalCode(co, globals, locals);
15151518
Py_DECREF(co);
1516-
flush_io();
15171519
return v;
15181520
}
15191521

@@ -1546,7 +1548,6 @@ run_pyc_file(FILE *fp, const char *filename, PyObject *globals,
15461548
if (v && flags)
15471549
flags->cf_flags |= (co->co_flags & PyCF_MASK);
15481550
Py_DECREF(co);
1549-
flush_io();
15501551
return v;
15511552
}
15521553

0 commit comments

Comments
 (0)