Commit be27026c authored by Guido van Rossum's avatar Guido van Rossum

Py_FlushLine and PyFile_WriteString now return error indicators

instead of calling PyErr_Clear().  Add checking of those errors.
parent 27a60b14
......@@ -930,11 +930,18 @@ eval_code2(co, globals, locals,
(err = PyDict_SetItemString(
f->f_builtins, "_", v)) == 0 &&
!Py_SuppressPrintingFlag) {
Py_FlushLine();
err = Py_FlushLine();
if (err == NULL) {
x = PySys_GetObject("stdout");
if (x == NULL)
err = -1;
}
if (err == 0)
err = PyFile_WriteObject(v, x, 0);
if (err == 0) {
PyFile_SoftSpace(x, 1);
Py_FlushLine();
err = Py_FlushLine();
}
}
Py_DECREF(v);
break;
......@@ -943,7 +950,8 @@ eval_code2(co, globals, locals,
v = POP();
w = PySys_GetObject("stdout");
if (PyFile_SoftSpace(w, 1))
PyFile_WriteString(" ", w);
err = PyFile_WriteString(" ", w);
if (err == 0)
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
if (err == 0 && PyString_Check(v)) {
/* XXX move into writeobject() ? */
......@@ -964,7 +972,8 @@ eval_code2(co, globals, locals,
PyErr_SetString(PyExc_RuntimeError,
"lost sys.stdout");
else {
PyFile_WriteString("\n", x);
err = PyFile_WriteString("\n", x);
if (err == 0)
PyFile_SoftSpace(x, 0);
}
break;
......@@ -2111,12 +2120,15 @@ PyEval_GetRestricted()
return current_frame == NULL ? 0 : current_frame->f_restricted;
}
void
int
Py_FlushLine()
{
PyObject *f = PySys_GetObject("stdout");
if (PyFile_SoftSpace(f, 0))
PyFile_WriteString("\n", f);
if (f == NULL)
return 0;
if (!PyFile_SoftSpace(f, 0))
return 0;
return PyFile_WriteString("\n", f);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment