]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Fix Unicode encode_wstr_utf8() (#127420) (#127504)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Mon, 2 Dec 2024 12:24:26 +0000 (13:24 +0100)
committerGitHub <noreply@github.com>
Mon, 2 Dec 2024 12:24:26 +0000 (13:24 +0100)
Fix Unicode encode_wstr_utf8() (#127420)

Raise RuntimeError instead of RuntimeWarning.

Co-authored-by: Victor Stinner <vstinner@python.org>
Objects/unicodeobject.c

index 5f3dd26ad7b762de7d2abcdf92594769e20a54b5..ba11351f003007e0044ce36207244e797a20e0b3 100644 (file)
@@ -15446,7 +15446,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) {