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

Test Limited API in _testcapi module #95991

Closed
encukou opened this issue Aug 15, 2022 · 1 comment
Closed

Test Limited API in _testcapi module #95991

encukou opened this issue Aug 15, 2022 · 1 comment
Labels
tests Tests in the Lib/test dir topic-C-API

Comments

@encukou
Copy link
Member

encukou commented Aug 15, 2022

The Limited API is currently tested in xxlimited module(s), which isn't a great location since the module serves as a “tutorial” example of how to make a module. There's no room for advanced stuff or edge cases.
Testing Limited API together with other C API is complicated, because:

  • Limited API needs to be enabled per source file
  • Some builds don't support Limited API, so Limited API tests must be skipped on those builds.
    (Currently this is Py_TRACE_REFS, but that may change.)
  • Py_LIMITED_API must be defined before <Python.h> is included.

With #95505 (splitting _testcapi module into several source files), the first complication is solved. I'd like to add helpers for the others, to make testing Limited API easy.

@encukou encukou added tests Tests in the Lib/test dir topic-C-API labels Aug 15, 2022
encukou added a commit to encukou/cpython that referenced this issue Aug 15, 2022
…estcapi

- Limited API needs to be enabled per source file
- Some builds don't support Limited API, so Limited API tests must be skipped on those builds
  (currently this is `Py_TRACE_REFS`, but that may change.)
- `Py_LIMITED_API` must be defined before `<Python.h>` is included.

This puts the hoop-jumping in `testcapi/parts.h`, so individual
test files can be relatively simple. (Currently that's only
`vectorcall_limited.c`, imagine more.)
encukou added a commit that referenced this issue Aug 17, 2022
GH-95992)

- Limited API needs to be enabled per source file
- Some builds don't support Limited API, so Limited API tests must be skipped on those builds
  (currently this is `Py_TRACE_REFS`, but that may change.)
- `Py_LIMITED_API` must be defined before `<Python.h>` is included.

This puts the hoop-jumping in `testcapi/parts.h`, so individual
test files can be relatively simple. (Currently that's only
`vectorcall_limited.c`, imagine more.)
@encukou
Copy link
Member Author

encukou commented Aug 17, 2022

Keeping this open until I get to the devguide update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-C-API
Projects
None yet
Development

No branches or pull requests

1 participant