From abe94cd2dc68ec03ee78321fe40f3cf934659c7e Mon Sep 17 00:00:00 2001 From: KentaroJay Date: Fri, 4 Jul 2025 12:34:41 +0200 Subject: [PATCH 1/2] gh-136250: Clarify string to integer and integer to string conversion limits in stdtypes documentation --- Doc/library/stdtypes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 394c302fd354b9..783bf01feedaa6 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -5946,6 +5946,10 @@ The limit is applied to the number of digit characters in the input or output string when a non-linear conversion algorithm would be involved. Underscores and the sign are not counted towards the limit. +For string to integer conversions, the exact digit count is known and checked. +For integer to string conversions, the limit is applied to an estimated upper +bound of the result size to avoid the expensive conversion operation. + When an operation would exceed the limit, a :exc:`ValueError` is raised: .. doctest:: From a7af606c033d382f0ae0e52dc12415fa06427cef Mon Sep 17 00:00:00 2001 From: Kentaro Jay Takahashi <64148935+KentaroJay@users.noreply.github.com> Date: Fri, 4 Jul 2025 15:46:13 +0200 Subject: [PATCH 2/2] Update stdtypes.rst Co-authored-by: Sergey B Kirpichev --- Doc/library/stdtypes.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 783bf01feedaa6..4e945f331748c3 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -5946,9 +5946,8 @@ The limit is applied to the number of digit characters in the input or output string when a non-linear conversion algorithm would be involved. Underscores and the sign are not counted towards the limit. -For string to integer conversions, the exact digit count is known and checked. -For integer to string conversions, the limit is applied to an estimated upper -bound of the result size to avoid the expensive conversion operation. +For integer to string conversions, the limit is applied to an estimated +size of the result. When an operation would exceed the limit, a :exc:`ValueError` is raised: