Issue #1766304: The range.__contains__ optimization should only be
applied to ints, not to instances of subclasses of int.
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 213f3dd..beff030 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -275,7 +275,7 @@
 
 static int
 range_contains(rangeobject *r, PyObject *ob) {
-    if (PyLong_Check(ob)) {
+    if (PyLong_CheckExact(ob) || PyBool_Check(ob)) {
         int cmp1, cmp2, cmp3;
         PyObject *tmp1 = NULL;
         PyObject *tmp2 = NULL;