Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Reorder setattr/delattr paths
  • Loading branch information
skirpichev committed Aug 23, 2023
commit 68eefbdcf994f8a5c5bc0c1e09ce873b407ee957
23 changes: 11 additions & 12 deletions Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,30 +869,29 @@ _Py_module_getattro(PyModuleObject *m, PyObject *name)
static int
module_setattro(PyModuleObject *mod, PyObject *name, PyObject *value)
{
PyObject *res;
assert(mod->md_dict != NULL);
if (value == NULL) {
PyObject *delattr;
if (PyDict_GetItemRef(mod->md_dict, &_Py_ID(__delattr__), &delattr) < 0) {
if (value) {
PyObject *setattr;
if (PyDict_GetItemRef(mod->md_dict, &_Py_ID(__setattr__), &setattr) < 0) {
return -1;
}
if (delattr) {
res = PyObject_CallFunctionObjArgs(delattr, name, NULL);
Py_DECREF(delattr);
if (setattr) {
PyObject *res = PyObject_CallFunctionObjArgs(setattr, name, value, NULL);
Py_DECREF(setattr);
if (res == NULL) {
return -1;
}
Comment thread
skirpichev marked this conversation as resolved.
Py_DECREF(res);
return 0;
}
} else {
Comment thread
skirpichev marked this conversation as resolved.
Outdated
PyObject *setattr;
if (PyDict_GetItemRef(mod->md_dict, &_Py_ID(__setattr__), &setattr) < 0) {
PyObject *delattr;
if (PyDict_GetItemRef(mod->md_dict, &_Py_ID(__delattr__), &delattr) < 0) {
return -1;
}
if (setattr) {
res = PyObject_CallFunctionObjArgs(setattr, name, value, NULL);
Py_DECREF(setattr);
if (delattr) {
PyObject *res = PyObject_CallFunctionObjArgs(delattr, name, NULL);
Py_DECREF(delattr);
if (res == NULL) {
return -1;
}
Expand Down