Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-106016: Support customizing of module attributes access with __setattr__/__delattr__ (PEP 726) #108261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
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
m -> mod
  • Loading branch information
skirpichev committed Aug 22, 2023
commit 0740efb78f2c4aff4991bdb0f25acf46847bce5a
10 changes: 5 additions & 5 deletions 10 Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,11 +867,11 @@ _Py_module_getattro(PyModuleObject *m, PyObject *name)
}

static int
module_setattro(PyModuleObject *m, PyObject *name, PyObject *value)
module_setattro(PyModuleObject *mod, PyObject *name, PyObject *value)
{
assert(m->md_dict != NULL);
assert(mod->md_dict != NULL);
if (value == NULL) {
skirpichev marked this conversation as resolved.
Show resolved Hide resolved
PyObject *delattr = PyDict_GetItemWithError(m->md_dict, &_Py_ID(__delattr__));
PyObject *delattr = PyDict_GetItemWithError(mod->md_dict, &_Py_ID(__delattr__));
if (PyErr_Occurred()) {
return -1;
}
Expand All @@ -883,7 +883,7 @@ module_setattro(PyModuleObject *m, PyObject *name, PyObject *value)
return 0;
}
} else {
skirpichev marked this conversation as resolved.
Show resolved Hide resolved
PyObject *setattr = PyDict_GetItemWithError(m->md_dict, &_Py_ID(__setattr__));
PyObject *setattr = PyDict_GetItemWithError(mod->md_dict, &_Py_ID(__setattr__));
if (PyErr_Occurred()) {
return -1;
}
Expand All @@ -895,7 +895,7 @@ module_setattro(PyModuleObject *m, PyObject *name, PyObject *value)
return 0;
}
}
return PyObject_GenericSetAttr((PyObject *)m, name, value);
return PyObject_GenericSetAttr((PyObject *)mod, name, value);
}

static int
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.