-
-
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
gh-116417: Add _testlimitedcapi C extension #116419
Conversation
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/.
@erlend-aasland @encukou @sobolevn @colesbury: What do you think of this change? (See the issue for the rationale.) |
If we land this change, should we move tests which don't use the non-limited C API (tests only using the limited C API) to _testlimitedapi? This change should be backported to 3.11 and 3.12 branches to ease backport of future changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a good idea to me.
- The
#include "pyconfig.h"
can be removed fromvectorcall_limited.c
andheaptype_relative.c
now that it's part ofparts.h
heaptype_relative.c
can also remove thePy_LIMITED_API
define now that it's defined inparts.h
.
Can we remove |
Fixed: nicely spotted for remaining code in heaptype_relative.c. I had a lot of build issues to build the new C extension properly on Linux and Windows, and then I forgot these lines.
I don't think that it's a test, but more an example to write code using the limited C API. I started with the comment: /* Use this file as a template to start implementing a module that
also declares object types. All occurrences of 'Xxo' should be changed cc @encukou |
@colesbury: I addressed your remarks and tests now pass. You can review the updated PR ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good idea, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like it if you could create an entry for this module in configure.ac
; that way it is easier to see if this module is enabled or not. Relevant output from sample ./configure
and make
invocations:
The following modules are *disabled* in configure script:
_ctypes_test _testbuffer _testcapi
_testclinic _testclinic_limited _testexternalinspection
_testimportmultiple _testinternalcapi _testmultiphase
_testsinglephase _xxtestfuzz xxsubtype
checking for stdlib extension module _testcapi... disabled
checking for stdlib extension module _testclinic... disabled
checking for stdlib extension module _testclinic_limited... disabled
checking for stdlib extension module _testinternalcapi... disabled
checking for stdlib extension module _testbuffer... disabled
checking for stdlib extension module _testimportmultiple... disabled
checking for stdlib extension module _testmultiphase... disabled
checking for stdlib extension module _testsinglephase... disabled
checking for stdlib extension module _testexternalinspection... disabled
If you "hide" this new extension module behind the _testcapi
module, it will not show up in these outputs.
Sure! It's done. Example:
The test extension is now disabled as expected. |
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Thanks! On more nit :) |
It's a nice change; it makes sense to have this as a separate test module IMO. |
Thanks for your helpful reviews! I merged my PR. |
Backporting this change to Python 3.12 looks non trivial, I get many conflicts:
The split of |
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>
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>
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/.