Show repr of non-unicode object in ICU errors

This commit is contained in:
Kovid Goyal 2022-05-21 06:18:00 +05:30
parent 1f7a80cdd3
commit 548065f29e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -35,7 +35,7 @@ static UChar* python_to_icu(PyObject *obj, int32_t *osz) {
int i; int i;
if (!PyUnicode_CheckExact(obj)) { if (!PyUnicode_CheckExact(obj)) {
PyErr_SetString(PyExc_TypeError, "Not a unicode string"); PyErr_Format(PyExc_TypeError, "%R is not a unicode string", obj);
return NULL; return NULL;
} }
if(PyUnicode_READY(obj) == -1) { if(PyUnicode_READY(obj) == -1) {
@ -105,7 +105,7 @@ static UChar32* python_to_icu32(PyObject *obj, int32_t *osz) {
int i; int i;
if (!PyUnicode_CheckExact(obj)) { if (!PyUnicode_CheckExact(obj)) {
PyErr_SetString(PyExc_TypeError, "Not a unicode string"); PyErr_Format(PyExc_TypeError, "%R is not a unicode string", obj);
return NULL; return NULL;
} }
if(PyUnicode_READY(obj) == -1) { if(PyUnicode_READY(obj) == -1) {