chiark / gitweb /
Return `long' objects when `int' is requested but the value won't fit.
[catacomb-python] / group.c
diff --git a/group.c b/group.c
index 5cc40e54a364cecb0028ca35329e9afc5fb0c792..7d5b2576d7c29b092601b0cde461cbb9eb025d0a 100644 (file)
--- a/group.c
+++ b/group.c
@@ -695,8 +695,8 @@ static PyObject *ge_pyint(PyObject *me)
 
   if ((x = G_TOINT(GE_G(me), MP_NEW, GE_X(me))) == 0)
     TYERR("can't convert to integer");
-  if (mp_tolong_checked(x, &l)) goto end;
-  rc = PyInt_FromLong(l);
+  if (!mp_tolong_checked(x, &l, 0)) rc = PyInt_FromLong(l);
+  else rc = mp_topylong(x);
 end:
   mp_drop(x);
   return (rc);