From b820d7f63132c1c6c1f301ee40be2b2729a61356 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Mon, 22 Aug 2016 12:24:46 +0100 Subject: Issue #27792: force int return type for modulo operations involving bools. --- Objects/longobject.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Objects/longobject.c') diff --git a/Objects/longobject.c b/Objects/longobject.c index 5b9bc67a48..38e707220a 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -2458,8 +2458,11 @@ long_divrem(PyLongObject *a, PyLongObject *b, *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) { -- cgit v1.2.1