Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 7014:c75d899e666f legacy-trunk
Last-minute fix for Jim H: don't die after del sys.stdout
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 31 Dec 1997 05:53:15 +0000 |
| parents | f14e4459fb94 |
| children | ad114620f8c2 |
line wrap: on
line diff
--- a/Python/ceval.c Wed Dec 31 04:51:23 1997 +0000 +++ b/Python/ceval.c Wed Dec 31 05:53:15 1997 +0000 @@ -1017,8 +1017,12 @@ err = Py_FlushLine(); if (err == 0) { x = PySys_GetObject("stdout"); - if (x == NULL) + if (x == NULL) { + PyErr_SetString( + PyExc_RuntimeError, + "lost sys.stdout"); err = -1; + } } if (err == 0) err = PyFile_WriteObject(v, x, 0); @@ -1037,7 +1041,12 @@ case PRINT_ITEM: v = POP(); w = PySys_GetObject("stdout"); - if (PyFile_SoftSpace(w, 1)) + if (w == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "lost sys.stdout"); + err = -1; + } + else if (PyFile_SoftSpace(w, 1)) err = PyFile_WriteString(" ", w); if (err == 0) err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
