Fix Unicode encode_wstr_utf8() (#127420)

Raise RuntimeError instead of RuntimeWarning.
This commit is contained in:
Victor Stinner 2024-12-02 11:14:47 +01:00 committed by GitHub
parent a8dd821d5b
commit bf21e2160d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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) {