@@ -1124,25 +1124,24 @@ _PyObject_NextNotImplemented(PyObject *self)
1124
1124
int
1125
1125
_PyObject_GetMethod (PyObject * obj , PyObject * name , PyObject * * method )
1126
1126
{
1127
- PyTypeObject * tp = Py_TYPE (obj );
1128
- PyObject * descr ;
1129
- descrgetfunc f = NULL ;
1130
- PyObject * * dictptr , * dict ;
1131
- PyObject * attr ;
1132
1127
int meth_found = 0 ;
1133
1128
1134
1129
assert (* method == NULL );
1135
1130
1136
- if (Py_TYPE (obj )-> tp_getattro != PyObject_GenericGetAttr
1137
- || !PyUnicode_Check (name )) {
1138
- * method = PyObject_GetAttr (obj , name );
1139
- return 0 ;
1131
+ PyTypeObject * tp = Py_TYPE (obj );
1132
+ if (!_PyType_IsReady (tp )) {
1133
+ if (PyType_Ready (tp ) < 0 ) {
1134
+ return 0 ;
1135
+ }
1140
1136
}
1141
1137
1142
- if (tp -> tp_dict == NULL && PyType_Ready (tp ) < 0 )
1138
+ if (tp -> tp_getattro != PyObject_GenericGetAttr || !PyUnicode_Check (name )) {
1139
+ * method = PyObject_GetAttr (obj , name );
1143
1140
return 0 ;
1141
+ }
1144
1142
1145
- descr = _PyType_Lookup (tp , name );
1143
+ PyObject * descr = _PyType_Lookup (tp , name );
1144
+ descrgetfunc f = NULL ;
1146
1145
if (descr != NULL ) {
1147
1146
Py_INCREF (descr );
1148
1147
if (_PyType_HasFeature (Py_TYPE (descr ), Py_TPFLAGS_METHOD_DESCRIPTOR )) {
@@ -1157,23 +1156,22 @@ _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method)
1157
1156
}
1158
1157
}
1159
1158
1160
- dictptr = _PyObject_GetDictPtr (obj );
1159
+ PyObject * * dictptr = _PyObject_GetDictPtr (obj );
1160
+ PyObject * dict ;
1161
1161
if (dictptr != NULL && (dict = * dictptr ) != NULL ) {
1162
1162
Py_INCREF (dict );
1163
- attr = PyDict_GetItemWithError (dict , name );
1163
+ PyObject * attr = PyDict_GetItemWithError (dict , name );
1164
1164
if (attr != NULL ) {
1165
- Py_INCREF (attr );
1166
- * method = attr ;
1165
+ * method = Py_NewRef (attr );
1167
1166
Py_DECREF (dict );
1168
1167
Py_XDECREF (descr );
1169
1168
return 0 ;
1170
1169
}
1171
- else {
1172
- Py_DECREF (dict );
1173
- if (PyErr_Occurred ()) {
1174
- Py_XDECREF (descr );
1175
- return 0 ;
1176
- }
1170
+ Py_DECREF (dict );
1171
+
1172
+ if (PyErr_Occurred ()) {
1173
+ Py_XDECREF (descr );
1174
+ return 0 ;
1177
1175
}
1178
1176
}
1179
1177
0 commit comments