diff options
author | Moshe Zadka <moshez@math.huji.ac.il> | 2001-01-11 05:41:27 (GMT) |
---|---|---|
committer | Moshe Zadka <moshez@math.huji.ac.il> | 2001-01-11 05:41:27 (GMT) |
commit | f68f2fec7df1224a031c3feed8a0ef6028cfcddd (patch) | |
tree | 575eb2afba4c192fcb8d272906afdf203ed23946 /Python/ceval.c | |
parent | 5ac97957f72d42d5bc3ec658b4321cc207cb038e (diff) | |
download | cpython-f68f2fec7df1224a031c3feed8a0ef6028cfcddd.zip cpython-f68f2fec7df1224a031c3feed8a0ef6028cfcddd.tar.gz cpython-f68f2fec7df1224a031c3feed8a0ef6028cfcddd.tar.bz2 |
Implementation of PEP-0217.
This closes the PEP, and patch 103170
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 5110746..8012b83 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1245,36 +1245,26 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals, case PRINT_EXPR: v = POP(); - /* Print value except if None */ - /* After printing, also assign to '_' */ - /* Before, set '_' to None to avoid recursion */ - if (v != Py_None && - (err = PyDict_SetItemString( - f->f_builtins, "_", Py_None)) == 0) { - err = Py_FlushLine(); - if (err == 0) { - x = PySys_GetObject("stdout"); - if (x == NULL) { - PyErr_SetString( - PyExc_RuntimeError, - "lost sys.stdout"); - err = -1; - } - } - if (err == 0) - err = PyFile_WriteObject(v, x, 0); - if (err == 0) { - PyFile_SoftSpace(x, 1); - err = Py_FlushLine(); - } - if (err == 0) { - err = PyDict_SetItemString( - f->f_builtins, "_", v); - } + w = PySys_GetObject("displayhook"); + if (w == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "lost sys.displayhook"); + err = -1; + } + if (err == 0) { + x = Py_BuildValue("(O)", v); + if (x == NULL) + err = -1; + } + if (err == 0) { + w = PyEval_CallObject(w, x); + if (w == NULL) + err = -1; } Py_DECREF(v); + Py_XDECREF(x); break; - + case PRINT_ITEM_TO: w = stream = POP(); /* fall through to PRINT_ITEM */ |