gh-106560: Fix redundant declarations in Python/frozen.c (#112612)

Avoid duplicated declarations of "extern" functions in
Python/frozen.c.

Compiler warnings seen by building Python with gcc -Wredundant-decls.
This commit is contained in:
Victor Stinner 2023-12-03 12:18:24 +01:00 committed by GitHub
parent 1f2a676785
commit d9e444dbb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View file

@ -468,6 +468,17 @@ def replace_block(lines, start_marker, end_marker, replacements, file):
return lines[:start_pos + 1] + replacements + lines[end_pos:]
class UniqueList(list):
def __init__(self):
self._seen = set()
def append(self, item):
if item in self._seen:
return
super().append(item)
self._seen.add(item)
def regen_frozen(modules):
headerlines = []
parentdir = os.path.dirname(FROZEN_FILE)
@ -477,7 +488,7 @@ def regen_frozen(modules):
header = relpath_for_posix_display(src.frozenfile, parentdir)
headerlines.append(f'#include "{header}"')
externlines = []
externlines = UniqueList()
bootstraplines = []
stdliblines = []
testlines = []