From 4feb745ff05e6fa879bb5cebcb3d927aa37f626f Mon Sep 17 00:00:00 2001 From: eirannejad Date: Thu, 28 Mar 2024 14:31:21 -0700 Subject: [PATCH] enum object cleanups --- src/runtime/Types/EnumObject.cs | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/runtime/Types/EnumObject.cs b/src/runtime/Types/EnumObject.cs index 13318ebc0..f48ed26c8 100644 --- a/src/runtime/Types/EnumObject.cs +++ b/src/runtime/Types/EnumObject.cs @@ -131,34 +131,13 @@ public static int nb_bool(BorrowedReference ob) } } - //public static NewReference tp_str(BorrowedReference ob) - //{ - // var co = GetManagedObject(ob) as CLRObject; - // if (co == null) - // { - // return Exceptions.RaiseTypeError("invalid enum object"); - // } - // try - // { - // return Runtime.PyString_FromString(co.inst.ToString()); - // } - // catch (Exception e) - // { - // if (e.InnerException != null) - // { - // e = e.InnerException; - // } - // Exceptions.SetError(e); - // return default; - // } - //} - public new static NewReference tp_repr(BorrowedReference ob) { if (GetManagedObject(ob) is not CLRObject co) { - return Exceptions.RaiseTypeError("invalid object"); + return Exceptions.RaiseTypeError("invalid enum object"); } + if (co.inst.GetType().IsEnum) { return Runtime.PyString_FromString(GetEnumReprString((Enum)co.inst));