Skip to content

Commit 02778b8

Browse files
committed
Fix bug in __call__ implementation when calling a base class method on
python subclass of a managed type.
1 parent cfc3ef3 commit 02778b8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pythonnet/src/runtime/methodbinding.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,17 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) {
161161
{
162162
string baseMethodName = "_" + baseType.type.Name + "__" + self.m.name;
163163
IntPtr baseMethod = Runtime.PyObject_GetAttrString(target, baseMethodName);
164-
if (baseMethod != null)
164+
if (baseMethod != IntPtr.Zero)
165165
{
166166
MethodBinding baseSelf = GetManagedObject(baseMethod) as MethodBinding;
167167
if (baseSelf != null)
168168
self = baseSelf;
169+
Runtime.Decref(baseMethod);
170+
}
171+
else
172+
{
173+
Runtime.PyErr_Clear();
169174
}
170-
Runtime.Decref(baseMethod);
171175
}
172176
}
173177
}

0 commit comments

Comments
 (0)