diff options
author | Peter Bierma <zintensitydev@gmail.com> | 2024-11-22 07:48:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-22 07:48:39 (GMT) |
commit | 89125e9f9f3d3099267ddaddfe72642e2af6495c (patch) | |
tree | b577057dbf06e37acc089fe4641247a9297b855e /Tools/c-analyzer/cpython/_analyzer.py | |
parent | 8c98ed846a7d7e50c4cf06f823d94737144dcf6a (diff) | |
download | cpython-89125e9f9f3d3099267ddaddfe72642e2af6495c.zip cpython-89125e9f9f3d3099267ddaddfe72642e2af6495c.tar.gz cpython-89125e9f9f3d3099267ddaddfe72642e2af6495c.tar.bz2 |
Allow local use of `static PyMutex` in the C analyzer (#127102)
Diffstat (limited to 'Tools/c-analyzer/cpython/_analyzer.py')
-rw-r--r-- | Tools/c-analyzer/cpython/_analyzer.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Tools/c-analyzer/cpython/_analyzer.py b/Tools/c-analyzer/cpython/_analyzer.py index f07fa8a..6204353 100644 --- a/Tools/c-analyzer/cpython/_analyzer.py +++ b/Tools/c-analyzer/cpython/_analyzer.py @@ -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:] |