summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-08-04 08:53:17 (GMT)
committerGitHub <noreply@github.com>2024-08-04 08:53:17 (GMT)
commit3462a80d2cf37a63fe43f46f64a8c9823f84531d (patch)
treec6870dfefae1447a500abc164c4714f86ba17d79
parent151934a324789c58cca9c7bbd6753d735454df5a (diff)
downloadcpython-3462a80d2cf37a63fe43f46f64a8c9823f84531d.zip
cpython-3462a80d2cf37a63fe43f46f64a8c9823f84531d.tar.gz
cpython-3462a80d2cf37a63fe43f46f64a8c9823f84531d.tar.bz2
gh-121889: cmath.acosh(0+nanj) returns nan+pi/2j (#121892)
As per C11 DR#471 (adjusted resolution accepted for C17), cacosh (0 + iNaN) should return NaN ± i pi/2, not NaN + iNaN. This patch fixes cmath's code to do same.
-rw-r--r--Lib/test/mathdata/cmath_testcases.txt4
-rw-r--r--Misc/NEWS.d/next/Library/2024-07-17-09-23-03.gh-issue-121889.6se9jS.rst1
-rw-r--r--Modules/cmathmodule.c4
3 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/mathdata/cmath_testcases.txt b/Lib/test/mathdata/cmath_testcases.txt
index 0165e17..0c0d2d7 100644
--- a/Lib/test/mathdata/cmath_testcases.txt
+++ b/Lib/test/mathdata/cmath_testcases.txt
@@ -371,9 +371,9 @@ acosh1002 acosh 0.0 inf -> inf 1.5707963267948966
acosh1003 acosh 2.3 inf -> inf 1.5707963267948966
acosh1004 acosh -0.0 inf -> inf 1.5707963267948966
acosh1005 acosh -2.3 inf -> inf 1.5707963267948966
-acosh1006 acosh 0.0 nan -> nan nan
+acosh1006 acosh 0.0 nan -> nan 1.5707963267948966 ignore-imag-sign
acosh1007 acosh 2.3 nan -> nan nan
-acosh1008 acosh -0.0 nan -> nan nan
+acosh1008 acosh -0.0 nan -> nan 1.5707963267948966 ignore-imag-sign
acosh1009 acosh -2.3 nan -> nan nan
acosh1010 acosh -inf 0.0 -> inf 3.1415926535897931
acosh1011 acosh -inf 2.3 -> inf 3.1415926535897931
diff --git a/Misc/NEWS.d/next/Library/2024-07-17-09-23-03.gh-issue-121889.6se9jS.rst b/Misc/NEWS.d/next/Library/2024-07-17-09-23-03.gh-issue-121889.6se9jS.rst
new file mode 100644
index 0000000..a7babe0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-07-17-09-23-03.gh-issue-121889.6se9jS.rst
@@ -0,0 +1 @@
+Adjusts ``cmath.acosh(complex('0+nanj'))`` for recent C standards.
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index bf86a21..16ac663 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -1259,8 +1259,8 @@ cmath_exec(PyObject *mod)
INIT_SPECIAL_VALUES(acosh_special_values, {
C(INF,-P34) C(INF,-P) C(INF,-P) C(INF,P) C(INF,P) C(INF,P34) C(INF,N)
C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
- C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
- C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
+ C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,P12)
+ C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,P12)
C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
C(INF,N) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,N) C(N,N)