https://github.com/python/cpython/commit/e9d9673729a87bca8e34f809fd2d3ca4096cd62f
commit: e9d9673729a87bca8e34f809fd2d3ca4096cd62f
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-10-14T13:25:11Z
summary:

[3.15] Set default arguments in _testlimitedcapi/unicode.c (GH-159380) (#159411)

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 <[email protected]>

files:
M Modules/_testlimitedcapi/unicode.c

diff --git a/Modules/_testlimitedcapi/unicode.c 
b/Modules/_testlimitedcapi/unicode.c
index 980b192fdc3cbb..9546cf3a1ec3cd 100644
--- a/Modules/_testlimitedcapi/unicode.c
+++ b/Modules/_testlimitedcapi/unicode.c
@@ -946,7 +946,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;
@@ -963,7 +963,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;
@@ -977,7 +977,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;
@@ -990,7 +990,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;
@@ -1284,7 +1284,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))
@@ -1323,7 +1323,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;
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to