summaryrefslogtreecommitdiff
path: root/Objects/object.c
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-10-06 00:44:25 -0600
committerSerhiy Storchaka <storchaka@gmail.com>2018-10-06 09:44:25 +0300
commitae62f015240c9162773341a9922794e6b960779d (patch)
tree24bfc29c50a3f0cdf9f98b14a58c29f6d19b5c43 /Objects/object.c
parentcd45385ffad8910293e5659cfe7ab036e70613b7 (diff)
downloadcpython-git-ae62f015240c9162773341a9922794e6b960779d.tar.gz
bpo-34910: Ensure that PyObject_Print() always returns -1 on error. (GH-9733)
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 607f047d14..ab1baa70d4 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -375,8 +375,9 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
else if (PyUnicode_Check(s)) {
PyObject *t;
t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace");
- if (t == NULL)
- ret = 0;
+ if (t == NULL) {
+ ret = -1;
+ }
else {
fwrite(PyBytes_AS_STRING(t), 1,
PyBytes_GET_SIZE(t), fp);