From e7696baaeb137d32130b8cbf000065fd8dbc9cc6 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 05:09:46 +0300 Subject: [PATCH 01/11] gh-119613: deprecate Py_IS_NAN/INFINITY and Py_IS_FINITE --- Doc/whatsnew/3.14.rst | 4 +++- Include/pymath.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 39172ac60cf1e0..41586d053bd47a 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -103,7 +103,9 @@ Optimizations Deprecated ========== - +* Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macroses, + use instead ``isnan``, ``isinf`` and ``isfinite`` available from ```` + since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.) Removed ======= diff --git a/Include/pymath.h b/Include/pymath.h index 4c1e3d9984894b..55796e2d0d9e3c 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -27,6 +27,10 @@ #define Py_MATH_TAU 6.2831853071795864769252867665590057683943L #endif +/* Py_IS_NAN, Py_IS_INFINITY and Py_IS_FINITE are deprecated + * since CPython 3.14. + */ + // Py_IS_NAN(X) // Return 1 if float or double arg is a NaN, else 0. #define Py_IS_NAN(X) isnan(X) From dd3dec589341029a87995acaab3277401680eb04 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 06:04:39 +0300 Subject: [PATCH 02/11] Update Doc/whatsnew/3.14.rst Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 41586d053bd47a..46a49d51334979 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -103,7 +103,7 @@ Optimizations Deprecated ========== -* Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macroses, +* Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macros, use instead ``isnan``, ``isinf`` and ``isfinite`` available from ```` since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.) From cee472177870920745e8d50a7b48ce90d1bf5cc7 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 06:06:26 +0300 Subject: [PATCH 03/11] Address review: move deprecation news --- Doc/whatsnew/3.14.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 46a49d51334979..efd8de1bb43790 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -103,9 +103,7 @@ Optimizations Deprecated ========== -* Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macros, - use instead ``isnan``, ``isinf`` and ``isfinite`` available from ```` - since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.) + Removed ======= @@ -195,6 +193,10 @@ Porting to Python 3.14 Deprecated ---------- +* Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macros, + use instead ``isnan``, ``isinf`` and ``isfinite`` available from ```` + since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.) + Removed ------- From 3ecd1592d4232e362c749617e0fa0d01ef52bb7c Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 09:21:40 +0300 Subject: [PATCH 04/11] + changelog entry --- .../next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst diff --git a/Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst b/Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst new file mode 100644 index 00000000000000..fee2a99633b290 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst @@ -0,0 +1 @@ +Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macros. From b5ede50895f063d3c16d105c614b4b4ff668ea71 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 10:04:34 +0300 Subject: [PATCH 05/11] Apply suggestions from code review Co-authored-by: Erlend E. Aasland --- Doc/whatsnew/3.14.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index efd8de1bb43790..8948af54e0e3ef 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -193,8 +193,8 @@ Porting to Python 3.14 Deprecated ---------- -* Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macros, - use instead ``isnan``, ``isinf`` and ``isfinite`` available from ```` +* Deprecate :c:macro:`!Py_IS_NAN`, :c:macro:`!Py_IS_INFINITY` and :c:macro:`!Py_IS_FINITE` macros, + use instead :c:macro:`!isnan`, :c:macro:`!isinf` and :c:macro:`!isfinite` available from :file:`math.h` since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.) Removed From d4008a132108eb61e4cd3d7a0ea4097644c9663a Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 11:07:56 +0300 Subject: [PATCH 06/11] Address review: emphasise soft deprecation --- Doc/whatsnew/3.14.rst | 6 ++++-- .../C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 8948af54e0e3ef..9eaeddc5e41e6b 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -193,8 +193,10 @@ Porting to Python 3.14 Deprecated ---------- -* Deprecate :c:macro:`!Py_IS_NAN`, :c:macro:`!Py_IS_INFINITY` and :c:macro:`!Py_IS_FINITE` macros, - use instead :c:macro:`!isnan`, :c:macro:`!isinf` and :c:macro:`!isfinite` available from :file:`math.h` +* Macros :c:macro:`!Py_IS_NAN`, :c:macro:`!Py_IS_INFINITY` + and :c:macro:`!Py_IS_FINITE` are :term:`soft deprecated`, + use instead :c:macro:`!isnan`, :c:macro:`!isinf` and + :c:macro:`!isfinite` available from :file:`math.h` since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.) Removed diff --git a/Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst b/Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst index fee2a99633b290..196a4722a98c70 100644 --- a/Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst +++ b/Misc/NEWS.d/next/C API/2024-05-29-09-21-37.gh-issue-119613.J2xfrC.rst @@ -1 +1,2 @@ -Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macros. +Macros ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` +are :term:`soft deprecated`. From 38153231b9be91d1f3aa9e4426e81a2b7a9c3b12 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 11:14:53 +0300 Subject: [PATCH 07/11] Update Include/pymath.h Co-authored-by: Victor Stinner --- Include/pymath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/pymath.h b/Include/pymath.h index 55796e2d0d9e3c..38e87391ebcfbf 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -27,7 +27,7 @@ #define Py_MATH_TAU 6.2831853071795864769252867665590057683943L #endif -/* Py_IS_NAN, Py_IS_INFINITY and Py_IS_FINITE are deprecated +/* Py_IS_NAN, Py_IS_INFINITY and Py_IS_FINITE are soft deprecated * since CPython 3.14. */ From 10e1bdcefa8a9038aee73dcb6d5b3a2c52630c75 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 29 May 2024 11:45:30 +0300 Subject: [PATCH 08/11] Address review: comments in Include/pymath.h --- Include/pymath.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Include/pymath.h b/Include/pymath.h index 38e87391ebcfbf..76b20b91185c10 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -27,20 +27,19 @@ #define Py_MATH_TAU 6.2831853071795864769252867665590057683943L #endif -/* Py_IS_NAN, Py_IS_INFINITY and Py_IS_FINITE are soft deprecated - * since CPython 3.14. - */ - // Py_IS_NAN(X) // Return 1 if float or double arg is a NaN, else 0. +// Soft deprecated since Python 3.14. #define Py_IS_NAN(X) isnan(X) // Py_IS_INFINITY(X) // Return 1 if float or double arg is an infinity, else 0. +// Soft deprecated since Python 3.14. #define Py_IS_INFINITY(X) isinf(X) // Py_IS_FINITE(X) // Return 1 if float or double arg is neither infinite nor NAN, else 0. +// Soft deprecated since Python 3.14. #define Py_IS_FINITE(X) isfinite(X) // Py_INFINITY: Value that evaluates to a positive double infinity. From 97da8f208cb894703305cc09c8d5d6c96c2e416f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 29 May 2024 11:45:44 +0200 Subject: [PATCH 09/11] Update Include/pymath.h Co-authored-by: Sergey B Kirpichev --- Include/pymath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/pymath.h b/Include/pymath.h index 76b20b91185c10..b54b6cb771928c 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -29,7 +29,7 @@ // Py_IS_NAN(X) // Return 1 if float or double arg is a NaN, else 0. -// Soft deprecated since Python 3.14. +// Soft deprecated since Python 3.14, use isnan() instead. #define Py_IS_NAN(X) isnan(X) // Py_IS_INFINITY(X) From a3c0b44681818fc504600bff9d7bab950d77c696 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 29 May 2024 11:45:51 +0200 Subject: [PATCH 10/11] Update Include/pymath.h Co-authored-by: Sergey B Kirpichev --- Include/pymath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/pymath.h b/Include/pymath.h index b54b6cb771928c..f72273f64c5523 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -34,7 +34,7 @@ // Py_IS_INFINITY(X) // Return 1 if float or double arg is an infinity, else 0. -// Soft deprecated since Python 3.14. +// Soft deprecated since Python 3.14, use isinf() instead. #define Py_IS_INFINITY(X) isinf(X) // Py_IS_FINITE(X) From b45447fa5a544dc214d13cf2a77679e96fbe4954 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 29 May 2024 11:45:58 +0200 Subject: [PATCH 11/11] Update Include/pymath.h Co-authored-by: Sergey B Kirpichev --- Include/pymath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/pymath.h b/Include/pymath.h index f72273f64c5523..d8f763f808d662 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -39,7 +39,7 @@ // Py_IS_FINITE(X) // Return 1 if float or double arg is neither infinite nor NAN, else 0. -// Soft deprecated since Python 3.14. +// Soft deprecated since Python 3.14, use isfinite() instead. #define Py_IS_FINITE(X) isfinite(X) // Py_INFINITY: Value that evaluates to a positive double infinity.