diff Python/bltinmodule.c @ 57422:b9b683eedee1 legacy-trunk

round(0, "ermintrude") succeeded instead of producing a TypeError. Fix this.
author Mark Dickinson <dickinsm@gmail.com>
date Tue, 24 Nov 2009 10:54:58 +0000
parents 92e06cdbeab9
children 75e1b8c05f43
line wrap: on
line diff
--- a/Python/bltinmodule.c	Mon Nov 23 20:54:09 2009 +0000
+++ b/Python/bltinmodule.c	Tue Nov 24 10:54:58 2009 +0000
@@ -2130,10 +2130,6 @@
 		kwlist, &x, &o_ndigits))
 		return NULL;
 
-	/* nans, infinities and zeros round to themselves */
-	if (!Py_IS_FINITE(x) || x == 0.0)
-		return PyFloat_FromDouble(x);
-
 	if (o_ndigits == NULL) {
 		/* second argument defaults to 0 */
 		ndigits = 0;
@@ -2145,6 +2141,10 @@
 			return NULL;
 	}
 
+	/* nans, infinities and zeros round to themselves */
+	if (!Py_IS_FINITE(x) || x == 0.0)
+		return PyFloat_FromDouble(x);
+
 	/* Deal with extreme values for ndigits. For ndigits > NDIGITS_MAX, x
 	   always rounds to itself.  For ndigits < NDIGITS_MIN, x always
 	   rounds to +-0.0.  Here 0.30103 is an upper bound for log10(2). */