Skip to content

Commit 0fdf969

Browse files
committed
Add IsTypeObject to Managed type
Addresses comment: pythonnet#958
1 parent 802a43a commit 0fdf969

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/runtime/classbase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public static void tp_dealloc(IntPtr ob)
297297
public static int tp_clear(IntPtr ob)
298298
{
299299
ManagedType self = GetManagedObject(ob);
300-
if (self.pyHandle != self.tpHandle)
300+
if (!self.IsTypeObject())
301301
{
302302
ClearObjectDict(ob);
303303
}

src/runtime/managedtype.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ internal static bool IsManagedType(IntPtr ob)
136136
return false;
137137
}
138138

139+
public bool IsTypeObject()
140+
{
141+
return pyHandle == tpHandle;
142+
}
143+
139144
internal static IDictionary<ManagedType, TrackTypes> GetManagedObjects()
140145
{
141146
return _managedObjs;

0 commit comments

Comments
 (0)