Skip to content

Commit 015795a

Browse files
committed
address some review comments
1 parent 47b58c9 commit 015795a

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

Python/structmember.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,16 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
325325
oldv = *(PyObject **)addr;
326326
FT_ATOMIC_STORE_PTR_RELEASE(*(PyObject **)addr, Py_XNewRef(v));
327327
Py_END_CRITICAL_SECTION();
328-
Py_XDECREF(oldv);
329328
if (v == NULL && oldv == NULL && l->type == Py_T_OBJECT_EX) {
330-
// Pseudo-non-existing attribute is deleted: raise AttributeError.
331-
// The attribute doesn't exist to Python, but CPython knows that it
332-
// could have existed because it was declared in __slots__.
333-
// _Py_T_OBJECT does not raise an exception here, and
334-
// PyMember_GetOne will return Py_None instead of NULL.
329+
// Raise an exception when attempting to delete an already deleted
330+
// attribute.
331+
// Differently from Py_T_OBJECT_EX, _Py_T_OBJECT does not raise an
332+
// exception here (PyMember_GetOne will return Py_None instead of
333+
// NULL).
335334
PyErr_SetString(PyExc_AttributeError, l->name);
336335
return -1;
337336
}
338-
// Other cases are already covered by the above:
339-
// oldv == NULL && v != NULL: pseudo-non-existing attribute is set, ok
340-
// oldv != NULL && v == NULL: existing attribute is deleted, ok
341-
// oldv != NULL && v != NULL: existing attribute is set, ok
337+
Py_XDECREF(oldv);
342338
break;
343339
case Py_T_CHAR: {
344340
const char *string;

0 commit comments

Comments
 (0)