Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
Description
Bug report
Bug description:
datetime has a C API that we expose through aglobal variable. This does not work well under multiple threads. For example, ifPyDateTime_IMPORT fails in one thread while another thread is invoking the datetime C API, then that will setPyDateTimeAPI toNULL, leading toNULL pointer dereferences in the original thread.
This global variable also forces us to do some nasty hacks with subinterpreters because it exposes static types. I helped fix this a few months ago by making_datetime static (seethis thread), but there are probably other issues that I haven't found yet.
I think a bandaid fix would be to makePyDateTimeAPI a thread-local variable, but I suspect that would break a lot of things, nor would that fix this for subinterpreters. More generally, we could deprecatePyDateTime_IMPORT andPyDateTimeAPI in favor of letting users manage the pointer on their own, but I don't know if we can do this without too many code changes (see#141543 and#83785 for the docs side).
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Status