Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-117398: datetime: Access C-API via PyInterpreterState#118357
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
neonene commented Apr 27, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
This comment was marked as resolved.
Include/datetime.h Outdated
| staticPyDateTime_CAPI*(*_get_pydatetime_capi)(void) =_get_pydatetime_capi_dummy; | ||
| #definePyDateTimeAPI _get_pydatetime_capi() | ||
| staticinlinevoidpydatetime_import(void){ |
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 would prefer to not leak such implementation detail at the ABI level, and so use a regular function rather than a static inline function. I would prefer that _pydatetime_capi is private.
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.
How can I resolve non-Windows errors? I'm not sure how to use private struct members here.
Error: _testcapi failed to import: /home/runner/work/cpython/cpython-builddir/ build/lib.linux-x86_64-3.13-pydebug/_testcapi.cpython-313d-x86_64-linux-gnu.so: undefined symbol: _PyDateTimeAPI_Get Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
neonene commented May 1, 2024
I added another capsule which points to the |
neonene commented May 1, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
vstinner commented May 1, 2024
Such change is too late for beta1. It's better to wait for the beginning of the 3.14 dev cycle. |
neonene commented May 1, 2024
How do you think of the situation? |
vstinner commented May 2, 2024
In my experience, such change is likely to cause regression and need more time to be stabilized. I prefer to wait Wednesday. |
neonene commented May 2, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Otherwise, 3.13 should take specific workarounds for the crash |
neonene commented May 3, 2024
A workaround is ready for review: #118531 |
vstinner commented May 3, 2024
Which crash? This PR is related to issue gh-117398 which doesn't mention any crash. |
ericsnowcurrently commented May 3, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
FYI, I asked @Yhg1s if we could get an exception for landing this after beta 1: #103092 (comment). He gave us a similar exception for 3.12. Thomas might not do that this time, but at least I've asked. |
Yhg1s commented May 5, 2024
This particular change is just one that adds a new capsule C API, which can then be used when in the future the datetime module switches to multi-phase init and better subinterpreter support, right? Given that it's of mild impact and it gives us an API that allows us to deprecate the old one and use multi-phase init for datetime, I'm okay with this going into beta 2. |
vstinner commented May 5, 2024
It doesn't sound safe to me to announce that the _datetime extension is compatible with subinterpreters before static types are converted to heap types. I suggest to discuss the plan in the issue: #117398 (comment) |
neonene commented May 8, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@vstinner I think this should be tested from 3.13.0b1+. The change is easy to diagnose or revert. If an inevitable problem is found, the case will support your exceptional approach (mix EDIT: Ultimately, |
vstinner left a comment
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.
IMO Py_MOD_PER_INTERPRETER_GIL_SUPPORTED cannot be added before other changes are done, such as converting static types to heap types.
I prefer to do the conversion in a different order, with multiple steps: #117398 (comment)
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
neonene commented May 9, 2024
This PR does not add the flag in |
An alternative PR to #117413, which also makes the datetime C-API available to the isolated subinterpreters.
The pointer to the
PyDateTime_CAPIstruct is stored inPyInterpreterStateright after thePyCapsule_Import()call. This version does not changeModules/_testcapi/datetime.cfor now. Also, the overhead should be even across interpreters.However, this extends thePyDateTime_CAPIstruct.cc @pganssle@vstinner@ericsnowcurrently@encukou@erlend-aasland