@@ -25,7 +25,7 @@ internal class MethodObject : ExtensionType
25
25
internal bool is_static = false ;
26
26
27
27
internal PyString ? doc ;
28
- internal Type type ;
28
+ internal MaybeType type ;
29
29
30
30
public MethodObject ( Type type , string name , MethodInfo [ ] info , bool allow_threads = MethodBinder . DefaultAllowThreads )
31
31
{
@@ -157,6 +157,11 @@ public static NewReference tp_descr_get(BorrowedReference ds, BorrowedReference
157
157
{
158
158
var self = ( MethodObject ) GetManagedObject ( ds ) ! ;
159
159
160
+ if ( ! self . type . Valid )
161
+ {
162
+ return Exceptions . RaiseTypeError ( self . type . DeletedMessage ) ;
163
+ }
164
+
160
165
// If the method is accessed through its type (rather than via
161
166
// an instance) we return an 'unbound' MethodBinding that will
162
167
// cached for future accesses through the type.
@@ -178,11 +183,11 @@ public static NewReference tp_descr_get(BorrowedReference ds, BorrowedReference
178
183
// In which case create a MethodBinding bound to the base class.
179
184
var obj = GetManagedObject ( ob ) as CLRObject ;
180
185
if ( obj != null
181
- && obj . inst . GetType ( ) != self . type
186
+ && obj . inst . GetType ( ) != self . type . Value
182
187
&& obj . inst is IPythonDerivedType
183
- && self . type . IsInstanceOfType ( obj . inst ) )
188
+ && self . type . Value . IsInstanceOfType ( obj . inst ) )
184
189
{
185
- var basecls = ClassManager . GetClass ( self . type ) ;
190
+ var basecls = ClassManager . GetClass ( self . type . Value ) ;
186
191
return new MethodBinding ( self , new PyObject ( ob ) , basecls ) . Alloc ( ) ;
187
192
}
188
193
0 commit comments