diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2019-09-12 15:59:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-12 15:59:38 (GMT) |
commit | 088b63ea7a8331a3e34bc93c3b873c60354b4fad (patch) | |
tree | 89a1c917ce44b8418d2427c58716f90d2db69121 /Tools | |
parent | 855df7f273c3988c72f01e51ba57091887ec38b2 (diff) | |
download | cpython-088b63ea7a8331a3e34bc93c3b873c60354b4fad.zip cpython-088b63ea7a8331a3e34bc93c3b873c60354b4fad.tar.gz cpython-088b63ea7a8331a3e34bc93c3b873c60354b4fad.tar.bz2 |
bpo-36876: Fix the globals checker tool. (gh-16058)
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/c-analyzer/c_globals/supported.py | 61 | ||||
-rw-r--r-- | Tools/c-analyzer/known.tsv | 8 |
2 files changed, 51 insertions, 18 deletions
diff --git a/Tools/c-analyzer/c_globals/supported.py b/Tools/c-analyzer/c_globals/supported.py index 4643e4e..d185daa 100644 --- a/Tools/c-analyzer/c_globals/supported.py +++ b/Tools/c-analyzer/c_globals/supported.py @@ -253,25 +253,50 @@ def _is_vartype_okay(vartype, ignoredtypes=None): return None +PYOBJECT_RE = re.compile(r''' + ^ + ( + # must start with "static " + static \s+ + ( + identifier + ) + \b + ) | + ( + # may start with "static " + ( static \s+ )? + ( + .* + ( + PyObject | + PyTypeObject | + _? Py \w+ Object | + _PyArg_Parser | + _Py_Identifier | + traceback_t | + PyAsyncGenASend | + _PyAsyncGenWrappedValue | + PyContext | + method_cache_entry + ) + \b + ) | + ( + ( + _Py_IDENTIFIER | + _Py_static_string + ) + [(] + ) + ) + ''', re.VERBOSE) + + def _is_object(vartype): - if re.match(r'.*\bPy\w*Object\b', vartype): - return True - if '_PyArg_Parser ' in vartype: - return True - if vartype.startswith(('_Py_IDENTIFIER(', 'static _Py_Identifier', - '_Py_static_string(')): - return True - if 'traceback_t' in vartype: - return True - if 'PyAsyncGenASend' in vartype: - return True - if '_PyAsyncGenWrappedValue' in vartype: - return True - if 'PyContext' in vartype: - return True - if 'method_cache_entry' in vartype: - return True - if vartype.startswith('static identifier '): + if 'PyDictKeysObject' in vartype: + return False + if PYOBJECT_RE.match(vartype): return True if vartype.endswith((' _Py_FalseStruct', ' _Py_TrueStruct')): return True diff --git a/Tools/c-analyzer/known.tsv b/Tools/c-analyzer/known.tsv index ce2afcb..db44080 100644 --- a/Tools/c-analyzer/known.tsv +++ b/Tools/c-analyzer/known.tsv @@ -787,6 +787,8 @@ Objects/genobject.c - _PyAsyncGenAThrow_Type variable PyTypeObject _PyAsyncGenAT Objects/genobject.c - PyAsyncGen_Type variable PyTypeObject PyAsyncGen_Type Objects/genobject.c - _PyAsyncGenWrappedValue_Type variable PyTypeObject _PyAsyncGenWrappedValue_Type Objects/typeobject.c - PyBaseObject_Type variable PyTypeObject PyBaseObject_Type +Modules/_blake2/blake2b_impl.c - PyBlake2_BLAKE2bType variable PyTypeObject PyBlake2_BLAKE2bType +Modules/_blake2/blake2s_impl.c - PyBlake2_BLAKE2sType variable PyTypeObject PyBlake2_BLAKE2sType Objects/boolobject.c - PyBool_Type variable PyTypeObject PyBool_Type Modules/_io/bufferedio.c - PyBufferedIOBase_Type variable PyTypeObject PyBufferedIOBase_Type Modules/_io/bufferedio.c - PyBufferedRandom_Type variable PyTypeObject PyBufferedRandom_Type @@ -972,6 +974,7 @@ Objects/exceptions.c - PyExc_Warning variable static PyTypeObject PyExc_Warning Objects/exceptions.c - _PyExc_ZeroDivisionError variable static PyTypeObject _PyExc_ZeroDivisionError Objects/exceptions.c - PyExc_ZeroDivisionError variable static PyTypeObject PyExc_ZeroDivisionError Objects/boolobject.c - _Py_FalseStruct variable static struct _longobject _Py_FalseStruct +Objects/tupleobject.c - _Py_fast_tuple_allocs variable Py_ssize_t _Py_fast_tuple_allocs Objects/stringlib/unicode_format.h - PyFieldNameIter_Type variable static PyTypeObject PyFieldNameIter_Type Modules/_io/fileio.c - PyFileIO_Type variable PyTypeObject PyFileIO_Type Python/preconfig.c - Py_FileSystemDefaultEncodeErrors variable const char *Py_FileSystemDefaultEncodeErrors @@ -1498,6 +1501,7 @@ Python/initconfig.c - Py_NoSiteFlag variable int Py_NoSiteFlag Objects/object.c - _Py_NotImplementedStruct variable PyObject _Py_NotImplementedStruct Objects/object.c - _PyNotImplemented_Type variable PyTypeObject _PyNotImplemented_Type Python/initconfig.c - Py_NoUserSiteDirectory variable int Py_NoUserSiteDirectory +Objects/bytesobject.c - _Py_null_strings variable Py_ssize_t _Py_null_strings Objects/obmalloc.c - _PyObject variable static PyMemAllocatorEx _PyObject Objects/obmalloc.c - _PyObject_Arena variable static PyObjectArenaAllocator _PyObject_Arena Objects/odictobject.c - PyODictItems_Type variable PyTypeObject PyODictItems_Type @@ -1506,6 +1510,7 @@ Objects/odictobject.c - PyODictKeys_Type variable PyTypeObject PyODictKeys_Type Objects/odictobject.c - PyODict_Type variable PyTypeObject PyODict_Type Objects/odictobject.c - PyODictValues_Type variable PyTypeObject PyODictValues_Type Python/fileutils.c - _Py_open_cloexec_works variable int _Py_open_cloexec_works +Objects/bytesobject.c - _Py_one_strings variable Py_ssize_t _Py_one_strings Python/initconfig.c - Py_OptimizeFlag variable int Py_OptimizeFlag Parser/myreadline.c - PyOS_InputHook variable int (*PyOS_InputHook)(void) Python/pylifecycle.c - _PyOS_mystrnicmp_hack variable int (*_PyOS_mystrnicmp_hack)(const char *, const char *, Py_ssize_t) @@ -1521,6 +1526,8 @@ Python/pathconfig.c - _Py_path_config variable _PyPathConfig _Py_path_config Objects/picklebufobject.c - PyPickleBuffer_Type variable PyTypeObject PyPickleBuffer_Type Objects/descrobject.c - PyProperty_Type variable PyTypeObject PyProperty_Type Python/initconfig.c - Py_QuietFlag variable int Py_QuietFlag +Objects.longobject.c - _Py_quick_int_allocs variable Py_ssize_t _Py_quick_int_allocs +Objects.longobject.c - _Py_quick_new_int_allocs variable Py_ssize_t _Py_quick_new_int_allocs Objects/rangeobject.c - PyRangeIter_Type variable PyTypeObject PyRangeIter_Type Objects/rangeobject.c - PyRange_Type variable PyTypeObject PyRange_Type Modules/_io/iobase.c - PyRawIOBase_Type variable PyTypeObject PyRawIOBase_Type @@ -1551,6 +1558,7 @@ Objects/obmalloc.c - _Py_tracemalloc_config variable struct _PyTraceMalloc_Confi Objects/boolobject.c - _Py_TrueStruct variable static struct _longobject _Py_TrueStruct Objects/tupleobject.c - PyTupleIter_Type variable PyTypeObject PyTupleIter_Type Objects/tupleobject.c - PyTuple_Type variable PyTypeObject PyTuple_Type +Objects/tupleobject.c - _Py_tuple_zero_allocs variable Py_ssize_t _Py_tuple_zero_allocs Objects/typeobject.c - PyType_Type variable PyTypeObject PyType_Type Python/initconfig.c - Py_UnbufferedStdioFlag variable int Py_UnbufferedStdioFlag Python/pylifecycle.c - _Py_UnhandledKeyboardInterrupt variable int _Py_UnhandledKeyboardInterrupt |