From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 31 Mar 2026 11:35:49 +0000 (+0200) Subject: [3.14] gh-145563: Add thread-safety annotation for PyCapsule C-API (GH-146612) (... X-Git-Tag: v3.14.4~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d1515dc21c7dea433fe639c6c8ca249986a6a7e;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-145563: Add thread-safety annotation for PyCapsule C-API (GH-146612) (#146659) gh-145563: Add thread-safety annotation for PyCapsule C-API (GH-146612) (cherry picked from commit 67354b2925e28b3bcc6e5b52bf92cd5f4cc69d3c) Co-authored-by: Pieter Eendebak --- diff --git a/Doc/data/threadsafety.dat b/Doc/data/threadsafety.dat index afb053adf5c6..82edd1167ef1 100644 --- a/Doc/data/threadsafety.dat +++ b/Doc/data/threadsafety.dat @@ -123,4 +123,33 @@ PyByteArray_GET_SIZE:atomic: # Raw data - no locking; mutating it is unsafe if the bytearray object is shared between threads PyByteArray_AsString:compatible: -PyByteArray_AS_STRING:compatible: \ No newline at end of file +PyByteArray_AS_STRING:compatible: + +# Capsule objects (Doc/c-api/capsule.rst) + +# Type check - read ob_type pointer, always safe +PyCapsule_CheckExact:atomic: + +# Creation - pure allocation, no shared state +PyCapsule_New:atomic: + +# Validation - reads pointer and name fields; safe on distinct objects +PyCapsule_IsValid:distinct: + +# Getters - read struct fields; safe on distinct objects but +# concurrent access to the same capsule requires external synchronization +PyCapsule_GetPointer:distinct: +PyCapsule_GetName:distinct: +PyCapsule_GetDestructor:distinct: +PyCapsule_GetContext:distinct: + +# Setters - write struct fields; safe on distinct objects but +# concurrent access to the same capsule requires external synchronization +PyCapsule_SetPointer:distinct: +PyCapsule_SetName:distinct: +PyCapsule_SetDestructor:distinct: +PyCapsule_SetContext:distinct: + +# Import - looks up a capsule from a module attribute and +# calls PyCapsule_GetPointer; may call arbitrary code +PyCapsule_Import:compatible: