From 1454a5b3c231962788c2c359bdc980c9570e182a Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Mon, 19 Oct 2026 13:08:55 -0400 Subject: [PATCH 1/2] Document missing pyport.h macros. --- Doc/c-api/float.rst | 4 ++-- Doc/c-api/intro.rst | 18 ++++++++++++++++-- Tools/check-c-api-docs/ignored_c_api.txt | 1 - 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index c484b3e5bdb5132..8a944402ed683a5 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -214,7 +214,7 @@ Pack functions The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an :c:expr:`int` argument, non-zero if you want the bytes string in little-endian format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` and ``p+7``), zero if you -want big-endian format (exponent first, at *p*). Use the :c:macro:`!PY_LITTLE_ENDIAN` +want big-endian format (exponent first, at *p*). Use the :c:macro:`PY_LITTLE_ENDIAN` constant to select the native endian: it is equal to ``0`` on big endian processor, or ``1`` on little endian processor. @@ -240,7 +240,7 @@ Unpack functions The unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an :c:expr:`int` argument, non-zero if the bytes string is in little-endian format (exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-endian -(exponent first, at *p*). Use the :c:macro:`!PY_LITTLE_ENDIAN` constant to +(exponent first, at *p*). Use the :c:macro:`PY_LITTLE_ENDIAN` constant to select the native endian: it is equal to ``0`` on big endian processor, or ``1`` on little endian processor. diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index 701d2a31b8c9059..b9f67c45c75333b 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -299,6 +299,12 @@ Numeric utilities Argument must be a character or an integer in the range [-128, 127] or [0, 255]. This macro returns ``c`` cast to an ``unsigned char``. +.. c:macro:: PY_BIG_ENDIAN + PY_LITTLE_ENDIAN + + Constants describing the byte order of the platform that Python was built + for. Exactly one of them is ``1`` and the other is ``0``. + Assertion utilities ^^^^^^^^^^^^^^^^^^^ @@ -916,8 +922,16 @@ use them. A signed integral type such that ``sizeof(Py_ssize_t) == sizeof(size_t)``. C99 doesn't define such a thing directly (size_t is an unsigned integral type). - See :pep:`353` for details. ``PY_SSIZE_T_MAX`` is the largest positive value - of type :c:type:`Py_ssize_t`. + See :pep:`353` for details. + +.. c:macro:: PY_SSIZE_T_MAX + + The largest positive value of type :c:type:`Py_ssize_t`. + +.. c:macro:: PY_SSIZE_T_MIN + + The smallest negative value of type :c:type:`Py_ssize_t`. + This is equal to ``-PY_SSIZE_T_MAX - 1``. .. _api-exceptions: diff --git a/Tools/check-c-api-docs/ignored_c_api.txt b/Tools/check-c-api-docs/ignored_c_api.txt index af7b2772ef5e085..1eb6806b83d5cd0 100644 --- a/Tools/check-c-api-docs/ignored_c_api.txt +++ b/Tools/check-c-api-docs/ignored_c_api.txt @@ -26,7 +26,6 @@ PyExpat_CAPSULE_NAME # pyport.h PYLONG_BITS_IN_DIGIT PY_DWORD_MAX -PY_BIG_ENDIAN # cpython/methodobject.h PyCFunction_GET_CLASS # cpython/descrobject.h From 607e297175bba775f5839c29af752354ca5394c5 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Mon, 19 Oct 2026 17:23:54 -0400 Subject: [PATCH 2/2] Update Doc/c-api/intro.rst Co-authored-by: Petr Viktorin --- Doc/c-api/intro.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index b9f67c45c75333b..258135a234cc50d 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -925,13 +925,10 @@ use them. See :pep:`353` for details. .. c:macro:: PY_SSIZE_T_MAX + PY_SSIZE_T_MIN - The largest positive value of type :c:type:`Py_ssize_t`. - -.. c:macro:: PY_SSIZE_T_MIN - - The smallest negative value of type :c:type:`Py_ssize_t`. - This is equal to ``-PY_SSIZE_T_MAX - 1``. + The limit values (largest positive one and smallest negative one, + respecitvely) of type :c:type:`Py_ssize_t`. .. _api-exceptions: