Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
vstinner authored and miss-islington committed Oct 14, 2026
commit 0f3f9bc522d9a9746b33625f84576f0893fe412b
12 changes: 6 additions & 6 deletions Modules/_testlimitedcapi/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;

Expand Down
Loading