static PyObject *
object_getoptionalattr(PyObject *self, PyObject *args)
{
- PyObject *obj, *attr_name, *value;
+ PyObject *obj, *attr_name, *value = UNINITIALIZED_PTR;
if (!PyArg_ParseTuple(args, "OO", &obj, &attr_name)) {
return NULL;
}
static PyObject *
object_getoptionalattrstring(PyObject *self, PyObject *args)
{
- PyObject *obj, *value;
+ PyObject *obj, *value = UNINITIALIZED_PTR;
const char *attr_name;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "Oz#", &obj, &attr_name, &size)) {
static PyObject *
mapping_getoptionalitem(PyObject *self, PyObject *args)
{
- PyObject *obj, *attr_name, *value;
+ PyObject *obj, *attr_name, *value = UNINITIALIZED_PTR;
if (!PyArg_ParseTuple(args, "OO", &obj, &attr_name)) {
return NULL;
}
static PyObject *
mapping_getoptionalitemstring(PyObject *self, PyObject *args)
{
- PyObject *obj, *value;
+ PyObject *obj, *value = UNINITIALIZED_PTR;
const char *attr_name;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "Oz#", &obj, &attr_name, &size)) {
#include "parts.h"
+#include "util.h"
static Py_ssize_t
get_code_extra_index(PyInterpreterState* interp) {
}
// Check the value is initially NULL
- void *extra;
+ void *extra = UNINITIALIZED_PTR;
int res = PyUnstable_Code_GetExtra(test_func_code, code_extra_index, &extra);
if (res < 0) {
goto finally;
goto finally;
}
// Assert it was set correctly
+ extra = UNINITIALIZED_PTR;
res = PyUnstable_Code_GetExtra(test_func_code, code_extra_index, &extra);
if (res < 0) {
goto finally;
static PyObject *
dict_getitemref(PyObject *self, PyObject *args)
{
- PyObject *obj, *attr_name, *value;
+ PyObject *obj, *attr_name, *value = UNINITIALIZED_PTR;
if (!PyArg_ParseTuple(args, "OO", &obj, &attr_name)) {
return NULL;
}
static PyObject *
dict_getitemstringref(PyObject *self, PyObject *args)
{
- PyObject *obj, *value;
+ PyObject *obj, *value = UNINITIALIZED_PTR;
const char *attr_name;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "Oz#", &obj, &attr_name, &size)) {
static PyObject *
dict_next(PyObject *self, PyObject *args)
{
- PyObject *mapping, *key, *value;
+ PyObject *mapping, *key = UNINITIALIZED_PTR, *value = UNINITIALIZED_PTR;
Py_ssize_t pos;
if (!PyArg_ParseTuple(args, "On", &mapping, &pos)) {
return NULL;
if (rc != 0) {
return Py_BuildValue("inOO", rc, pos, key, value);
}
+ assert(key == UNINITIALIZED_PTR);
+ assert(value == UNINITIALIZED_PTR);
if (PyErr_Occurred()) {
return NULL;
}
PyObject *obj)
/*[clinic end generated code: output=7a5ff5f6d3cf687f input=77ec686f1f95fa38]*/
{
- PyObject *type;
- PyObject *value;
- PyObject *tb;
+ PyObject *type = UNINITIALIZED_PTR;
+ PyObject *value = UNINITIALIZED_PTR;
+ PyObject *tb = UNINITIALIZED_PTR;
PyErr_SetObject(exc, obj);
PyErr_Fetch(&type, &value, &tb);
+ assert(type != UNINITIALIZED_PTR);
+ assert(value != UNINITIALIZED_PTR);
+ assert(tb != UNINITIALIZED_PTR);
Py_XDECREF(type);
Py_XDECREF(tb);
return value;
PyObject *new_value, PyObject *new_tb)
/*[clinic end generated code: output=b55fa35dec31300e input=ea9f19e0f55fe5b3]*/
{
- PyObject *type, *value, *tb;
+ PyObject *type = UNINITIALIZED_PTR, *value = UNINITIALIZED_PTR, *tb = UNINITIALIZED_PTR;
PyErr_GetExcInfo(&type, &value, &tb);
Py_INCREF(new_type);
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))
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);
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);
}
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))
result = PyUnicode_DecodeUTF7Stateful(data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);
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))
result = PyUnicode_DecodeUTF8Stateful(data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);
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))
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))
result = PyUnicode_DecodeUTF32Stateful(data, size, errors, &byteorder, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(iNn)", byteorder, result, consumed);
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))
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))
result = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(iNn)", byteorder, result, consumed);
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))
result = PyUnicode_DecodeMBCSStateful(data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);
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))
result = PyUnicode_DecodeCodePageStateful(code_page, data, size, errors, &consumed);
if (!result) {
+ assert(consumed == UNINITIALIZED_SIZE);
return NULL;
}
return Py_BuildValue("(Nn)", result, consumed);
assert(!PyErr_Occurred()); \
return PyLong_FromSsize_t(_ret); \
} while (0)
+
+/* Marker to check that pointer value was set. */
+#define UNINITIALIZED_PTR ((void *)"uninitialized")
+/* Marker to check that Py_ssize_t value was set. */
+#define UNINITIALIZED_SIZE ((Py_ssize_t)236892191)
+/* Marker to check that integer value was set. */
+#define UNINITIALIZED_INT (63256717)
Py_DECREF(v);
}
+ k = v = UNINITIALIZED_PTR;
while (PyDict_Next(dict, &pos, &k, &v)) {
PyObject *o;
iterations++;
+ assert(k != UNINITIALIZED_PTR);
+ assert(v != UNINITIALIZED_PTR);
i = PyLong_AS_LONG(v) + 1;
o = PyLong_FromLong(i);
if (o == NULL)
return -1;
}
Py_DECREF(o);
+ k = v = UNINITIALIZED_PTR;
}
+ assert(k == UNINITIALIZED_PTR);
+ assert(v == UNINITIALIZED_PTR);
Py_DECREF(dict);
assert(Py_REFCNT(obj) == refcnt);
// test PyWeakref_GetRef(), reference is alive
- PyObject *ref = Py_True; // marker to check that value was set
+ PyObject *ref = UNINITIALIZED_PTR;
assert(PyWeakref_GetRef(weakref, &ref) == 1);
assert(ref == obj);
assert(Py_REFCNT(obj) == (refcnt + 1));
assert(PyWeakref_GET_OBJECT(weakref) == Py_None);
// test PyWeakref_GetRef(), reference is dead
- ref = Py_True;
+ ref = UNINITIALIZED_PTR;
assert(PyWeakref_GetRef(weakref, &ref) == 0);
assert(ref == NULL);
// test PyWeakref_GetRef(), invalid type
assert(!PyErr_Occurred());
- ref = Py_True;
+ ref = UNINITIALIZED_PTR;
assert(PyWeakref_GetRef(invalid_weakref, &ref) == -1);
assert(PyErr_ExceptionMatches(PyExc_TypeError));
PyErr_Clear();
PyErr_Clear();
// test PyWeakref_GetRef(NULL)
- ref = Py_True; // marker to check that value was set
+ ref = UNINITIALIZED_PTR;
assert(PyWeakref_GetRef(NULL, &ref) == -1);
assert(PyErr_ExceptionMatches(PyExc_SystemError));
assert(ref == NULL);