Skip to content

gh-155742: Add support.built_with_c_assertions() - #156776

Merged
vstinner merged 5 commits into
python:mainfrom
vstinner:pythoninfo_assert
Sep 2, 2026
Merged

gh-155742: Add support.built_with_c_assertions()#156776
vstinner merged 5 commits into
python:mainfrom
vstinner:pythoninfo_assert

Conversation

@vstinner

@vstinner vstinner commented Sep 1, 2026

Copy link
Copy Markdown
Member

Comment thread Lib/test/support/__init__.py Outdated
Comment thread Lib/test/support/__init__.py
--with-assertions implies -DNDEBUG anyway. Moreover, the test is
wrong for --with-assertions=no.
@vstinner

vstinner commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

Can't someone have --with-assertions=no?

It's unlikely, but if someone uses this option, the test is wrong. Well, checking for --with-assertions in CONFIG_ARGS is redundant with checking for -DNDEBUG in PY_CFLAGS. I removed the CONFIG_ARGS check.

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just two little nits.

Comment thread Lib/test/support/__init__.py Outdated


def built_with_c_assertions():
# Check if Python was built with C assertions (assert())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Check if Python was built with C assertions (assert())
"""Check if Python was built with C assertions (assert())."""

Comment thread Lib/test/support/__init__.py Outdated
# Check if Python was built with C assertions (assert())

if MS_WINDOWS:
# On Windows, rely on Py_DEBUG macro to check for assertions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# On Windows, rely on Py_DEBUG macro to check for assertions
# On Windows, rely on the Py_DEBUG macro to check for assertions

Co-authored-by: Stan Ulbrych <stan@python.org>
@vstinner
vstinner enabled auto-merge (squash) September 2, 2026 11:02
@vstinner
vstinner merged commit c700121 into python:main Sep 2, 2026
57 checks passed
@vstinner
vstinner deleted the pythoninfo_assert branch September 2, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants