chiark / gitweb /
Return `long' objects when `int' is requested but the value won't fit.
[catacomb-python] / pgen.c
diff --git a/pgen.c b/pgen.c
index 24639ecff96dfa95c11b4e729597b1717522a9c8..108fa31a5168c19cac5aaa03b59c8752dc6d9da5 100644 (file)
--- a/pgen.c
+++ b/pgen.c
@@ -120,9 +120,8 @@ static PyObject *pfilt_pyint(PyObject *me)
   long l;
   PyObject *rc = 0;
 
-  if (mp_tolong_checked(PFILT_F(me)->m, &l)) goto end;
-  rc = PyInt_FromLong(l);
-end:
+  if (!mp_tolong_checked(PFILT_F(me)->m, &l, 0)) rc = PyInt_FromLong(l);
+  else rc = mp_topylong(PFILT_F(me)->m);
   return (rc);
 }