diff options
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 12d4905..b8c3772 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -610,6 +610,13 @@ float_int(PyObject *v) long aslong; /* (long)wholepart */ (void)modf(x, &wholepart); +#ifdef RISCOS + /* conversion from floating to integral type would raise exception */ + if (wholepart>LONG_MAX || wholepart<LONG_MIN) { + PyErr_SetString(PyExc_OverflowError, "float too large to convert"); + return NULL; + } +#endif /* doubles may have more bits than longs, or vice versa; and casting to long may yield gibberish in either case. What really matters is whether converting back to double again reproduces what we |