You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pythongh-108240: Fix a reference cycle in _socket.CAPI capsule
_socket.CAPI capsule contains a strong reference to _socket.socket
type. The garbage collector cannot visit this reference and so cannot
create the reference cycle involving _socket.socket (a heap type
creates a reference cycle to inside, via MRO and methods). At Python,
_PyImport_ClearModules() sets _socket attributes to None which works
around the issue.
If the module is cleared from sys.modules manually,
_PyImport_ClearModules() cannot set _socket.CAPI to None and so the
issue cannot be worked around.
Change _socket.CAPI to use a borrowed reference instead of a strong
reference to allow clearing _socket.socket in this case.
Co-authored-by: Kirill Podoprigora <[email protected]>
0 commit comments