https://github.com/python/cpython/commit/0ac890bea79d3e0162c8909b0999f626f1141d89
commit: 0ac890bea79d3e0162c8909b0999f626f1141d89
branch: main
author: Stan Ulbrych <[email protected]>
committer: ZeroIntensity <[email protected]>
date: 2025-11-08T14:22:05-05:00
summary:

gh-141004: Document `Py_BUILD_ASSERT*` macros (GH-141266)

files:
M Doc/c-api/intro.rst
M Doc/conf.py

diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
index 4e7d1630ab3da6..6e1a9dcb35543b 100644
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -233,6 +233,29 @@ complete listing.
 
    .. versionadded:: 3.4
 
+.. c:macro:: Py_BUILD_ASSERT(cond)
+
+   Asserts a compile-time condition *cond*, as a statement.
+   The build will fail if the condition is false or cannot be evaluated at 
compile time.
+
+   For example::
+
+      Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));
+
+   .. versionadded:: 3.3
+
+.. c:macro:: Py_BUILD_ASSERT_EXPR(cond)
+
+   Asserts a compile-time condition *cond*, as an expression that evaluates to 
``0``.
+   The build will fail if the condition is false or cannot be evaluated at 
compile time.
+
+   For example::
+
+      #define foo_to_char(foo) \
+          ((char *)(foo) + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) 
== 0))
+
+   .. versionadded:: 3.3
+
 .. c:macro:: PyDoc_STRVAR(name, str)
 
    Creates a variable with name *name* that can be used in docstrings.
diff --git a/Doc/conf.py b/Doc/conf.py
index f1dda10052e109..0f1412d1007dc2 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -226,9 +226,6 @@
 # Temporary undocumented names.
 # In future this list must be empty.
 nitpick_ignore += [
-    # Undocumented public C macros
-    ('c:macro', 'Py_BUILD_ASSERT'),
-    ('c:macro', 'Py_BUILD_ASSERT_EXPR'),
     # Do not error nit-picky mode builds when _SubParsersAction.add_parser 
cannot
     # be resolved, as the method is currently undocumented. For context, see
     # https://github.com/python/cpython/pull/103289.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to