Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 15811:1a00d21910c8 legacy-trunk
Implementation of PEP-0217.
This closes the PEP, and patch 103170
| author | Moshe Zadka <moshez@math.huji.ac.il> |
|---|---|
| date | Thu, 11 Jan 2001 05:41:27 +0000 |
| parents | f9772f87b13e |
| children | faaf9f10d849 |
line wrap: on
line diff
--- a/Python/ceval.c Thu Jan 11 04:19:52 2001 +0000 +++ b/Python/ceval.c Thu Jan 11 05:41:27 2001 +0000 @@ -1245,36 +1245,26 @@ 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 */
