Skip to content

Commit

Permalink
pythongh-90110: Update the C-analyzer Tool (pythongh-99307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently authored and gvanrossum committed Nov 10, 2022
1 parent 873da31 commit e0ab5b8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Modules/zlibmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ ZlibDecompressor__new__(PyTypeObject *cls,
PyObject *kwargs)
{
static char *keywords[] = {"wbits", "zdict", NULL};
static char *format = "|iO:_ZlibDecompressor";
static const char * const format = "|iO:_ZlibDecompressor";
int wbits = MAX_WBITS;
PyObject *zdict = NULL;
zlibstate *state = PyType_GetModuleState(cls);
Expand Down
6 changes: 6 additions & 0 deletions Tools/c-analyzer/cpython/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def clean_lines(text):
# generated
Python/deepfreeze/*.c
Python/frozen_modules/*.h
Python/generated_cases.c.h
# not actually source
Python/bytecodes.c
# @end=conf@
''')
Expand Down Expand Up @@ -285,6 +289,7 @@ def clean_lines(text):

SAME = {
_abs('Include/*.h'): [_abs('Include/cpython/')],
_abs('Python/ceval.c'): ['Python/generated_cases.c.h'],
}

MAX_SIZES = {
Expand All @@ -311,6 +316,7 @@ def clean_lines(text):
_abs('Python/frozen_modules/*.h'): (20_000, 500),
_abs('Python/opcode_targets.h'): (10_000, 500),
_abs('Python/stdlib_module_names.h'): (5_000, 500),
_abs('Python/importlib.h'): (200_000, 5000),

# These large files are currently ignored (see above).
_abs('Modules/_ssl_data.h'): (80_000, 10_000),
Expand Down
91 changes: 2 additions & 89 deletions Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -304,20 +304,14 @@ Objects/sliceobject.c - _Py_EllipsisObject -
# manually cached PyUnicodeObject
Python/ast_unparse.c - _str_replace_inf -

# holds statically-initialized strings
Objects/typeobject.c - slotdefs -

# other
Objects/typeobject.c object___reduce_ex___impl objreduce -
Objects/unicodeobject.c - _string_module -
Objects/unicodeobject.c - interned -

#-----------------------
# other

# initialized once
Python/context.c - _token_missing -
Python/fileutils.c - _Py_open_cloexec_works -
Python/hamt.c - _empty_bitmap_node -
Python/hamt.c - _empty_hamt -

Expand Down Expand Up @@ -384,6 +378,7 @@ Python/perf_trampoline.c - perf_map_file -
Objects/unicodeobject.c - ucnhash_capi -
Parser/action_helpers.c _PyPegen_dummy_name cache -
Python/dtoa.c - p5s -
Python/fileutils.c - _Py_open_cloexec_works -
Python/fileutils.c - force_ascii -
Python/fileutils.c set_inheritable ioctl_works -
Python/import.c - import_lock -
Expand Down Expand Up @@ -511,6 +506,7 @@ Modules/_testcapi/vectorcall.c - MethodDescriptorNopGet_Type -
Modules/_testcapi/vectorcall.c - MethodDescriptor2_Type -
Modules/itertoolsmodule.c - _grouper_type -
Modules/itertoolsmodule.c - accumulate_type -
Modules/itertoolsmodule.c - batched_type -
Modules/itertoolsmodule.c - chain_type -
Modules/itertoolsmodule.c - combinations_type -
Modules/itertoolsmodule.c - compress_type -
Expand Down Expand Up @@ -701,89 +697,6 @@ Modules/xxmodule.c - ErrorObject -
#-----------------------
# cached - initialized once

# _Py_IDENTIFIER (global)
Modules/_asynciomodule.c - PyId___asyncio_running_event_loop__ -
Modules/_asynciomodule.c - PyId__asyncio_future_blocking -
Modules/_asynciomodule.c - PyId_add_done_callback -
Modules/_asynciomodule.c - PyId_call_soon -
Modules/_asynciomodule.c - PyId_cancel -
Modules/_asynciomodule.c - PyId_get_event_loop -
Modules/_asynciomodule.c - PyId_throw -
Modules/_datetimemodule.c - PyId_as_integer_ratio -
Modules/_datetimemodule.c - PyId_fromutc -
Modules/_datetimemodule.c - PyId_isoformat -
Modules/_datetimemodule.c - PyId_strftime -

# _Py_IDENTIFIER (local)
Modules/_asynciomodule.c FutureObj_finalize PyId_call_exception_handler -
Modules/_asynciomodule.c FutureObj_finalize PyId_exception -
Modules/_asynciomodule.c FutureObj_finalize PyId_future -
Modules/_asynciomodule.c FutureObj_finalize PyId_message -
Modules/_asynciomodule.c FutureObj_finalize PyId_source_traceback -
Modules/_asynciomodule.c FutureObj_get_state PyId_CANCELLED -
Modules/_asynciomodule.c FutureObj_get_state PyId_FINISHED -
Modules/_asynciomodule.c FutureObj_get_state PyId_PENDING -
Modules/_asynciomodule.c TaskObj_finalize PyId_call_exception_handler -
Modules/_asynciomodule.c TaskObj_finalize PyId_message -
Modules/_asynciomodule.c TaskObj_finalize PyId_source_traceback -
Modules/_asynciomodule.c TaskObj_finalize PyId_task -
Modules/_asynciomodule.c future_init PyId_get_debug -
Modules/_asynciomodule.c get_future_loop PyId__loop -
Modules/_asynciomodule.c get_future_loop PyId_get_loop -
Modules/_asynciomodule.c register_task PyId_add -
Modules/_asynciomodule.c unregister_task PyId_discard -
Modules/_ctypes/_ctypes.c CDataType_from_param PyId__as_parameter_ -
Modules/_ctypes/_ctypes.c PyCArrayType_new PyId__length_ -
Modules/_ctypes/_ctypes.c PyCArrayType_new PyId__type_ -
Modules/_ctypes/_ctypes.c PyCFuncPtr_set_restype PyId__check_retval_ -
Modules/_ctypes/_ctypes.c PyCPointerType_new PyId__type_ -
Modules/_ctypes/_ctypes.c PyCPointerType_set_type PyId__type_ -
Modules/_ctypes/_ctypes.c PyCSimpleType_from_param PyId__as_parameter_ -
Modules/_ctypes/_ctypes.c PyCSimpleType_new PyId__type_ -
Modules/_ctypes/_ctypes.c StructUnionType_new PyId__abstract_ -
Modules/_ctypes/_ctypes.c StructUnionType_new PyId__fields_ -
Modules/_ctypes/_ctypes.c _build_result PyId___ctypes_from_outparam__ -
Modules/_ctypes/_ctypes.c _init_pos_args PyId__fields_ -
Modules/_ctypes/_ctypes.c c_char_p_from_param PyId__as_parameter_ -
Modules/_ctypes/_ctypes.c c_void_p_from_param PyId__as_parameter_ -
Modules/_ctypes/_ctypes.c c_wchar_p_from_param PyId__as_parameter_ -
Modules/_ctypes/_ctypes.c converters_from_argtypes PyId_from_param -
Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__argtypes_ -
Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__check_retval_ -
Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__flags_ -
Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__restype_ -
Modules/_ctypes/callproc.c ConvParam PyId__as_parameter_ -
Modules/_ctypes/callproc.c unpickle PyId___new__ -
Modules/_ctypes/callproc.c unpickle PyId___setstate__ -
Modules/_ctypes/stgdict.c MakeAnonFields PyId__anonymous_ -
Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__pack_ -
Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__swappedbytes_ -
Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__use_broken_old_ctypes_structure_semantics_ -
Modules/_cursesmodule.c _curses_getwin PyId_read -
Modules/_cursesmodule.c _curses_window_putwin PyId_write -
Modules/_cursesmodule.c update_lines_cols PyId_COLS -
Modules/_cursesmodule.c update_lines_cols PyId_LINES -
Modules/_datetimemodule.c call_tzname PyId_tzname -
Modules/_datetimemodule.c date_strftime PyId_timetuple -
Modules/_datetimemodule.c date_today PyId_fromtimestamp -
Modules/_datetimemodule.c datetime_strptime PyId__strptime_datetime -
Modules/_datetimemodule.c make_Zreplacement PyId_replace -
Modules/_datetimemodule.c tzinfo_reduce PyId___getinitargs__ -
Modules/_elementtree.c _elementtree_Element_find_impl PyId_find -
Modules/_elementtree.c _elementtree_Element_findall_impl PyId_findall -
Modules/_elementtree.c _elementtree_Element_findtext_impl PyId_findtext -
Modules/_elementtree.c _elementtree_Element_iterfind_impl PyId_iterfind -
Modules/_elementtree.c expat_start_doctype_handler PyId_doctype -
Modules/_elementtree.c treebuilder_add_subelement PyId_append -
Modules/_elementtree.c treebuilder_flush_data PyId_tail -
Modules/_elementtree.c treebuilder_flush_data PyId_text -
Modules/_json.c _encoded_const PyId_false -
Modules/_json.c _encoded_const PyId_null -
Modules/_json.c _encoded_const PyId_true -
Modules/_json.c raise_errmsg PyId_JSONDecodeError -
Modules/_json.c raise_errmsg PyId_decoder -
Modules/ossaudiodev.c oss_exit PyId_close -

# manually cached PyUnicodeOjbect
Modules/_asynciomodule.c - context_kwname -
Modules/_ctypes/callproc.c _ctypes_get_errobj error_object_name -
Expand Down
5 changes: 5 additions & 0 deletions Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ Modules/_testcapimodule.c test_capsule buffer -
Modules/_testcapimodule.c test_empty_argparse kwlist -
Modules/_testcapimodule.c test_structmembers_new keywords -
Modules/_testcapimodule.c getargs_s_hash_int keywords -
Modules/_testcapimodule.c - g_dict_watch_events -
Modules/_testcapimodule.c - g_dict_watchers_installed -
Modules/_testcapimodule.c - g_type_modified_events -
Modules/_testcapimodule.c - g_type_watchers_installed -
Modules/_testimportmultiple.c - _barmodule -
Modules/_testimportmultiple.c - _foomodule -
Modules/_testimportmultiple.c - _testimportmultiple -
Expand Down Expand Up @@ -467,6 +471,7 @@ Objects/obmalloc.c - _PyObject -
Objects/obmalloc.c - usedpools -
Python/perf_trampoline.c - _Py_perfmap_callbacks -
Objects/typeobject.c - name_op -
Objects/typeobject.c - slotdefs -
Objects/unicodeobject.c - stripfuncnames -
Objects/unicodeobject.c - utf7_category -
Objects/unicodeobject.c unicode_decode_call_errorhandler_wchar argparse -
Expand Down

0 comments on commit e0ab5b8

Please sign in to comment.