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
Next Next commit
clean up PyObject_Print
  • Loading branch information
MonadChains committed Oct 18, 2022
commit db0181e4044f9f6828fbff94895df9c2505e6fcb
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.
Outdated
t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace");
Comment thread
encukou marked this conversation as resolved.
Outdated
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.
Outdated
}
}
Expand Down