Skip to content

Commit

Permalink
use PyObject_GetAttr & ignore exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Feb 11, 2024
1 parent c4dec10 commit 1e25d84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Objects/descrobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ classmethod_get(PyObject *self, PyObject *obj, PyObject *type)
if (descr->d_method->ml_flags & METH_METHOD) {
cls = descr->d_common.d_type;
}
PyObject *mod;
PyObject_GetOptionalAttr((PyObject*)type, &_Py_ID(__module__), &mod);
PyObject *mod = PyObject_GetAttr((PyObject*)type, &_Py_ID(__module__));
PyErr_Clear();
PyObject *result = PyCMethod_New(descr->d_method, type, mod, cls);
Py_XDECREF(mod);
Expand Down
4 changes: 2 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -6653,8 +6653,8 @@ type_add_method(PyTypeObject *type, PyMethodDef *meth)
descr = PyDescr_NewClassMethod(type, meth);
}
else if (meth->ml_flags & METH_STATIC) {
PyObject *mod;
PyObject_GetOptionalAttr((PyObject*)type, &_Py_ID(__module__), &mod);
PyObject *mod = PyObject_GetAttr((PyObject*)type, &_Py_ID(__module__));
PyErr_Clear();
PyObject *cfunc = PyCFunction_NewEx(meth, (PyObject*)type, mod);
Py_XDECREF(mod);
if (cfunc == NULL) {
Expand Down

0 comments on commit 1e25d84

Please sign in to comment.