diff options
| author | Guido van Rossum <guido@python.org> | 2001-10-24 20:42:55 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2001-10-24 20:42:55 +0000 |
| commit | e2ae77b8b8a62e648bb1864a9b36ef3280984404 (patch) | |
| tree | e03ad6f126a16529b2fb43671903e357bcb05835 /Objects/floatobject.c | |
| parent | c6ac8a78f668123ec5c2c3d5a824e7886e9a1c60 (diff) | |
| download | cpython-git-e2ae77b8b8a62e648bb1864a9b36ef3280984404.tar.gz | |
SF patch #474590 -- RISC OS support
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 12d49050ab..b8c37721db 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 |
