Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Style nitpicks
  • Loading branch information
encukou committed Apr 27, 2023
commit ea9e9acee1f6eb10c5b798ab883cc0a4b269df39
12 changes: 6 additions & 6 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3409,8 +3409,9 @@ obj_extra_data_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
size_t extra_size = sizeof(PyObject *);
PyObject *obj = PyUnstable_Object_GC_NewWithExtraData(type, extra_size);
if (obj == NULL)
if (obj == NULL) {
return PyErr_NoMemory();
}
memset(obj, '\0', type->tp_basicsize + extra_size);
PyObject_Init(obj, type);
PyObject_GC_Track(obj);
Expand All @@ -3428,10 +3429,10 @@ obj_extra_data_get(PyObject *self, void *Py_UNUSED(ignored))
{
PyObject **extra_storage = obj_extra_data_get_extra_storage(self);
PyObject *value = *extra_storage;
if (!value)
if (!value) {
Py_RETURN_NONE;
Py_INCREF(value);
return value;
}
return Py_NewRef(value);
}

static int
Expand All @@ -3440,8 +3441,7 @@ obj_extra_data_set(PyObject *self, PyObject *newval, void *Py_UNUSED(ignored))
PyObject **extra_storage = obj_extra_data_get_extra_storage(self);
Py_CLEAR(*extra_storage);
if (newval) {
Py_INCREF(newval);
*extra_storage = newval;
*extra_storage = Py_NewRef(newval);
}
return 0;
}
Expand Down