Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 46395:6196529afd73
Add a NEWS entry for issue2221.
Also don't flush stdout on each call to exec() or eval().
Only interactive input really needs it.
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> |
|---|---|
| date | Thu, 10 Apr 2008 21:03:09 +0000 |
| parents | 22a74eaf6b22 |
| children | 47d9bbe10897 |
comparison
equal
deleted
inserted
replaced
| 46394:8416cdd11c11 | 46395:6196529afd73 |
|---|---|
| 52 | 52 |
| 53 /* Forward */ | 53 /* Forward */ |
| 54 static void initmain(void); | 54 static void initmain(void); |
| 55 static void initsite(void); | 55 static void initsite(void); |
| 56 static int initstdio(void); | 56 static int initstdio(void); |
| 57 static void flush_io(void); | |
| 57 static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *, | 58 static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *, |
| 58 PyCompilerFlags *, PyArena *); | 59 PyCompilerFlags *, PyArena *); |
| 59 static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *, | 60 static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *, |
| 60 PyCompilerFlags *); | 61 PyCompilerFlags *); |
| 61 static void err_input(perrdetail *); | 62 static void err_input(perrdetail *); |
| 990 return -1; | 991 return -1; |
| 991 } | 992 } |
| 992 d = PyModule_GetDict(m); | 993 d = PyModule_GetDict(m); |
| 993 v = run_mod(mod, filename, d, d, flags, arena); | 994 v = run_mod(mod, filename, d, d, flags, arena); |
| 994 PyArena_Free(arena); | 995 PyArena_Free(arena); |
| 996 flush_io(); | |
| 995 if (v == NULL) { | 997 if (v == NULL) { |
| 996 PyErr_Print(); | 998 PyErr_Print(); |
| 997 return -1; | 999 return -1; |
| 998 } | 1000 } |
| 999 Py_DECREF(v); | 1001 Py_DECREF(v); |
| 1080 v = run_pyc_file(fp, filename, d, d, flags); | 1082 v = run_pyc_file(fp, filename, d, d, flags); |
| 1081 } else { | 1083 } else { |
| 1082 v = PyRun_FileExFlags(fp, filename, Py_file_input, d, d, | 1084 v = PyRun_FileExFlags(fp, filename, Py_file_input, d, d, |
| 1083 closeit, flags); | 1085 closeit, flags); |
| 1084 } | 1086 } |
| 1087 flush_io(); | |
| 1085 if (v == NULL) { | 1088 if (v == NULL) { |
| 1086 PyErr_Print(); | 1089 PyErr_Print(); |
| 1087 ret = -1; | 1090 ret = -1; |
| 1088 goto done; | 1091 goto done; |
| 1089 } | 1092 } |
| 1511 co = PyAST_Compile(mod, filename, flags, arena); | 1514 co = PyAST_Compile(mod, filename, flags, arena); |
| 1512 if (co == NULL) | 1515 if (co == NULL) |
| 1513 return NULL; | 1516 return NULL; |
| 1514 v = PyEval_EvalCode(co, globals, locals); | 1517 v = PyEval_EvalCode(co, globals, locals); |
| 1515 Py_DECREF(co); | 1518 Py_DECREF(co); |
| 1516 flush_io(); | |
| 1517 return v; | 1519 return v; |
| 1518 } | 1520 } |
| 1519 | 1521 |
| 1520 static PyObject * | 1522 static PyObject * |
| 1521 run_pyc_file(FILE *fp, const char *filename, PyObject *globals, | 1523 run_pyc_file(FILE *fp, const char *filename, PyObject *globals, |
| 1544 co = (PyCodeObject *)v; | 1546 co = (PyCodeObject *)v; |
| 1545 v = PyEval_EvalCode(co, globals, locals); | 1547 v = PyEval_EvalCode(co, globals, locals); |
| 1546 if (v && flags) | 1548 if (v && flags) |
| 1547 flags->cf_flags |= (co->co_flags & PyCF_MASK); | 1549 flags->cf_flags |= (co->co_flags & PyCF_MASK); |
| 1548 Py_DECREF(co); | 1550 Py_DECREF(co); |
| 1549 flush_io(); | |
| 1550 return v; | 1551 return v; |
| 1551 } | 1552 } |
| 1552 | 1553 |
| 1553 PyObject * | 1554 PyObject * |
| 1554 Py_CompileStringFlags(const char *str, const char *filename, int start, | 1555 Py_CompileStringFlags(const char *str, const char *filename, int start, |
