From 548065f29e077cbc83efaf2b02bd6011f91f0ba7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 21 May 2022 06:18:00 +0530 Subject: [PATCH] Show repr of non-unicode object in ICU errors --- src/calibre/utils/icu_calibre_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/icu_calibre_utils.h b/src/calibre/utils/icu_calibre_utils.h index d80a62da97..d2e3a81e87 100644 --- a/src/calibre/utils/icu_calibre_utils.h +++ b/src/calibre/utils/icu_calibre_utils.h @@ -35,7 +35,7 @@ static UChar* python_to_icu(PyObject *obj, int32_t *osz) { int i; 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; } if(PyUnicode_READY(obj) == -1) { @@ -105,7 +105,7 @@ static UChar32* python_to_icu32(PyObject *obj, int32_t *osz) { int i; 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; } if(PyUnicode_READY(obj) == -1) {