Skip to content

Commit 1869c7c

Browse files
committed
Minor change
1 parent ea4b2b6 commit 1869c7c

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/runtime/Types/DelegateObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static NewReference tp_call(BorrowedReference ob, BorrowedReference args,
103103
/// <summary>
104104
/// Implements __cmp__ for reflected delegate types.
105105
/// </summary>
106-
public new static NewReference tp_richcompare(BorrowedReference ob, BorrowedReference other, int op)
106+
public static NewReference tp_richcompare(BorrowedReference ob, BorrowedReference other, int op)
107107
{
108108
if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
109109
{

src/runtime/Types/EnumObject.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)