11using System ;
22using System . Collections ;
3- using System . Reflection ;
4- using System . Security ;
53using System . Runtime . InteropServices ;
64
75namespace Python . Runtime
@@ -27,7 +25,7 @@ internal ClassBase(Type tp)
2725
2826 internal virtual bool CanSubclass ( )
2927 {
30- return ( ! this . type . IsEnum ) ;
28+ return ! type . IsEnum ;
3129 }
3230
3331 /// <summary>
@@ -49,12 +47,12 @@ public virtual IntPtr type_subscript(IntPtr idx)
4947 return Exceptions . RaiseTypeError ( "type(s) expected" ) ;
5048 }
5149
52- Type target = GenericUtil . GenericForType ( this . type , types . Length ) ;
50+ Type target = GenericUtil . GenericForType ( type , types . Length ) ;
5351
5452 if ( target != null )
5553 {
5654 Type t = target . MakeGenericType ( types ) ;
57- ManagedType c = ( ManagedType ) ClassManager . GetClass ( t ) ;
55+ ManagedType c = ClassManager . GetClass ( t ) ;
5856 Runtime . XIncref ( c . pyHandle ) ;
5957 return c . pyHandle ;
6058 }
@@ -115,10 +113,15 @@ public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op)
115113 co1 = GetManagedObject ( ob ) as CLRObject ;
116114 co2 = GetManagedObject ( other ) as CLRObject ;
117115 if ( co1 == null || co2 == null )
116+ {
118117 return Exceptions . RaiseTypeError ( "Cannot get managed object" ) ;
118+ }
119119 var co1Comp = co1 . inst as IComparable ;
120120 if ( co1Comp == null )
121- return Exceptions . RaiseTypeError ( "Cannot convert object of type " + co1 . GetType ( ) + " to IComparable" ) ;
121+ {
122+ Type co1Type = co1 . GetType ( ) ;
123+ return Exceptions . RaiseTypeError ( $ "Cannot convert object of type { co1Type } to IComparable") ;
124+ }
122125 try
123126 {
124127 int cmp = co1Comp . CompareTo ( co2 . inst ) ;
0 commit comments