Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-43795: PEP-652: Simplify headers for easier static analysis #25483

Merged
merged 2 commits into from
Apr 23, 2021

Conversation

encukou
Copy link
Member

@encukou encukou commented Apr 20, 2021

As part of the PEP-652 implementation, I'll tighten the CI check
for functions/data defined with Py_LIMITED_API.

Discussion in https://discuss.python.org/t/pep-652-maintaining-the-stable-abi/6986
suggests that parsing C headers is OK (though personally I'd rather generate it...),
but writing a full C parser is a monumental task and adding an existing one as a
dependency brings too many vendoring/bootstraping issues.

So, for the check I'll use a "simple" regex on preprocessor output, and adapt
the few trivial places where the regex won't work.

  • Keep declarations in the limited API to one item per line
  • Make it possible to override _Py_NO_RETURN, so the annotation can be
    removed from preprocessor output.

https://bugs.python.org/issue43795

This makes static analysis easier.

From discussion at https://discuss.python.org/t/pep-652-maintaining-the-stable-abi/6986/13
it is clear that:
- parsing C to get information is okay (though I personally prefer to *generate* it)
- writing a full C parser is a monumental task (and adding an existing one as a dependency
  is not feasible)

I think it's reasonable to simplify our declarations in order to make header checks
easier, rather than write a parser that can handle all C.
This makes static analysis of the headers easier.
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

@encukou encukou merged commit e7cc64e into python:master Apr 23, 2021
@encukou encukou deleted the pep652-simplify-headers branch April 23, 2021 12:14
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.

4 participants