Skip to content

Uniformly disable assertions on release builds and enable them for tests - #278

Merged
mattip merged 1 commit into
python-cffi:mainfrom
ngoldbaum:build-assertions
Sep 15, 2026
Merged

mattip merged 1 commit into
python-cffi:mainfrom
ngoldbaum:build-assertions

Conversation

@ngoldbaum

Copy link
Copy Markdown
Contributor

Currently the Linux and iOS wheels are built with debug assertions enabled. This could lead to aborts at runtime for release builds if someone happens to hit an assert. The Mac and Windows wheels do not have asserts.

I'm pretty sure this was unintentional: setuptools 75.7.0 and newer no longer inherit -DNDEBUG from CPython.

This PR sets up an intentional policy: release wheels shouldn't have asserts but wheels built for testing and other test jobs should have asserts enabled. Also sets up CI scaffolding and a test for this.

I have a followup PR that uses asserts to document and enforce invariants which led me to notice and think about this.

@mattip

mattip commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Makes sense, and the test is passing. Thanks @ngoldbaum

@mattip
mattip merged commit 1728e56 into python-cffi:main Sep 15, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants