From 56e1ccaf151b0d16c8ea6b97fc3b101d131f30cd Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 29 Nov 2024 16:58:57 +0100 Subject: [PATCH] Fix Unicode encode_wstr_utf8() Raise RuntimeError instead of RuntimeWarning. --- Objects/unicodeobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index ab4f07ed054385..3a31b2fc3038be 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -16154,7 +16154,7 @@ encode_wstr_utf8(wchar_t *wstr, char **str, const char *name) int res; res = _Py_EncodeUTF8Ex(wstr, str, NULL, NULL, 1, _Py_ERROR_STRICT); if (res == -2) { - PyErr_Format(PyExc_RuntimeWarning, "cannot encode %s", name); + PyErr_Format(PyExc_RuntimeError, "cannot encode %s", name); return -1; } if (res < 0) {