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

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 Resolved
Comment thread Lib/test/support/__init__.py Resolved
--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
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
vstinner added a commit that referenced this pull request Oct 16, 2026
…9515)

* gh-158445: Add C API tests on build information functions (#158603)

Add tests on functions:

* Py_GetBuildInfo()
* Py_GetCompiler()
* Py_GetCopyright()
* Py_GetPlatform()
* Py_GetVersion()

Changes:

* Add Modules/_testlimitedcapi.c and
  Lib/test/test_capi/test_build.py files.
* Add internal _Py_GetBuiltWithAssert() function.
* Reimplemenet support.built_with_c_assertions() using
  _Py_GetBuiltWithAssert() to cover more cases like buildbots using
  CFLAGS=-UNDEBUG in release mode.

(cherry picked from commit a831abb)

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

Co-authored-by: Stan Ulbrych <stan@python.org>
(cherry picked from commit c700121)

---------

Co-authored-by: Stan Ulbrych <stan@python.org>
vstinner added a commit that referenced this pull request Oct 16, 2026
…9515) (#159525)

[3.15] gh-158445: Add C API tests on build information functions (#159515)

* gh-158445: Add C API tests on build information functions (#158603)

Add tests on functions:

* Py_GetBuildInfo()
* Py_GetCompiler()
* Py_GetCopyright()
* Py_GetPlatform()
* Py_GetVersion()

Changes:

* Add Modules/_testlimitedcapi.c and
  Lib/test/test_capi/test_build.py files.
* Add internal _Py_GetBuiltWithAssert() function.
* Reimplemenet support.built_with_c_assertions() using
  _Py_GetBuiltWithAssert() to cover more cases like buildbots using
  CFLAGS=-UNDEBUG in release mode.

(cherry picked from commit a831abb)

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


(cherry picked from commit c700121)

---------


(cherry picked from commit cb7a629)

Co-authored-by: Stan Ulbrych <stan@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants