@@ -13,24 +13,18 @@ internal class EnumObject : ClassBase
1313
1414 internal EnumObject ( Type type ) : base ( type )
1515 {
16- if ( ! type . IsEnum )
17- {
18- throw new ArgumentException ( $ "{ nameof ( EnumObject ) } can only handle Enum types. Received { type . Name } ", nameof ( type ) ) ;
19- }
20-
2116 _isUnsigned = type . GetEnumUnderlyingType ( ) == typeof ( UInt64 ) ;
2217 }
2318
2419 /// <summary>
2520 /// Standard comparison implementation for instances of enum types.
2621 /// </summary>
27- public new static NewReference tp_richcompare ( BorrowedReference ob , BorrowedReference other , int op )
22+ public static NewReference tp_richcompare ( BorrowedReference ob , BorrowedReference other , int op )
2823 {
2924 object rightInstance ;
3025 CLRObject leftClrObject ;
3126 int comparisonResult ;
32- var leftType = Runtime . PyObject_TYPE ( ob ) ;
33- var leftClass = ( EnumObject ) GetManagedObject ( leftType ) ! ;
27+ EnumObject leftClass ;
3428
3529 switch ( op )
3630 {
@@ -56,6 +50,7 @@ internal EnumObject(Type type) : base(type)
5650 return new NewReference ( pyfalse ) ;
5751 }
5852
53+ leftClass = ( EnumObject ) GetManagedObject ( Runtime . PyObject_TYPE ( ob ) ) ! ;
5954 if ( rightInstance != null &&
6055 TryCompare ( leftClrObject . inst as Enum , rightInstance , leftClass . _isUnsigned , out comparisonResult ) &&
6156 comparisonResult == 0 )
@@ -81,6 +76,7 @@ internal EnumObject(Type type) : base(type)
8176 return Exceptions . RaiseTypeError ( $ "Cannot compare { leftClrObject . inst . GetType ( ) } to None") ;
8277 }
8378
79+ leftClass = ( EnumObject ) GetManagedObject ( Runtime . PyObject_TYPE ( ob ) ) ! ;
8480 try
8581 {
8682 if ( ! TryCompare ( leftClrObject . inst as Enum , rightInstance , leftClass . _isUnsigned , out comparisonResult ) )
0 commit comments