mirror of
https://github.com/python/cpython.git
synced 2025-11-14 07:49:28 +00:00
eval_code2(): Guido provides this patch for his suggested elaboration
of extended print. If the file object being printed to is None, then sys.stdout is used.
This commit is contained in:
parent
9821bf4e62
commit
093abe005d
1 changed files with 2 additions and 2 deletions
|
|
@ -1230,7 +1230,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
|
|
||||||
case PRINT_ITEM:
|
case PRINT_ITEM:
|
||||||
v = POP();
|
v = POP();
|
||||||
if (stream == NULL) {
|
if (stream == NULL || stream == Py_None) {
|
||||||
w = PySys_GetObject("stdout");
|
w = PySys_GetObject("stdout");
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
|
|
@ -1263,7 +1263,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
/* fall through to PRINT_NEWLINE */
|
/* fall through to PRINT_NEWLINE */
|
||||||
|
|
||||||
case PRINT_NEWLINE:
|
case PRINT_NEWLINE:
|
||||||
if (stream == NULL) {
|
if (stream == NULL || stream == Py_None) {
|
||||||
w = PySys_GetObject("stdout");
|
w = PySys_GetObject("stdout");
|
||||||
if (w == NULL)
|
if (w == NULL)
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue