@@ -25,7 +25,7 @@ internal class MethodObject : ExtensionType
2525 internal bool is_static = false ;
2626
2727 internal PyString ? doc ;
28- internal Type type ;
28+ internal MaybeType type ;
2929
3030 public MethodObject ( Type type , string name , MethodInfo [ ] info , bool allow_threads = MethodBinder . DefaultAllowThreads )
3131 {
@@ -157,6 +157,11 @@ public static NewReference tp_descr_get(BorrowedReference ds, BorrowedReference
157157 {
158158 var self = ( MethodObject ) GetManagedObject ( ds ) ! ;
159159
160+ if ( ! self . type . Valid )
161+ {
162+ return Exceptions . RaiseTypeError ( self . type . DeletedMessage ) ;
163+ }
164+
160165 // If the method is accessed through its type (rather than via
161166 // an instance) we return an 'unbound' MethodBinding that will
162167 // cached for future accesses through the type.
@@ -178,11 +183,11 @@ public static NewReference tp_descr_get(BorrowedReference ds, BorrowedReference
178183 // In which case create a MethodBinding bound to the base class.
179184 var obj = GetManagedObject ( ob ) as CLRObject ;
180185 if ( obj != null
181- && obj . inst . GetType ( ) != self . type
186+ && obj . inst . GetType ( ) != self . type . Value
182187 && obj . inst is IPythonDerivedType
183- && self . type . IsInstanceOfType ( obj . inst ) )
188+ && self . type . Value . IsInstanceOfType ( obj . inst ) )
184189 {
185- var basecls = ClassManager . GetClass ( self . type ) ;
190+ var basecls = ClassManager . GetClass ( self . type . Value ) ;
186191 return new MethodBinding ( self , new PyObject ( ob ) , basecls ) . Alloc ( ) ;
187192 }
188193
0 commit comments