summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapi/unicode.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_testcapi/unicode.c')
-rw-r--r--Modules/_testcapi/unicode.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/Modules/_testcapi/unicode.c b/Modules/_testcapi/unicode.c
index f2cf9a7..232b2ad 100644
--- a/Modules/_testcapi/unicode.c
+++ b/Modules/_testcapi/unicode.c
@@ -490,7 +490,7 @@ static PyObject *
unicode_aswidecharstring(PyObject *self, PyObject *args)
{
PyObject *unicode, *result;
- Py_ssize_t size = 100;
+ Py_ssize_t size = UNINITIALIZED_SIZE;
wchar_t *buffer;
if (!PyArg_ParseTuple(args, "O", &unicode))
@@ -498,8 +498,10 @@ unicode_aswidecharstring(PyObject *self, PyObject *args)
NULLABLE(unicode);
buffer = PyUnicode_AsWideCharString(unicode, &size);
- if (buffer == NULL)
+ if (buffer == NULL) {
+ assert(size == UNINITIALIZED_SIZE);
return NULL;
+ }
result = PyUnicode_FromWideChar(buffer, size + 1);
PyMem_Free(buffer);
@@ -624,15 +626,17 @@ unicode_asutf8andsize(PyObject *self, PyObject *args)
PyObject *unicode;
Py_ssize_t buflen;
const char *s;
- Py_ssize_t size = -100;
+ Py_ssize_t size = UNINITIALIZED_SIZE;
if (!PyArg_ParseTuple(args, "On", &unicode, &buflen))
return NULL;
NULLABLE(unicode);
s = PyUnicode_AsUTF8AndSize(unicode, &size);
- if (s == NULL)
+ if (s == NULL) {
+ assert(size == UNINITIALIZED_SIZE);
return NULL;
+ }
return Py_BuildValue("(y#n)", s, buflen, size);
}
@@ -726,7 +730,7 @@ unicode_decodeutf7stateful(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- Py_ssize_t consumed;
+ Py_ssize_t consumed = UNINITIALIZED_SIZE;
PyObject *result;
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
@@ -734,6 +738,7 @@ unicode_decodeutf7stateful(PyObject *self, PyObject *args)
result = PyUnicode_DecodeUTF7Stateful(data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);
@@ -760,7 +765,7 @@ unicode_decodeutf8stateful(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- Py_ssize_t consumed = 123456789;
+ Py_ssize_t consumed = UNINITIALIZED_SIZE;
PyObject *result;
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
@@ -768,6 +773,7 @@ unicode_decodeutf8stateful(PyObject *self, PyObject *args)
result = PyUnicode_DecodeUTF8Stateful(data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);
@@ -788,7 +794,7 @@ unicode_decodeutf32(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- int byteorder;
+ int byteorder = UNINITIALIZED_INT;
PyObject *result;
if (!PyArg_ParseTuple(args, "iy#|z", &byteorder, &data, &size, &errors))
@@ -808,8 +814,8 @@ unicode_decodeutf32stateful(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- int byteorder;
- Py_ssize_t consumed;
+ int byteorder = UNINITIALIZED_INT;
+ Py_ssize_t consumed = UNINITIALIZED_SIZE;
PyObject *result;
if (!PyArg_ParseTuple(args, "iy#|z", &byteorder, &data, &size, &errors))
@@ -817,6 +823,7 @@ unicode_decodeutf32stateful(PyObject *self, PyObject *args)
result = PyUnicode_DecodeUTF32Stateful(data, size, errors, &byteorder, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(iNn)", byteorder, result, consumed);
@@ -837,7 +844,7 @@ unicode_decodeutf16(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- int byteorder = 0;
+ int byteorder = UNINITIALIZED_INT;
PyObject *result;
if (!PyArg_ParseTuple(args, "iy#|z", &byteorder, &data, &size, &errors))
@@ -857,8 +864,8 @@ unicode_decodeutf16stateful(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- int byteorder;
- Py_ssize_t consumed;
+ int byteorder = UNINITIALIZED_INT;
+ Py_ssize_t consumed = UNINITIALIZED_SIZE;
PyObject *result;
if (!PyArg_ParseTuple(args, "iy#|z", &byteorder, &data, &size, &errors))
@@ -866,6 +873,7 @@ unicode_decodeutf16stateful(PyObject *self, PyObject *args)
result = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(iNn)", byteorder, result, consumed);
@@ -1019,7 +1027,7 @@ unicode_decodembcsstateful(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- Py_ssize_t consumed;
+ Py_ssize_t consumed = UNINITIALIZED_SIZE;
PyObject *result;
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
@@ -1027,6 +1035,7 @@ unicode_decodembcsstateful(PyObject *self, PyObject *args)
result = PyUnicode_DecodeMBCSStateful(data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);
@@ -1040,7 +1049,7 @@ unicode_decodecodepagestateful(PyObject *self, PyObject *args)
const char *data;
Py_ssize_t size;
const char *errors = NULL;
- Py_ssize_t consumed;
+ Py_ssize_t consumed = UNINITIALIZED_SIZE;
PyObject *result;
if (!PyArg_ParseTuple(args, "iy#|z", &code_page, &data, &size, &errors))
@@ -1048,6 +1057,7 @@ unicode_decodecodepagestateful(PyObject *self, PyObject *args)
result = PyUnicode_DecodeCodePageStateful(code_page, data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);