Skip to content

Commit f1cfdd9

Browse files
committed
Split format_table_lines() & apply suggestions
1 parent 847bccc commit f1cfdd9

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

Tools/c-analyzer/cpython/_parser.py

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ def _abs(relfile):
1717
return os.path.join(REPO_ROOT, relfile)
1818

1919

20-
def format_table_lines(lines):
20+
def format_conf_lines(lines):
21+
"""Format conf entries for use in a TSV table."""
22+
return [_abs(entry) for entry in lines]
23+
24+
25+
def format_tsv_lines(lines):
2126
"""Format entries for use in a TSV table."""
2227
lines = ((_abs(first), *rest) for first, *rest in lines)
2328
lines = map('\t'.join, lines)
@@ -41,64 +46,64 @@ def format_table_lines(lines):
4146
'''
4247

4348
# XXX Handle these.
44-
EXCLUDED = format_table_lines([
45-
# OSX
46-
('Modules/_scproxy.c',), # SystemConfiguration/SystemConfiguration.h
49+
EXCLUDED = format_conf_lines([
50+
# macOS
51+
'Modules/_scproxy.c', # SystemConfiguration/SystemConfiguration.h
4752

4853
# Windows
49-
('Modules/_winapi.c',), # windows.h
50-
('Modules/expat/winconfig.h',),
51-
('Modules/overlapped.c',), # winsock.h
52-
('Python/dynload_win.c',), # windows.h
53-
('Python/thread_nt.h',),
54+
'Modules/_winapi.c', # windows.h
55+
'Modules/expat/winconfig.h',
56+
'Modules/overlapped.c', # winsock.h
57+
'Python/dynload_win.c', # windows.h
58+
'Python/thread_nt.h',
5459

5560
# other OS-dependent
56-
('Python/dynload_aix.c',), # sys/ldr.h
57-
('Python/dynload_dl.c',), # dl.h
58-
('Python/dynload_hpux.c',), # dl.h
59-
('Python/emscripten_signal.c',),
60-
('Python/emscripten_syscalls.c',),
61-
('Python/thread_pthread.h',),
62-
('Python/thread_pthread_stubs.h',),
61+
'Python/dynload_aix.c', # sys/ldr.h
62+
'Python/dynload_dl.c', # dl.h
63+
'Python/dynload_hpux.c', # dl.h
64+
'Python/emscripten_signal.c',
65+
'Python/emscripten_syscalls.c',
66+
'Python/thread_pthread.h',
67+
'Python/thread_pthread_stubs.h',
6368

6469
# only huge constants (safe but parsing is slow)
65-
('Modules/_ssl_data_*.h',),
66-
('Modules/cjkcodecs/mappings_*.h',),
67-
('Modules/unicodedata_db.h',),
68-
('Modules/unicodename_db.h',),
69-
('Objects/unicodetype_db.h',),
70+
'Modules/_ssl_data_*.h',
71+
'Modules/cjkcodecs/mappings_*.h',
72+
'Modules/unicodedata_db.h',
73+
'Modules/unicodename_db.h',
74+
'Objects/unicodetype_db.h',
7075

7176
# generated
72-
('Python/deepfreeze/*.c',),
73-
('Python/frozen_modules/*.h',),
74-
('Python/generated_cases.c.h',),
75-
('Python/executor_cases.c.h',),
76-
('Python/optimizer_cases.c.h',),
77+
'Python/deepfreeze/*.c',
78+
'Python/frozen_modules/*.h',
79+
'Python/generated_cases.c.h',
80+
'Python/executor_cases.c.h',
81+
'Python/optimizer_cases.c.h',
7782
# XXX: Throws errors if PY_VERSION_HEX is not mocked out
78-
('Modules/clinic/_testclinic_depr.c.h',),
83+
'Modules/clinic/_testclinic_depr.c.h',
7984

8085
# not actually source
81-
('Python/bytecodes.c',),
82-
('Python/optimizer_bytecodes.c',),
86+
'Python/bytecodes.c',
87+
'Python/optimizer_bytecodes.c',
8388

8489
# mimalloc
85-
('Objects/mimalloc/*.c',),
86-
('Include/internal/mimalloc/*.h',),
87-
('Include/internal/mimalloc/mimalloc/*.h',),
90+
'Objects/mimalloc/*.c',
91+
'Include/internal/mimalloc/*.h',
92+
'Include/internal/mimalloc/mimalloc/*.h',
8893
])
8994

9095
# XXX Fix the parser.
91-
EXCLUDED += format_table_lines([
96+
EXCLUDED += format_conf_lines([
9297
# The tool should be able to parse these...
9398

9499
# The problem with xmlparse.c is that something
95100
# has gone wrong where # we handle "maybe inline actual"
96101
# in Tools/c-analyzer/c_parser/parser/_global.py.
97-
('Modules/expat/internal.h',),
98-
('Modules/expat/xmlparse.c',),
102+
'Modules/expat/internal.h',
103+
'Modules/expat/xmlparse.c',
99104
])
100105

101-
INCL_DIRS = format_table_lines([
106+
INCL_DIRS = format_tsv_lines([
102107
# (glob, dirname)
103108

104109
('*', '.'),
@@ -127,7 +132,7 @@ def format_table_lines(lines):
127132

128133
])
129134

130-
INCLUDES = format_table_lines([
135+
INCLUDES = format_tsv_lines([
131136
# (glob, include)
132137

133138
('**/*.h', 'Python.h'),
@@ -161,7 +166,7 @@ def format_table_lines(lines):
161166
('Objects/stringlib/split.h', 'Objects/stringlib/fastsearch.h'),
162167
])
163168

164-
MACROS = format_table_lines([
169+
MACROS = format_tsv_lines([
165170
# (glob, name, value)
166171

167172
('Include/internal/*.h', 'Py_BUILD_CORE', '1'),
@@ -271,7 +276,7 @@ def format_table_lines(lines):
271276

272277
# others
273278
('Modules/_sre/sre_lib.h', 'LOCAL(type)', 'static inline type'),
274-
('Modules/_sre/sre_lib.h', 'SRE(F)', 'sre_ucs2_'), ##F
279+
('Modules/_sre/sre_lib.h', 'SRE(F)', 'sre_ucs2_##F'),
275280
('Objects/stringlib/codecs.h', 'STRINGLIB_IS_UNICODE', '1'),
276281
('Include/internal/pycore_crossinterp_data_registry.h', 'Py_CORE_CROSSINTERP_DATA_REGISTRY_H', '1'),
277282
])

0 commit comments

Comments
 (0)