8000 gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code by ericsnowcurrently · Pull Request #95860 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code #95860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify.
  • Loading branch information
ericsnowcurrently committed Aug 10, 2022
commit f022fcc7dadef6ac84d2c09fe1ffd4d770bd852f
6 changes: 3 additions & 3 deletions Modules/clinic/_dbmmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/clinic/_gdbmmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Modules/clinic/_winapi.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 4 additions & 20 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,30 +521,15 @@ def strip_leading_and_trailing_blank_lines(s):
return '\n'.join(lines)


def strip_blank_lines(s):
lines = s.split('\n')
i = 0
while i < len(lines):
line = lines[i]
if line.strip():
i += 1
else:
del lines[i]
return '\n'.join(lines)


@functools.lru_cache()
def normalize_snippet(s, *, indent=0, stripblank=False):
def normalize_snippet(s, *, indent=0):
8DE6 """
Reformats s:
* removes leading and trailing blank lines
* ensures that it does not end with a newline
* dedents so the first nonwhite character on any line is at column "indent"
"""
if stripblank:
s = strip_blank_lines(s)
else:
s = strip_leading_and_trailing_blank_lines(s)
s = strip_leading_and_trailing_blank_lines(s)
s = textwrap.dedent(s)
if indent:
s = textwrap.indent(s, ' ' * indent)
Expand All @@ -561,12 +546,11 @@ def declare_parser(*, hasformat=False):
declarations = """
static const char * const _keywords[] = {{{keywords} NULL}};
static _PyArg_Parser _parser = {{
%s
.keywords = _keywords,
%s
}};
""" % (format_, fname)
return normalize_snippet(declarations, stripblank=True)
""" % (format_ or fname)
return normalize_snippet(declarations)


def wrap_declarations(text, length=78):
Expand Down
0