~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ec.c, catacomb/__init__.py: Return tail from `parse'; provide `fromstring'.
[catacomb-python]
/
rand.c
diff --git
a/rand.c
b/rand.c
index
675bf70
..
22a0b3c
100644
(file)
--- a/
rand.c
+++ b/
rand.c
@@
-102,16
+102,14
@@
static PyObject *grmeth_range(PyObject *me, PyObject *arg)
if (!PyArg_ParseTuple(arg, "O:range", &m)) return (0);
if (grand_check(me)) return (0);
if (PyInt_Check(m)) {
if (!PyArg_ParseTuple(arg, "O:range", &m)) return (0);
if (grand_check(me)) return (0);
if (PyInt_Check(m)) {
- long mm = PyInt_A
S_LONG
(m);
- if (mm
<= 0)
-
goto notpos;
- if (mm <= 0xffffffff)
+ long mm = PyInt_A
sLong
(m);
+ if (mm
== -1 && PyErr_Occurred()) PyErr_Clear();
+
else if (mm <= 0)
goto notpos;
+
else
if (mm <= 0xffffffff)
return (PyInt_FromLong(grand_range(GRAND_R(me), mm)));
}
return (PyInt_FromLong(grand_range(GRAND_R(me), mm)));
}
- if ((x = getmp(m)) == 0)
- goto end;
- if (!MP_POSP(x))
- goto notpos;
+ if ((x = getmp(m)) == 0) goto end;
+ if (!MP_POSP(x)) goto notpos;
y = mprand_range(MP_NEW, x, GRAND_R(me), 0);
MP_DROP(x);
return (mp_pywrap(y));
y = mprand_range(MP_NEW, x, GRAND_R(me), 0);
MP_DROP(x);
return (mp_pywrap(y));