Commit ae62f015 authored by Zackery Spytz's avatar Zackery Spytz Committed by Serhiy Storchaka

bpo-34910: Ensure that PyObject_Print() always returns -1 on error. (GH-9733)

parent cd45385f
Ensure that :c:func:`PyObject_Print` always returns ``-1`` on error. Patch
by Zackery Spytz.
...@@ -375,8 +375,9 @@ PyObject_Print(PyObject *op, FILE *fp, int flags) ...@@ -375,8 +375,9 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
else if (PyUnicode_Check(s)) { else if (PyUnicode_Check(s)) {
PyObject *t; PyObject *t;
t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace"); t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace");
if (t == NULL) if (t == NULL) {
ret = 0; ret = -1;
}
else { else {
fwrite(PyBytes_AS_STRING(t), 1, fwrite(PyBytes_AS_STRING(t), 1,
PyBytes_GET_SIZE(t), fp); PyBytes_GET_SIZE(t), fp);
......
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