Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,10 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
s = PyObject_Str(op);
else
s = PyObject_Repr(op);
if (s == NULL)
if (s == NULL) {
ret = -1;
else if (PyBytes_Check(s)) {
fwrite(PyBytes_AS_STRING(s), 1,
PyBytes_GET_SIZE(s), fp);
}
else if (PyUnicode_Check(s)) {
else {
PyObject *t;
Comment thread
MonadChains marked this conversation as resolved.
Resolved
t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace");
Comment thread
encukou marked this conversation as resolved.
Resolved
if (t == NULL) {
Expand All @@ -300,12 +297,6 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
Py_DECREF(t);
}
}
else {
PyErr_Format(PyExc_TypeError,
"str() or repr() returned '%.100s'",
Py_TYPE(s)->tp_name);
ret = -1;
}
Py_XDECREF(s);
Comment thread
MonadChains marked this conversation as resolved.
Resolved
}
}
Expand Down