Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed May 22, 2024
1 parent 99f4b13 commit d496db8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2399,19 +2399,18 @@ unicode_fromformat_write_utf8(_PyUnicodeWriter *writer, const char *str,

if (width < 0) {
return unicode_decode_utf8_writer(writer, str, length,
_Py_ERROR_UNKNOWN, "replace", NULL);
_Py_ERROR_REPLACE, "replace", NULL);
}
else {
PyObject *unicode = PyUnicode_DecodeUTF8Stateful(str, length,
"replace", NULL);
if (unicode == NULL)
return -1;

int res = unicode_fromformat_write_str(writer, unicode,
width, -1, flags);
Py_DECREF(unicode);
return res;
}
PyObject *unicode = PyUnicode_DecodeUTF8Stateful(str, length,
"replace", NULL);
if (unicode == NULL)
return -1;

int res = unicode_fromformat_write_str(writer, unicode,
width, -1, flags);
Py_DECREF(unicode);
return res;
}

static int
Expand Down

0 comments on commit d496db8

Please sign in to comment.