From 790ccfbfbfc2aa28dac3311d1fe8e68cc5dec09a Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 12 Nov 2025 04:57:55 +0300 Subject: [PATCH 1/2] gh-141370: document undefined behavior of Py_ABS() --- Doc/c-api/intro.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index 6e1a9dcb35543b..b89a4f30425d5f 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -119,7 +119,8 @@ complete listing. .. c:macro:: Py_ABS(x) - Return the absolute value of ``x``. + Return the absolute value of ``x``. If the result cannot be represented in + same type, the behavior is undefined. .. versionadded:: 3.3 From 0ca938cca9cb1790bf63e4cf1d99d377aba6f5de Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 12 Nov 2025 11:12:25 +0300 Subject: [PATCH 2/2] address review: a separate paragraph and example --- Doc/c-api/intro.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index b89a4f30425d5f..c76cc2f70ecccf 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -119,8 +119,11 @@ complete listing. .. c:macro:: Py_ABS(x) - Return the absolute value of ``x``. If the result cannot be represented in - same type, the behavior is undefined. + Return the absolute value of ``x``. + + If the result cannot be represented (for example, if ``x`` has + :c:macro:`!INT_MIN` value for :c:expr:`int` type), the behavior is + undefined. .. versionadded:: 3.3