Skip to content

Some C-API tests use assert, so they don't run in non-debug mode #95783

@encukou

Description

@encukou

The assert function in C does nothing in non-debug builds.

Like assert vs. self.assertTrue in Python, tests (in Modules/_testcapimodule.c, Modules/_testapi/* and similar) should not use assert. They should fail regardless of build settings.

Possible fixes for this kind of issue:

  • Raise PyExc_AssertionError or similar explicitly
  • Move the test to Python if possible (or just part of it, but splitting a test up between files has a readability cost)
  • Even Py_FatalError would be better than assert

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtopic-C-APItype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions