Whoops.  errno should only be tested when the result is finite.
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index aa38691..4fb5916 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -188,11 +188,11 @@
 					"math domain error (singularity)");
 			return NULL;
 	}
-	/* on most machines, errno should be 0 at this point */
-	if (errno && is_error(r))
+	if (Py_IS_FINITE(r) && errno && is_error(r))
+		/* this branch unnecessary on most platforms */
 		return NULL;
-	else
-        	return (*from_double_func)(r);
+
+	return (*from_double_func)(r);
 }
 
 /*