]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix Unicode encode_wstr_utf8() (#127420)
authorVictor Stinner <vstinner@python.org>
Mon, 2 Dec 2024 10:14:47 +0000 (11:14 +0100)
committerGitHub <noreply@github.com>
Mon, 2 Dec 2024 10:14:47 +0000 (11:14 +0100)
Raise RuntimeError instead of RuntimeWarning.

Objects/unicodeobject.c

index 33fa21d4c7d1bfaec56595a4f7436e2466eaea49..463da06445984b5dd9d4fc6acfc29869c2d9711f 100644 (file)
@@ -16158,7 +16158,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) {