-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
C API: Move limited C API tests from _testcapi to a new _testlimitedcapi extension #116417
Comments
Add a new C extension "_testlimitedcapi" which is only built with the limited C API. Move heaptype_relative.c and vectorcall_limited.c from Modules/_testcapi/ to Modules/_testlimitedcapi/.
Add a new C extension "_testlimitedcapi" which is only built with the limited C API. Move heaptype_relative.c and vectorcall_limited.c from Modules/_testcapi/ to Modules/_testlimitedcapi/. * configure: add _testlimitedcapi test extension. * Update generate_stdlib_module_names.py. * Update make check-c-globals. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Move bytes.c and sys.c from Modules/_testcapi/ to Modules/_testlimitedcapi/. * Split some tests in two files, limited and non-limited: * abstract.c * dict.c * list.c * set.c * Copy util.h to Modules/_testlimitedcapi/. * Update test_capi.
Argument Clinic no longer calls PyFloat_AS_DOUBLE() when the usage of the limited C API is requested.
Argument Clinic no longer calls PyFloat_AS_DOUBLE() when the usage of the limited C API is requested.
Argument Clinic no longer calls PyFloat_AS_DOUBLE() when the usage of the limited C API is requested.
* Remove unused '_testcapimodule' global in Modules/_testcapi/unicode.c. * Update c-analyzer to not use the internal C API in _testlimitedcapi.c.
Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Update related test_capi tests. Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
* Remove unused '_testcapimodule' global in Modules/_testcapi/unicode.c. * Update c-analyzer to not use the internal C API in _testlimitedcapi.c.
Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Changes: * Replace PyBytes_AS_STRING() with PyBytes_AsString(). * Replace PyBytes_GET_SIZE() with PyBytes_Size(). * Update related test_capi tests. * Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Changes: * Replace PyBytes_AS_STRING() with PyBytes_AsString(). * Replace PyBytes_GET_SIZE() with PyBytes_Size(). * Update related test_capi tests. * Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
Split list.c and set.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
Note to myself: |
What Limited C API? Shouldn't there be multiple separately compiled extensions, one for each version? |
I only plan to test a single limited C API version per C file. IMO it's already better than not testing the limited C API.
|
What is the purpose of testing the Limited C API separately? I thought that it is to check that these functions are available in the specified Limited C API version, but if we use higher version, this does not work. There are many new functions in 3.13, so you would need to bump the version to 3.13.
|
We made mistakes quite often in the past in the limited C API. The idea is to test our limited C API to make sure that it works as expected. For example, the "trashcan" API was exposed in the limited C API but it didn't work because it accessed a PyThreadState member which is not accessible in the limited C API. For me, it's awkward that we missed such obvious bug :-(
I don't worry much about the exact tested limited C API.
Right, more and more parts the limited C API have different implementations depending on the implementation. One example is Py_INCREF() / Py_DECREF() which is either implemented as static inline functions or implemented as function calls. If we build C extensions with different limited C API versions, it's more likely to catch bugs. Maybe later we can even test the same API on multiple limited C API versions. But I propose to move step by step. First, decide which tests are tested with the limited C API or not. I propose to tests basically everything with the limited C API, unless the API is not available in the limited C API. That's why this PR proposes to split tests between limited and non-limited tests. By the way, |
…n#116570) * Remove unused '_testcapimodule' global in Modules/_testcapi/unicode.c. * Update c-analyzer to not use the internal C API in _testlimitedcapi.c.
…ython#116571) Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Changes: * Replace PyBytes_AS_STRING() with PyBytes_AsString(). * Replace PyBytes_GET_SIZE() with PyBytes_Size(). * Update related test_capi tests. * Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
…python#116602) Split list.c and set.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
Use different function names between _testcapi and _testlimitedcapi to not confuse the WASI linker.
…api (python#116986) Split abstract.c and float.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_bytes and test_class.
…pi (python#116993) Split unicode.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_codecs.
…ython#117001) * Split long.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. * Move testcapi_long.h from Modules/_testcapi/ to Modules/_testlimitedcapi/. * Add MODULE__TESTLIMITEDCAPI_DEPS to Makefile.pre.in.
…ython#117006) Split dict.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
…pi (python#117014) Split complex.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
Add a new C extension "_testlimitedcapi" which is only built with the limited C API. Move heaptype_relative.c and vectorcall_limited.c from Modules/_testcapi/ to Modules/_testlimitedcapi/. * configure: add _testlimitedcapi test extension. * Update generate_stdlib_module_names.py. * Update make check-c-globals. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
…n#116568) Argument Clinic no longer calls PyFloat_AS_DOUBLE() when the usage of the limited C API is requested.
…n#116570) * Remove unused '_testcapimodule' global in Modules/_testcapi/unicode.c. * Update c-analyzer to not use the internal C API in _testlimitedcapi.c.
…ython#116571) Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Changes: * Replace PyBytes_AS_STRING() with PyBytes_AsString(). * Replace PyBytes_GET_SIZE() with PyBytes_Size(). * Update related test_capi tests. * Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
…python#116602) Split list.c and set.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
Use different function names between _testcapi and _testlimitedcapi to not confuse the WASI linker.
…api (python#116986) Split abstract.c and float.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_bytes and test_class.
…pi (python#116993) Split unicode.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_codecs.
…ython#117001) * Split long.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. * Move testcapi_long.h from Modules/_testcapi/ to Modules/_testlimitedcapi/. * Add MODULE__TESTLIMITEDCAPI_DEPS to Makefile.pre.in.
…ython#117006) Split dict.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
…pi (python#117014) Split complex.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
* Fix implementation of %#T and %#N (they were implemented as %T# and %N#). * Restore tests removed in pythongh-116417.
Currently, the
_testcapi
C extension is partially built with the limited C API and partially with the non-limited C API. It can lead to some confusion: which API is being tested?I proposed to create a new
_testlimitedcapi
extension which is only built with the limited C API. It can only access to the limited C API and so there is a lower risk to test the non-limited C API by mistake.Linked PRs
The text was updated successfully, but these errors were encountered: