Skip to content

Commit e9d9673

Browse files
[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 e96d943) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 3396c34 commit e9d9673

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎Modules/_testlimitedcapi/unicode.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ unicode_encodecodepage(PyObject *self, PyObject *args)
946946
{
947947
int code_page;
948948
PyObject *unicode;
949-
const char *errors;
949+
const char *errors = NULL;
950950

951951
if (!PyArg_ParseTuple(args, "iO|z", &code_page, &unicode, &errors))
952952
return NULL;
@@ -963,7 +963,7 @@ unicode_decodelocaleandsize(PyObject *self, PyObject *args)
963963
{
964964
const char *data;
965965
Py_ssize_t size;
966-
const char *errors;
966+
const char *errors = NULL;
967967

968968
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
969969
return NULL;
@@ -977,7 +977,7 @@ unicode_decodelocale(PyObject *self, PyObject *args)
977977
{
978978
const char *data;
979979
Py_ssize_t size;
980-
const char *errors;
980+
const char *errors = NULL;
981981

982982
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
983983
return NULL;
@@ -990,7 +990,7 @@ static PyObject *
990990
unicode_encodelocale(PyObject *self, PyObject *args)
991991
{
992992
PyObject *unicode;
993-
const char *errors;
993+
const char *errors = NULL;
994994

995995
if (!PyArg_ParseTuple(args, "O|z", &unicode, &errors))
996996
return NULL;
@@ -1284,7 +1284,7 @@ unicode_comparewithasciistring(PyObject *self, PyObject *args)
12841284
{
12851285
PyObject *left;
12861286
const char *right = NULL;
1287-
Py_ssize_t right_len;
1287+
Py_ssize_t right_len = 0;
12881288
int result;
12891289

12901290
if (!PyArg_ParseTuple(args, "O|y#", &left, &right, &right_len))
@@ -1323,7 +1323,7 @@ unicode_equaltoutf8andsize(PyObject *self, PyObject *args)
13231323
{
13241324
PyObject *left;
13251325
const char *right = NULL;
1326-
Py_ssize_t right_len;
1326+
Py_ssize_t right_len = 0;
13271327
Py_ssize_t size = -100;
13281328
int result;
13291329

0 commit comments

Comments
 (0)