]> granicus.if.org Git - python/commitdiff
eval_code2(): Guido provides this patch for his suggested elaboration
authorBarry Warsaw <barry@python.org>
Tue, 29 Aug 2000 04:56:13 +0000 (04:56 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 29 Aug 2000 04:56:13 +0000 (04:56 +0000)
of extended print.  If the file object being printed to is None, then
sys.stdout is used.

Python/ceval.c

index 53a5177520cdc009dac58babd6b3337af68405fc..4b40197c4e3b321951d0346203d9445023fcfab2 100644 (file)
@@ -1230,7 +1230,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
 
                case PRINT_ITEM:
                        v = POP();
-                       if (stream == NULL) {
+                       if (stream == NULL || stream == Py_None) {
                                w = PySys_GetObject("stdout");
                                if (w == NULL) {
                                        PyErr_SetString(PyExc_RuntimeError,
@@ -1263,7 +1263,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
                        /* fall through to PRINT_NEWLINE */
 
                case PRINT_NEWLINE:
-                       if (stream == NULL) {
+                       if (stream == NULL || stream == Py_None) {
                                w = PySys_GetObject("stdout");
                                if (w == NULL)
                                        PyErr_SetString(PyExc_RuntimeError,