@@ -399,6 +399,12 @@ internal static IntPtr CreateMetaType(Type impl)
399
399
IntPtr mdefAddr = mdef ;
400
400
slotsHolder . AddDealloctor ( ( ) =>
401
401
{
402
+ IntPtr t = type ;
403
+ IntPtr tp_dict = Marshal . ReadIntPtr ( t , TypeOffset . tp_dict ) ;
404
+ if ( Runtime . PyDict_DelItemString ( tp_dict , "__instancecheck__" ) != 0 )
405
+ {
406
+ Runtime . PyErr_Print ( ) ;
407
+ }
402
408
FreeMethodDef ( mdefAddr ) ;
403
409
} ) ;
404
410
}
@@ -414,6 +420,12 @@ internal static IntPtr CreateMetaType(Type impl)
414
420
IntPtr mdefAddr = mdef ;
415
421
slotsHolder . AddDealloctor ( ( ) =>
416
422
{
423
+ IntPtr t = type ;
424
+ IntPtr tp_dict = Marshal . ReadIntPtr ( t , TypeOffset . tp_dict ) ;
425
+ if ( Runtime . PyDict_DelItemString ( tp_dict , "__subclasscheck__" ) != 0 )
426
+ {
427
+ Runtime . PyErr_Print ( ) ;
428
+ }
417
429
FreeMethodDef ( mdefAddr ) ;
418
430
} ) ;
419
431
}
@@ -521,6 +533,7 @@ internal static IntPtr AllocateTypeObject(string name)
521
533
Marshal . WriteIntPtr ( type , TypeOffset . name , temp ) ;
522
534
523
535
#if PYTHON3
536
+ Runtime . XIncref ( temp ) ;
524
537
Marshal . WriteIntPtr ( type , TypeOffset . qualname , temp ) ;
525
538
#endif
526
539
@@ -1101,6 +1114,11 @@ private static IntPtr GetDefaultSlot(int offset)
1101
1114
// tp_free of PyTypeType is point to PyObejct_GC_Del.
1102
1115
return Marshal . ReadIntPtr ( Runtime . PyTypeType , TypeOffset . tp_free ) ;
1103
1116
}
1117
+ else if ( offset == TypeOffset . tp_free )
1118
+ {
1119
+ // PyObject_GC_Del
1120
+ return Marshal . ReadIntPtr ( Runtime . PyTypeType , TypeOffset . tp_free ) ;
1121
+ }
1104
1122
else if ( offset == TypeOffset . tp_call )
1105
1123
{
1106
1124
return IntPtr . Zero ;
@@ -1110,6 +1128,16 @@ private static IntPtr GetDefaultSlot(int offset)
1110
1128
// PyType_GenericNew
1111
1129
return Marshal . ReadIntPtr ( Runtime . PySuper_Type , TypeOffset . tp_new ) ;
1112
1130
}
1131
+ else if ( offset == TypeOffset . tp_getattro )
1132
+ {
1133
+ // PyObject_GenericGetAttr
1134
+ return Marshal . ReadIntPtr ( Runtime . PyBaseObjectType , TypeOffset . tp_getattro ) ;
1135
+ }
1136
+ else if ( offset == TypeOffset . tp_setattro )
1137
+ {
1138
+ // PyObject_GenericSetAttr
1139
+ return Marshal . ReadIntPtr ( Runtime . PyBaseObjectType , TypeOffset . tp_setattro ) ;
1140
+ }
1113
1141
1114
1142
return Marshal . ReadIntPtr ( Runtime . PyTypeType , offset ) ;
1115
1143
}
0 commit comments