From: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:24:03 +0000 (+0100) Subject: [3.13] Fix Unicode encode_wstr_utf8() (#127420) (#127505) X-Git-Tag: v3.13.1~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=943e57e1ceae074064d20faaeae2c5edc6b3e631;p=thirdparty%2FPython%2Fcpython.git [3.13] Fix Unicode encode_wstr_utf8() (#127420) (#127505) Fix Unicode encode_wstr_utf8() (#127420) Raise RuntimeError instead of RuntimeWarning. Co-authored-by: Victor Stinner --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index c69a64de062b..7ea058b9730b 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -15633,7 +15633,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 decode %s", name); + PyErr_Format(PyExc_RuntimeError, "cannot encode %s", name); return -1; } if (res < 0) {