From 4a42cebf6dd769e2fa4e234a9e91093b3ad1cb63 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sat, 12 Jun 2021 10:23:02 +0100 Subject: bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606) Change the behaviour of `math.pow(0.0, -math.inf)` and `math.pow(-0.0, -math.inf)` to return positive infinity instead of raising `ValueError`. This makes `math.pow` consistent with the built-in `pow` (and the `**` operator) for this particular special case, and brings the `math.pow` special-case handling into compliance with IEEE 754. --- Modules/mathmodule.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'Modules') diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index b3429c5653..bd97b03205 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2810,8 +2810,6 @@ math_pow_impl(PyObject *module, double x, double y) r = y; else if (y < 0. && fabs(x) < 1.0) { r = -y; /* result is +inf */ - if (x == 0.) /* 0**-inf: divide-by-zero */ - errno = EDOM; } else r = 0.; -- cgit v1.2.1