From 868c0897747325fbface8fcbcd889e6aa74d945b Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Wed, 19 Nov 2025 18:02:13 +0000 Subject: [PATCH 1/7] Commit --- Doc/c-api/sys.rst | 22 ++++++++++++++++++++++ Misc/NEWS.d/3.10.0a1.rst | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst index ee73c1c8adaa7b..7cd3e6227aa9e4 100644 --- a/Doc/c-api/sys.rst +++ b/Doc/c-api/sys.rst @@ -267,6 +267,28 @@ Operating System Utilities .. versionadded:: 3.14 +.. c:function:: int PyOS_mystricmp(const char *str1, const char *str2) + + Compare two strings, *str1* and *str2*. The function works almost + identically to :c:func:`!strcmp` except that it ignores the case. + + Return ``0`` if the strings are equal, a negative value if *str1* is less + than *str2*, or a positive value if *str1* is greater than *str2*. + + This function is async-signal-safe and cannot fail. + + +.. c:function:: int PyOS_mystrnicmp(const char *str1, const char *str2, Py_ssize_t size) + + Compare two strings, *str1* and *str2*. The function works almost + identically to :c:func:`!strncmp` except that it ignores the case. + + Return ``0`` if the strings are equal, a negative value if *str1* is less + than *str2*, or a positive value if *str1* is greater than *str2*. + + This function is async-signal-safe and cannot fail. + + .. _systemfunctions: System Functions diff --git a/Misc/NEWS.d/3.10.0a1.rst b/Misc/NEWS.d/3.10.0a1.rst index f09842f1e77dea..473e7c7ac0f574 100644 --- a/Misc/NEWS.d/3.10.0a1.rst +++ b/Misc/NEWS.d/3.10.0a1.rst @@ -3275,8 +3275,8 @@ Types created with :c:func:`PyType_FromSpec` now make any signature in their .. nonce: u6Xfr2 .. section: C API -Fix bug in PyOS_mystrnicmp and PyOS_mystricmp that incremented pointers -beyond the end of a string. +Fix bug in :c:func:`PyOS_mystrnicmp` and :c:func:`PyOS_mystricmp` that +incremented pointers beyond the end of a string. .. From 750fcf1a69b9eb270d3f0f241132e07ace4321ec Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Wed, 19 Nov 2025 18:05:53 +0000 Subject: [PATCH 2/7] Simplify --- Doc/c-api/sys.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst index 7cd3e6227aa9e4..aaf2ecab032184 100644 --- a/Doc/c-api/sys.rst +++ b/Doc/c-api/sys.rst @@ -275,7 +275,7 @@ Operating System Utilities Return ``0`` if the strings are equal, a negative value if *str1* is less than *str2*, or a positive value if *str1* is greater than *str2*. - This function is async-signal-safe and cannot fail. + This function cannot fail. .. c:function:: int PyOS_mystrnicmp(const char *str1, const char *str2, Py_ssize_t size) @@ -286,7 +286,7 @@ Operating System Utilities Return ``0`` if the strings are equal, a negative value if *str1* is less than *str2*, or a positive value if *str1* is greater than *str2*. - This function is async-signal-safe and cannot fail. + This function cannot fail. .. _systemfunctions: From ade4de4faaa643af7e662f2ab4e610c14d7f0b80 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 20 Nov 2025 16:53:01 +0000 Subject: [PATCH 3/7] Petr's review --- Doc/c-api/conversion.rst | 24 ++++++++++++++++++++++-- Doc/c-api/sys.rst | 22 ---------------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst index a18bbf4e0e37d7..7bba429880fdf9 100644 --- a/Doc/c-api/conversion.rst +++ b/Doc/c-api/conversion.rst @@ -165,13 +165,33 @@ The following functions provide locale-independent string to number conversions. .. c:function:: int PyOS_stricmp(const char *s1, const char *s2) Case insensitive comparison of strings. The function works almost - identically to :c:func:`!strcmp` except that it ignores the case. + identically to :c:func:`!strcmp` except that it ignores the case and locale. + + Return ``0`` if the strings are equal, a negative value if *str1* is less + than *str2*, or a positive value if *str1* is greater than *str2*. + + This function cannot fail. .. c:function:: int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size) Case insensitive comparison of strings. The function works almost - identically to :c:func:`!strncmp` except that it ignores the case. + identically to :c:func:`!strncmp` except that it ignores the case and locale. + + Return ``0`` if the strings are equal, a negative value if *str1* is less + than *str2*, or a positive value if *str1* is greater than *str2*. + + This function cannot fail. + + +.. c:function:: int PyOS_mystricmp(const char *str1, const char *str2) + + This is an alias of :c:func:`PyOS_stricmp` on all platforms except Windows. + + +.. c:function:: int PyOS_mystrnicmp(const char *str1, const char *str2, Py_ssize_t size) + + This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows. Character classification and conversion diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst index aaf2ecab032184..ee73c1c8adaa7b 100644 --- a/Doc/c-api/sys.rst +++ b/Doc/c-api/sys.rst @@ -267,28 +267,6 @@ Operating System Utilities .. versionadded:: 3.14 -.. c:function:: int PyOS_mystricmp(const char *str1, const char *str2) - - Compare two strings, *str1* and *str2*. The function works almost - identically to :c:func:`!strcmp` except that it ignores the case. - - Return ``0`` if the strings are equal, a negative value if *str1* is less - than *str2*, or a positive value if *str1* is greater than *str2*. - - This function cannot fail. - - -.. c:function:: int PyOS_mystrnicmp(const char *str1, const char *str2, Py_ssize_t size) - - Compare two strings, *str1* and *str2*. The function works almost - identically to :c:func:`!strncmp` except that it ignores the case. - - Return ``0`` if the strings are equal, a negative value if *str1* is less - than *str2*, or a positive value if *str1* is greater than *str2*. - - This function cannot fail. - - .. _systemfunctions: System Functions From 102f714caa22ac2a3b1d900f1986b48c1542bd76 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 20 Nov 2025 17:07:14 +0000 Subject: [PATCH 4/7] Re-move --- Doc/c-api/conversion.rst | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst index 7bba429880fdf9..2d66047e894ec3 100644 --- a/Doc/c-api/conversion.rst +++ b/Doc/c-api/conversion.rst @@ -167,10 +167,7 @@ The following functions provide locale-independent string to number conversions. Case insensitive comparison of strings. The function works almost identically to :c:func:`!strcmp` except that it ignores the case and locale. - Return ``0`` if the strings are equal, a negative value if *str1* is less - than *str2*, or a positive value if *str1* is greater than *str2*. - - This function cannot fail. + This is an alias of :c:func:`PyOS_stricmp` on all platforms except Windows. .. c:function:: int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size) @@ -178,20 +175,29 @@ The following functions provide locale-independent string to number conversions. Case insensitive comparison of strings. The function works almost identically to :c:func:`!strncmp` except that it ignores the case and locale. + This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows. + + +.. c:function:: int PyOS_mystricmp(const char *str1, const char *str2) + + Case insensitive comparison of strings. The function works almost + identically to :c:func:`!strcmp` except that it ignores the case and locale. + Return ``0`` if the strings are equal, a negative value if *str1* is less than *str2*, or a positive value if *str1* is greater than *str2*. This function cannot fail. -.. c:function:: int PyOS_mystricmp(const char *str1, const char *str2) - - This is an alias of :c:func:`PyOS_stricmp` on all platforms except Windows. +.. c:function:: int PyOS_mystrnicmp(const char *str1, const char *str2, Py_ssize_t size) + Case insensitive comparison of strings. The function works almost + identically to :c:func:`!strncmp` except that it ignores the case and locale. -.. c:function:: int PyOS_mystrnicmp(const char *str1, const char *str2, Py_ssize_t size) + Return ``0`` if the strings are equal, a negative value if *str1* is less + than *str2*, or a positive value if *str1* is greater than *str2*. - This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows. + This function cannot fail. Character classification and conversion From fc7fe7785905eaf2b47b0f8908837082cbd15aff Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 20 Nov 2025 18:19:43 +0000 Subject: [PATCH 5/7] Fix ref --- Doc/c-api/conversion.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst index 2d66047e894ec3..d1f03bd8904e01 100644 --- a/Doc/c-api/conversion.rst +++ b/Doc/c-api/conversion.rst @@ -167,7 +167,7 @@ The following functions provide locale-independent string to number conversions. Case insensitive comparison of strings. The function works almost identically to :c:func:`!strcmp` except that it ignores the case and locale. - This is an alias of :c:func:`PyOS_stricmp` on all platforms except Windows. + This is an alias of :c:func:`PyOS_mstricmp` on all platforms except Windows. .. c:function:: int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size) From 8ec83908416720f195d0e7c0834c6a58c3bfc9a0 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 20 Nov 2025 18:32:40 +0000 Subject: [PATCH 6/7] !fixup Fix ref --- Doc/c-api/conversion.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst index d1f03bd8904e01..fd6a5e0ce2f4d9 100644 --- a/Doc/c-api/conversion.rst +++ b/Doc/c-api/conversion.rst @@ -167,7 +167,7 @@ The following functions provide locale-independent string to number conversions. Case insensitive comparison of strings. The function works almost identically to :c:func:`!strcmp` except that it ignores the case and locale. - This is an alias of :c:func:`PyOS_mstricmp` on all platforms except Windows. + This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows. .. c:function:: int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size) From 01fbfa1ec1b2b81a00ff23de5cb3d58a53c6d987 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Fri, 21 Nov 2025 16:50:27 +0000 Subject: [PATCH 7/7] Peteer's review --- Doc/c-api/conversion.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst index fd6a5e0ce2f4d9..1b745d8812712f 100644 --- a/Doc/c-api/conversion.rst +++ b/Doc/c-api/conversion.rst @@ -167,7 +167,8 @@ The following functions provide locale-independent string to number conversions. Case insensitive comparison of strings. The function works almost identically to :c:func:`!strcmp` except that it ignores the case and locale. - This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows. + This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows, + where it is an alias of :c:func:`!strcmp`. .. c:function:: int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size) @@ -175,7 +176,8 @@ The following functions provide locale-independent string to number conversions. Case insensitive comparison of strings. The function works almost identically to :c:func:`!strncmp` except that it ignores the case and locale. - This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows. + This is an alias of :c:func:`PyOS_mystricmp` on all platforms except Windows, + where it is an alias of :c:func:`!strncmp`. .. c:function:: int PyOS_mystricmp(const char *str1, const char *str2)