bpo-33217: Raise TypeError for non-Enum lookups in Enums (GH-6651)

* bpo-33217: Raise TypeError for non-Enum lookups in Enums
diff --git a/Lib/enum.py b/Lib/enum.py
index 04d8ec1..9d1aef3 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -303,6 +303,10 @@
         return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
 
     def __contains__(cls, member):
+        if not isinstance(member, Enum):
+            raise TypeError(
+                "unsupported operand type(s) for 'in': '%s' and '%s'" % (
+                    type(member).__qualname__, cls.__class__.__qualname__))
         return isinstance(member, cls) and member._name_ in cls._member_map_
 
     def __delattr__(cls, attr):
@@ -705,7 +709,9 @@
 
     def __contains__(self, other):
         if not isinstance(other, self.__class__):
-            return NotImplemented
+            raise TypeError(
+                "unsupported operand type(s) for 'in': '%s' and '%s'" % (
+                    type(other).__qualname__, self.__class__.__qualname__))
         return other._value_ & self._value_ == other._value_
 
     def __repr__(self):