mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Py_FlushLine and PyFile_WriteString now return error indicators
instead of calling PyErr_Clear(). Add checking of those errors.
This commit is contained in:
parent
27a60b147c
commit
be27026c09
1 changed files with 24 additions and 12 deletions
|
@ -930,11 +930,18 @@ eval_code2(co, globals, locals,
|
||||||
(err = PyDict_SetItemString(
|
(err = PyDict_SetItemString(
|
||||||
f->f_builtins, "_", v)) == 0 &&
|
f->f_builtins, "_", v)) == 0 &&
|
||||||
!Py_SuppressPrintingFlag) {
|
!Py_SuppressPrintingFlag) {
|
||||||
Py_FlushLine();
|
err = Py_FlushLine();
|
||||||
|
if (err == NULL) {
|
||||||
x = PySys_GetObject("stdout");
|
x = PySys_GetObject("stdout");
|
||||||
|
if (x == NULL)
|
||||||
|
err = -1;
|
||||||
|
}
|
||||||
|
if (err == 0)
|
||||||
err = PyFile_WriteObject(v, x, 0);
|
err = PyFile_WriteObject(v, x, 0);
|
||||||
|
if (err == 0) {
|
||||||
PyFile_SoftSpace(x, 1);
|
PyFile_SoftSpace(x, 1);
|
||||||
Py_FlushLine();
|
err = Py_FlushLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
break;
|
break;
|
||||||
|
@ -943,7 +950,8 @@ eval_code2(co, globals, locals,
|
||||||
v = POP();
|
v = POP();
|
||||||
w = PySys_GetObject("stdout");
|
w = PySys_GetObject("stdout");
|
||||||
if (PyFile_SoftSpace(w, 1))
|
if (PyFile_SoftSpace(w, 1))
|
||||||
PyFile_WriteString(" ", w);
|
err = PyFile_WriteString(" ", w);
|
||||||
|
if (err == 0)
|
||||||
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
|
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
|
||||||
if (err == 0 && PyString_Check(v)) {
|
if (err == 0 && PyString_Check(v)) {
|
||||||
/* XXX move into writeobject() ? */
|
/* XXX move into writeobject() ? */
|
||||||
|
@ -964,7 +972,8 @@ eval_code2(co, globals, locals,
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"lost sys.stdout");
|
"lost sys.stdout");
|
||||||
else {
|
else {
|
||||||
PyFile_WriteString("\n", x);
|
err = PyFile_WriteString("\n", x);
|
||||||
|
if (err == 0)
|
||||||
PyFile_SoftSpace(x, 0);
|
PyFile_SoftSpace(x, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2111,12 +2120,15 @@ PyEval_GetRestricted()
|
||||||
return current_frame == NULL ? 0 : current_frame->f_restricted;
|
return current_frame == NULL ? 0 : current_frame->f_restricted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
Py_FlushLine()
|
Py_FlushLine()
|
||||||
{
|
{
|
||||||
PyObject *f = PySys_GetObject("stdout");
|
PyObject *f = PySys_GetObject("stdout");
|
||||||
if (PyFile_SoftSpace(f, 0))
|
if (f == NULL)
|
||||||
PyFile_WriteString("\n", f);
|
return 0;
|
||||||
|
if (!PyFile_SoftSpace(f, 0))
|
||||||
|
return 0;
|
||||||
|
return PyFile_WriteString("\n", f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue