Skip to content

Commit 1e25d84

Browse files
committed
use PyObject_GetAttr & ignore exceptions
1 parent c4dec10 commit 1e25d84

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

Objects/descrobject.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ classmethod_get(PyObject *self, PyObject *obj, PyObject *type)
130130
if (descr->d_method->ml_flags & METH_METHOD) {
131131
cls = descr->d_common.d_type;
132132
}
133-
PyObject *mod;
134-
PyObject_GetOptionalAttr((PyObject*)type, &_Py_ID(__module__), &mod);
133+
PyObject *mod = PyObject_GetAttr((PyObject*)type, &_Py_ID(__module__));
135134
PyErr_Clear();
136135
PyObject *result = PyCMethod_New(descr->d_method, type, mod, cls);
137136
Py_XDECREF(mod);

Objects/typeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6653,8 +6653,8 @@ type_add_method(PyTypeObject *type, PyMethodDef *meth)
66536653
descr = PyDescr_NewClassMethod(type, meth);
66546654
}
66556655
else if (meth->ml_flags & METH_STATIC) {
6656-
PyObject *mod;
6657-
PyObject_GetOptionalAttr((PyObject*)type, &_Py_ID(__module__), &mod);
6656+
PyObject *mod = PyObject_GetAttr((PyObject*)type, &_Py_ID(__module__));
6657+
PyErr_Clear();
66586658
PyObject *cfunc = PyCFunction_NewEx(meth, (PyObject*)type, mod);
66596659
Py_XDECREF(mod);
66606660
if (cfunc == NULL) {

0 commit comments

Comments
 (0)