@@ -117,7 +117,7 @@ internal static void SaveRuntimeData(RuntimeDataStorage storage)
117117 // Python object's dictionary tool; thus raising an AttributeError
118118 // instead of a TypeError.
119119 // Classes are re-initialized on in RestoreRuntimeData.
120- var dict = new BorrowedReference ( Marshal . ReadIntPtr ( cls . Value . tpHandle , TypeOffset . tp_dict ) ) ;
120+ using var dict = Runtime . PyObject_GenericGetDict ( cls . Value . TypeReference ) ;
121121 foreach ( var member in cls . Value . dotNetMembers )
122122 {
123123 // No need to decref the member, the ClassBase instance does
@@ -135,7 +135,7 @@ internal static void SaveRuntimeData(RuntimeDataStorage storage)
135135 }
136136 }
137137 // We modified the Type object, notify it we did.
138- Runtime . PyType_Modified ( cls . Value . tpHandle ) ;
138+ Runtime . PyType_Modified ( cls . Value . TypeReference ) ;
139139 }
140140 }
141141
@@ -155,7 +155,7 @@ internal static Dictionary<ManagedType, InterDomainContext> RestoreRuntimeData(R
155155 // re-init the class
156156 InitClassBase ( pair . Key . Value , pair . Value ) ;
157157 // We modified the Type object, notify it we did.
158- Runtime . PyType_Modified ( pair . Value . tpHandle ) ;
158+ Runtime . PyType_Modified ( pair . Value . TypeReference ) ;
159159 var context = contexts [ pair . Value . pyHandle ] ;
160160 pair . Value . Load ( context ) ;
161161 loadedObjs . Add ( pair . Value , context ) ;
@@ -266,10 +266,10 @@ private static void InitClassBase(Type type, ClassBase impl)
266266 // point to the managed methods providing the implementation.
267267
268268
269- IntPtr tp = TypeManager . GetTypeHandle ( impl , type ) ;
269+ var pyType = TypeManager . GetType ( impl , type ) ;
270270
271271 // Finally, initialize the class __dict__ and return the object.
272- var dict = new BorrowedReference ( Marshal . ReadIntPtr ( tp , TypeOffset . tp_dict ) ) ;
272+ using var dict = Runtime . PyObject_GenericGetDict ( pyType . Reference ) ;
273273
274274
275275 if ( impl . dotNetMembers == null )
@@ -312,7 +312,7 @@ private static void InitClassBase(Type type, ClassBase impl)
312312 // Implement Overloads on the class object
313313 if ( ! CLRModule . _SuppressOverloads )
314314 {
315- var ctors = new ConstructorBinding ( type , tp , co . binder ) ;
315+ var ctors = new ConstructorBinding ( type , pyType , co . binder ) ;
316316 // ExtensionType types are untracked, so don't Incref() them.
317317 // TODO: deprecate __overloads__ soon...
318318 Runtime . PyDict_SetItem ( dict , PyIdentifier . __overloads__ , ctors . ObjectReference ) ;
@@ -332,7 +332,7 @@ private static void InitClassBase(Type type, ClassBase impl)
332332
333333 // The type has been modified after PyType_Ready has been called
334334 // Refresh the type
335- Runtime . PyType_Modified ( tp ) ;
335+ Runtime . PyType_Modified ( pyType . Reference ) ;
336336 }
337337
338338 internal static bool ShouldBindMethod ( MethodBase mb )
0 commit comments