Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Thedatetime C API is not thread-safe #141563

Open
@ZeroIntensity

Description

@ZeroIntensity

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).

cc@pganssle

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp