Skip to content

Commit caa98cb

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Keep getattr allive around call
Summary: We need to keep the function alive while we call it - otherwise it can be removed from the dict and go away. 3.14 already does this because it uses GetItemRef. Reviewed By: itamaro Differential Revision: D97773747 fbshipit-source-id: 38a7a2cddd41df95a147e356ede3c364edd6c891
1 parent f94ee78 commit caa98cb

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Objects/moduleobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,9 @@ _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress)
810810
assert(m->md_dict != NULL);
811811
getattr = PyDict_GetItemWithError(m->md_dict, &_Py_ID(__getattr__));
812812
if (getattr) {
813+
Py_INCREF(getattr);
813814
PyObject *result = PyObject_CallOneArg(getattr, name);
815+
Py_DECREF(getattr);
814816
if (result == NULL && suppress == 1 && PyErr_ExceptionMatches(PyExc_AttributeError)) {
815817
// suppress AttributeError
816818
PyErr_Clear();

0 commit comments

Comments
 (0)