-
-
Notifications
You must be signed in to change notification settings - Fork 32k
datetime: Stop Exposing Process-Global Objects in the datetime C-API #122184
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
Comments
I was looking at the PyDateTime wrappers in PyO3 today and noticed a tiny weirdness. Lines 199 to 200 in 12eaadc
In practice I guess this means the macro (and implicitly that use of |
I believe that it definitely can fail, e.g. if a user names a file |
I made a small C reproducer to illustrate the problem and created capi-workgroup/problems#81 so this issue can go back to its original purpose. |
Feature or enhancement
Proposal:
The datetime module has its own C-API which is enabled with
PyDateTime_IMPORT
. From the docs:My main concern is that the
PyDateTimeAPI
struct is a process-global value, but it exposes object pointers (which should always be per-interpreter). We have worked around this in 3.13+, but it would be better if we could make the objects per-interpreter.FTR, here are the objects exposed directly by
PyDateTimeAPI
:PyDateTime_DateType
PyDateTime_DateTimeType
PyDateTime_TimeType
PyDateTime_DeltaType
PyDateTime_TZInfoType
utc_timezone
(an instance ofPyDateTime_TimeZoneType
)exposed indirectly:
PyDateTime_TimeZoneType
In order to make these objects per-interpreter, it would require changes to the datetime C-API. 1 I expect we would leave
PyDateTime_IMPORT
alone. Instead, we'd need to update the macros in datetime.h to get the objects from the module associated with the current interpreter. 2Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Footnotes
These would be ABI-incompatible changes, which wouldn't be a problem unless the datetime C-API is part of the limited API). ↩
Anyone who is accessing the
PyDateTimeAPI
struct directly would have to change their code. It might make sense to provide a getter function/macro for each of the objects. ↩The text was updated successfully, but these errors were encountered: