diff Objects/floatobject.c @ 20654:edd9d0b3c47e legacy-trunk

SF patch #474590 -- RISC OS support
author Guido van Rossum <guido@python.org>
date Wed, 24 Oct 2001 20:42:55 +0000
parents 2983b54256c7
children c7aa332a2ffa
line wrap: on
line diff
--- a/Objects/floatobject.c	Wed Oct 24 20:22:40 2001 +0000
+++ b/Objects/floatobject.c	Wed Oct 24 20:42:55 2001 +0000
@@ -610,6 +610,13 @@
 	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