Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Tools/c-analyzer/cpython/_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,26 @@ def _is_kwlist(decl):
vartype = ''.join(str(decl.vartype).split())
return vartype == 'char*[]'

def _is_local_static_mutex(decl):
if not hasattr(decl, "vartype"):
return False

if not hasattr(decl, "parent") or decl.parent is None:
# We only want to allow local variables
return False

vartype = decl.vartype
return (vartype.typespec == 'PyMutex') and (decl.storage == 'static')

def _has_other_supported_type(decl):
if hasattr(decl, 'file') and decl.file.filename.endswith('.c.h'):
assert 'clinic' in decl.file.filename, (decl,)
if decl.name == '_kwtuple':
return True
if _is_local_static_mutex(decl):
# GH-127081: Local static mutexes are used to
# wrap libc functions that aren't thread safe
return True
vartype = str(decl.vartype).split()
if vartype[0] == 'struct':
vartype = vartype[1:]
Expand Down
Loading