comparison Python/sysmodule.c @ 15812:a563eec46c1a legacy-trunk

stdout is sometimes a macro; use "outf" instead. Submitted by: Mark Favas <m.favas@per.dem.csiro.au>
author Greg Stein <gstein@lyra.org>
date Thu, 11 Jan 2001 09:27:34 +0000
parents 1a00d21910c8
children d41f9b0a40ca
comparison
equal deleted inserted replaced
15811:1a00d21910c8 15812:a563eec46c1a
68 } 68 }
69 69
70 static PyObject * 70 static PyObject *
71 sys_displayhook(PyObject *self, PyObject *args) 71 sys_displayhook(PyObject *self, PyObject *args)
72 { 72 {
73 PyObject *o, *stdout; 73 PyObject *o, *outf;
74 PyInterpreterState *interp = PyThreadState_Get()->interp; 74 PyInterpreterState *interp = PyThreadState_Get()->interp;
75 PyObject *modules = interp->modules; 75 PyObject *modules = interp->modules;
76 PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); 76 PyObject *builtins = PyDict_GetItemString(modules, "__builtin__");
77 77
78 /* parse arguments */ 78 /* parse arguments */
88 } 88 }
89 if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) 89 if (PyObject_SetAttrString(builtins, "_", Py_None) != 0)
90 return NULL; 90 return NULL;
91 if (Py_FlushLine() != 0) 91 if (Py_FlushLine() != 0)
92 return NULL; 92 return NULL;
93 stdout = PySys_GetObject("stdout"); 93 outf = PySys_GetObject("stdout");
94 if (stdout == NULL) { 94 if (outf == NULL) {
95 PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); 95 PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
96 return NULL; 96 return NULL;
97 } 97 }
98 if (PyFile_WriteObject(o, stdout, 0) != 0) 98 if (PyFile_WriteObject(o, outf, 0) != 0)
99 return NULL; 99 return NULL;
100 PyFile_SoftSpace(stdout, 1); 100 PyFile_SoftSpace(outf, 1);
101 if (Py_FlushLine() != 0) 101 if (Py_FlushLine() != 0)
102 return NULL; 102 return NULL;
103 if (PyObject_SetAttrString(builtins, "_", o) != 0) 103 if (PyObject_SetAttrString(builtins, "_", o) != 0)
104 return NULL; 104 return NULL;
105 Py_INCREF(Py_None); 105 Py_INCREF(Py_None);