-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Add support for the limited C API to Argument Clinic #108494
Comments
Argument Clinic now has a partial support of the Limited API: * Add --limited option to clinic.c. * Add '_testclinic_limited' extension which is built with the limited C API version 3.13. * For now, hardcode in clinic.py that "_testclinic_limited.c" targets the limited C API.
Argument Clinic now has a partial support of the Limited API: * Add --limited option to clinic.c. * Add '_testclinic_limited' extension which is built with the limited C API version 3.13. * For now, hardcode in clinic.py that "_testclinic_limited.c" targets the limited C API.
My first change adds this code to build
Maybe we could add a marker using Argument Clinic syntax to announce "hey, I want the limited C API"! Or AC could parse the C code and look for |
AC now checks for "#define Py_LIMITED_API" pattern to use the limited C API.
AC now checks for "#define Py_LIMITED_API" pattern to use the limited C API.
My change added support for limited C API version 3.13. If we consider supporting older Python versions, this issue should be carefully reviewed: #71686 "PY_SSIZE_T_CLEAN conflicts with Py_LIMITED_API". Maybe it has been fixed in the meanwhile, I'm not sure. The goal here would be to be able build a C extension with Python 3.13 which works on Python 3.2 to 3.12. |
Something else to consider, @shihai1991 wrote:
I don't in which Python version it was usable as part of the stable ABI. My current implementation is limited to |
Well, see issue #85283 for the interesting discussion in 2020-2021. |
AC now checks for "#define Py_LIMITED_API" pattern to use the limited C API.
I implemented that in my second PR, see LIMITED_CAPI_REGEX. |
Revert my change adding 'ns' parameter, add back 'verify' parameter, and add also 'limited_capi' parameter.
Revert my change adding 'ns' parameter, add back 'verify' parameter, and add also 'limited_capi' parameter.
Fix the limited C API code path in Argument Clinic to parse "positional or keywords" arguments. Add an unit test in _testclinic_limited.
Fix the limited C API code path in Argument Clinic to parse "positional or keywords" arguments. Add an unit test in _testclinic_limited.
Revert my change adding 'ns' parameter, add back 'verify' parameter, and add also 'limited_capi' parameter.
Use PyTuple_Size() instead of PyTuple_GET_SIZE().
When I try to convert the |
…he limited C API (#108584) Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Erlend E. Aasland <[email protected]>
* main: pythongh-108520: Fix bad fork detection in nested multiprocessing use case (python#108568) pythongh-108590: Revert pythongh-108657 (commit 400a1ce) (python#108686) pythongh-108494: Argument Clinic: Document how to generate code that uses the limited C API (python#108584) Document Python build requirements (python#108646) pythongh-101100: Fix Sphinx warnings in the Logging Cookbook (python#108678) Fix typo in multiprocessing docs (python#108666) pythongh-108669: unittest: Fix documentation for TestResult.collectedDurations (python#108670) pythongh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (python#108657) Revert "pythongh-103224: Use the realpath of the Python executable in `test_venv` (pythonGH-103243)" (pythonGH-108667) pythongh-106320: Remove private _Py_ForgetReference() (python#108664) Mention Ellipsis pickling in the docs (python#103660) Revert "Use non alternate name for Kyiv (pythonGH-108533)" (pythonGH-108649) pythongh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (python#108632) pythongh-108455: peg_generator: install two stubs packages before running mypy (python#108637) pythongh-107801: Improve the accuracy of io.IOBase.seek docs (python#108268)
…arameters in the limited C API (GH-108622)
… that uses the limited C API (python/cpython#108584) Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Erlend E. Aasland <[email protected]>
… that uses the limited C API (python/cpython#108584) Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Erlend E. Aasland <[email protected]>
Add _testclinic_limited to Tools/msi/test/test_files.wxs.
…ythonGH-110077) Add _testclinic_limited to Tools/msi/test/test_files.wxs. (cherry picked from commit 6387b53) Co-authored-by: Victor Stinner <[email protected]>
…ython#110077) (cherry picked from commit 6387b53)
…ythonGH-110077) (cherry picked from commit 6387b53) Co-authored-by: Victor Stinner <[email protected]>
…GH-110077) (#110230) gh-108494: Document how to add a project in PCbuild/readme.txt (GH-110077) (cherry picked from commit 6387b53) Co-authored-by: Victor Stinner <[email protected]>
Thanks to @serhiy-storchaka, Argument Clinic now supports all formats for the limited C API. I'm sure that we will find code which doesn't work and room for improvement. It can be done later. I close the issue. Thanks to everybody who helped me to make it possible :-) |
Follow-up: PR #110964 "[C API] Move undocumented private _PyArg C API to pycore_modsupport.h internal C API". |
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
…ython#110077) Add _testclinic_limited to Tools/msi/test/test_files.wxs.
Feature or enhancement
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Proposal:
I propose adding support for the limited C API to Argument Clinic. Since Argument Clinic supports a wide diversity of parameter types and object types, I propose to add the support incrementally (step by step).
The final goal is to restrict some stdlib C extensions to the limited C API.
Linked PRs
parse_file()
API #108575The text was updated successfully, but these errors were encountered: