[3.14] gh-141004: Document Py_BUILD_ASSERT* macros (GH-141266) (GH-141269)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / iOS (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run

gh-141004: Document `Py_BUILD_ASSERT*` macros (GH-141266)
(cherry picked from commit 0ac890bea7)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-11-08 20:27:41 +01:00 committed by GitHub
parent f98211852a
commit d8a2b8a4f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 3 deletions

View file

@ -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.

View file

@ -226,9 +226,6 @@ nitpick_ignore = [
# 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.