mirror of
https://github.com/python/cpython.git
synced 2025-10-28 17:13:08 +00:00
bpo-46541: Scan Fewer Files in generate_global_objects.py (gh-31364)
https://bugs.python.org/issue46541
This commit is contained in:
parent
6c89589486
commit
4d8a515d19
1 changed files with 19 additions and 15 deletions
|
|
@ -100,17 +100,21 @@ IDENTIFIERS = [
|
||||||
#######################################
|
#######################################
|
||||||
# helpers
|
# helpers
|
||||||
|
|
||||||
def iter_global_strings():
|
def iter_files():
|
||||||
id_regex = re.compile(r'\b_Py_ID\((\w+)\)')
|
for name in ('Modules', 'Objects', 'Parser', 'PC', 'Programs', 'Python'):
|
||||||
str_regex = re.compile(r'\b_Py_DECLARE_STR\((\w+), "(.*?)"\)')
|
root = os.path.join(ROOT, name)
|
||||||
for dirname, _, files in os.walk(ROOT):
|
for dirname, _, files in os.walk(root):
|
||||||
if os.path.relpath(dirname, ROOT).startswith('Include'):
|
|
||||||
continue
|
|
||||||
for name in files:
|
for name in files:
|
||||||
if not name.endswith(('.c', '.h')):
|
if not name.endswith(('.c', '.h')):
|
||||||
continue
|
continue
|
||||||
filename = os.path.join(dirname, name)
|
yield os.path.join(dirname, name)
|
||||||
with open(os.path.join(filename), encoding='utf-8') as infile:
|
|
||||||
|
|
||||||
|
def iter_global_strings():
|
||||||
|
id_regex = re.compile(r'\b_Py_ID\((\w+)\)')
|
||||||
|
str_regex = re.compile(r'\b_Py_DECLARE_STR\((\w+), "(.*?)"\)')
|
||||||
|
for filename in iter_files():
|
||||||
|
with open(filename, encoding='utf-8') as infile:
|
||||||
for lno, line in enumerate(infile, 1):
|
for lno, line in enumerate(infile, 1):
|
||||||
for m in id_regex.finditer(line):
|
for m in id_regex.finditer(line):
|
||||||
identifier, = m.groups()
|
identifier, = m.groups()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue