File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -387,13 +387,13 @@ static int ClearImpl(IntPtr ob, ManagedType self)
387387 bool isTypeObject = Runtime . PyObject_TYPE ( ob ) == Runtime . PyCLRMetaType ;
388388 if ( ! isTypeObject )
389389 {
390+ ClearObjectDict ( ob ) ;
391+
390392 int baseClearResult = BaseUnmanagedClear ( ob ) ;
391393 if ( baseClearResult != 0 )
392394 {
393395 return baseClearResult ;
394396 }
395-
396- ClearObjectDict ( ob ) ;
397397 }
398398 if ( self is not null ) self . tpHandle = IntPtr . Zero ;
399399 return 0 ;
Original file line number Diff line number Diff line change @@ -76,7 +76,15 @@ internal ClassDerivedObject(Type tp) : base(tp)
7676 // So we don't call PyObject_GC_Del here and instead we set the python
7777 // reference to a weak reference so that the C# object can be collected.
7878 GCHandle gc = GCHandle . Alloc ( self , GCHandleType . Weak ) ;
79- Debug . Assert ( self . TypeReference == Runtime . PyObject_TYPE ( self . ObjectReference ) ) ;
79+ #if DEBUG
80+ BorrowedReference instanceType = Runtime . PyObject_TYPE ( self . ObjectReference ) ;
81+ if ( self . TypeReference != instanceType )
82+ {
83+ using var type = new PyObject ( self . TypeReference ) ;
84+ using var instType = new PyObject ( instanceType ) ;
85+ Debug . Fail ( $ "{ type } vs { instType } ") ;
86+ }
87+ #endif
8088 SetGCHandle ( self . ObjectReference , self . TypeReference , gc ) ;
8189 self . gcHandle . Free ( ) ;
8290 self . gcHandle = gc ;
You can’t perform that action at this time.
0 commit comments