Skip to content

Commit ae62f01

Browse files
ZackerySpytzserhiy-storchaka
authored andcommitted
bpo-34910: Ensure that PyObject_Print() always returns -1 on error. (GH-9733)
1 parent cd45385 commit ae62f01

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ensure that :c:func:`PyObject_Print` always returns ``-1`` on error. Patch
2+
by Zackery Spytz.

Objects/object.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,9 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
375375
else if (PyUnicode_Check(s)) {
376376
PyObject *t;
377377
t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace");
378-
if (t == NULL)
379-
ret = 0;
378+
if (t == NULL) {
379+
ret = -1;
380+
}
380381
else {
381382
fwrite(PyBytes_AS_STRING(t), 1,
382383
PyBytes_GET_SIZE(t), fp);

0 commit comments

Comments
 (0)