Conversation
6164db5 to
dc77ab0
Compare
dc77ab0 to
5b857a4
Compare
ZeroIntensity
left a comment
There was a problem hiding this comment.
Thanks for working on these!
| struct PyExpat_CAPI { | ||
| char *magic; /* set to PyExpat_CAPI_MAGIC */ |
There was a problem hiding this comment.
Let's avoid making code formatting changes in this PR.
vstinner
left a comment
There was a problem hiding this comment.
The PyExpat capsule is used to access Modules/pyexpat.c functions in Modules/_elementtree.c. I'm not sure that it was intended to be used outside Modules/_elementtree.c.
A code search on PyPI top 15,000 projects (at 2025-09-22) found no matching projects.
In 2020, I moved the Unicode capsule C structure to the internal C API (pycore_ucnhash.h): commit 47e1afd. Then I renamed the PyUnicodeData_CAPSULE_NAME to make it private: commit 84f7382. I expected lot of complains and broken projects, but no one was impacted :-) It went well.
|
If you need this you should probably use expat directly; the vendored copy is aliased so that it shouldn't conflict. |
|
Should we deprecate the pyexpat public capsule, and use a private capsule in elementtree? |
|
I don't use this personally so I would prefer deprecating and making it private :') However, while there might not exist public code relying on this, there might exist private one =/. Strictly speaking, there is actually one handler that Python provides and this is |
| included by default by :file:`Python.h`) and ``expat.h`` for Expat. | ||
|
|
||
| To use the C API, consider adding the following code in your extension | ||
| module initilisation function and store the pointer to the C API in |
There was a problem hiding this comment.
Typo:
| module initilisation function and store the pointer to the C API in | |
| module initialization function and store the pointer to the C API in |
That's the purpose of a deprecation over multiple years, communicate that we are going to remove an API, to give users time to report their usage and ask to keep the API and provide a different one. |
|
Ok, but how do I really deprecate this one? should I just go with a |
|
Yeah, As is adding docs to hold “porting notes” (i.e. use the Python APIs, or |
The Expat C API does not store a global variable as other C APIs and instead prefer consumers to add both the capsule and the C API pointer in the consumer's state. I don't really llike this but it's probably the best
📚 Documentation preview 📚: https://cpython-previews--141259.org.readthedocs.build/