Issue #27792: force int return type for modulo operations involving bools.
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 5b9bc67..38e7072 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -2458,8 +2458,11 @@
         *pdiv = (PyLongObject*)PyLong_FromLong(0);
         if (*pdiv == NULL)
             return -1;
-        Py_INCREF(a);
-        *prem = (PyLongObject *) a;
+        *prem = (PyLongObject *)long_long((PyObject *)a);
+        if (*prem == NULL) {
+            Py_CLEAR(*pdiv);
+            return -1;
+        }
         return 0;
     }
     if (size_b == 1) {