From 960b91351d070f0a560253d0a26a7749dff9c258 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 14 Oct 2026 14:52:44 +0200 Subject: [PATCH] Set default arguments in _testlimitedcapi/unicode.c (GH-159380) Some optional arguments had no default value leading to undefined behavior if they were omitted. (cherry picked from commit e96d943d7df89e1f082e890ea668da95c77c177a) Co-authored-by: Victor Stinner --- Modules/_testlimitedcapi/unicode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/_testlimitedcapi/unicode.c b/Modules/_testlimitedcapi/unicode.c index c7a23d5d1cbd71..c3a252be404062 100644 --- a/Modules/_testlimitedcapi/unicode.c +++ b/Modules/_testlimitedcapi/unicode.c @@ -944,7 +944,7 @@ unicode_encodecodepage(PyObject *self, PyObject *args) { int code_page; PyObject *unicode; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "iO|z", &code_page, &unicode, &errors)) return NULL; @@ -961,7 +961,7 @@ unicode_decodelocaleandsize(PyObject *self, PyObject *args) { const char *data; Py_ssize_t size; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors)) return NULL; @@ -975,7 +975,7 @@ unicode_decodelocale(PyObject *self, PyObject *args) { const char *data; Py_ssize_t size; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors)) return NULL; @@ -988,7 +988,7 @@ static PyObject * unicode_encodelocale(PyObject *self, PyObject *args) { PyObject *unicode; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z", &unicode, &errors)) return NULL; @@ -1282,7 +1282,7 @@ unicode_comparewithasciistring(PyObject *self, PyObject *args) { PyObject *left; const char *right = NULL; - Py_ssize_t right_len; + Py_ssize_t right_len = 0; int result; if (!PyArg_ParseTuple(args, "O|y#", &left, &right, &right_len)) @@ -1321,7 +1321,7 @@ unicode_equaltoutf8andsize(PyObject *self, PyObject *args) { PyObject *left; const char *right = NULL; - Py_ssize_t right_len; + Py_ssize_t right_len = 0; Py_ssize_t size = -100; int result;