Skip to content

Commit

Permalink
pythongh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (pyt…
Browse files Browse the repository at this point in the history
…hon#119712)

When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.

(cherry picked from commit 7ca74a7)
  • Loading branch information
vstinner committed May 29, 2024
1 parent 7a9534f commit 0066ca6
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 19 deletions.
5 changes: 4 additions & 1 deletion Modules/_ctypes/clinic/_ctypes.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/_io/clinic/bufferedio.c.h

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

5 changes: 4 additions & 1 deletion Modules/_io/clinic/iobase.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/_io/clinic/textio.c.h

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

5 changes: 4 additions & 1 deletion Modules/clinic/_curses_panel.c.h

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

5 changes: 4 additions & 1 deletion 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/_elementtree.c.h

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

5 changes: 4 additions & 1 deletion Modules/clinic/_gdbmmodule.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/_pickle.c.h

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

5 changes: 4 additions & 1 deletion Modules/clinic/arraymodule.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/pyexpat.c.h

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

12 changes: 9 additions & 3 deletions Tools/clinic/libclinic/parse_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def declare_parser(
p for p in f.parameters.values()
if not p.is_positional_only() and not p.is_vararg()
])

condition = '#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)'
if limited_capi:
declarations = """
#define KWTUPLE NULL
Expand All @@ -50,6 +52,9 @@ def declare_parser(
# define KWTUPLE NULL
#endif
"""

codegen.add_include('pycore_runtime.h', '_Py_SINGLETON()',
condition=condition)
else:
# XXX Why do we not statically allocate the tuple
# for non-builtin modules?
Expand All @@ -73,9 +78,10 @@ def declare_parser(
#endif // !Py_BUILD_CORE
""" % num_keywords

condition = '#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)'
codegen.add_include('pycore_gc.h', 'PyGC_Head', condition=condition)
codegen.add_include('pycore_runtime.h', '_Py_ID()', condition=condition)
codegen.add_include('pycore_gc.h', 'PyGC_Head',
condition=condition)
codegen.add_include('pycore_runtime.h', '_Py_ID()',
condition=condition)

declarations += """
static const char * const _keywords[] = {{{keywords_c} NULL}};
Expand Down

0 comments on commit 0066ca6

Please sign in to comment.