https://github.com/python/cpython/commit/89125e9f9f3d3099267ddaddfe72642e2af6495c
commit: 89125e9f9f3d3099267ddaddfe72642e2af6495c
branch: main
author: Peter Bierma <[email protected]>
committer: vstinner <[email protected]>
date: 2024-11-22T08:48:39+01:00
summary:
Allow local use of `static PyMutex` in the C analyzer (#127102)
files:
M Tools/c-analyzer/cpython/_analyzer.py
M Tools/c-analyzer/cpython/ignored.tsv
diff --git a/Tools/c-analyzer/cpython/_analyzer.py
b/Tools/c-analyzer/cpython/_analyzer.py
index f07fa8af495e17..6204353e9bd26a 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:]
diff --git a/Tools/c-analyzer/cpython/ignored.tsv
b/Tools/c-analyzer/cpython/ignored.tsv
index 4327a111eedbaf..686f3935d91bda 100644
--- a/Tools/c-analyzer/cpython/ignored.tsv
+++ b/Tools/c-analyzer/cpython/ignored.tsv
@@ -739,7 +739,6 @@ Modules/expat/xmlrole.c - declClose -
Modules/expat/xmlrole.c - error -
## other
-Modules/grpmodule.c grp_getgrall_impl getgrall_mutex -
Modules/_io/_iomodule.c - _PyIO_Module -
Modules/_sqlite/module.c - _sqlite3module -
Modules/clinic/md5module.c.h _md5_md5 _keywords -
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]