[3.13] gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712) (#119716)

gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#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 7ca74a760a)
This commit is contained in:
Victor Stinner 2024-05-29 12:32:00 +02:00 committed by GitHub
parent 7a9534f595
commit 48c7776883
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 43 additions and 19 deletions

View File

@ -2,6 +2,9 @@
preserve preserve
[clinic start generated code]*/ [clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif
#include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
@ -607,4 +610,4 @@ Simple_from_outparm(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py
} }
return Simple_from_outparm_impl(self, cls); return Simple_from_outparm_impl(self, cls);
} }
/*[clinic end generated code: output=9c6539a3559e6088 input=a9049054013a1b77]*/ /*[clinic end generated code: output=a90886be2a294ee6 input=a9049054013a1b77]*/

View File

@ -4,7 +4,7 @@ preserve
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h" // PyGC_Head # include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID() # include "pycore_runtime.h" // _Py_SINGLETON()
#endif #endif
#include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
@ -1245,4 +1245,4 @@ skip_optional_pos:
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=4249187a725a3b3e input=a9049054013a1b77]*/ /*[clinic end generated code: output=8eead000083dc5fa input=a9049054013a1b77]*/

View File

@ -2,6 +2,9 @@
preserve preserve
[clinic start generated code]*/ [clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif
#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
@ -438,4 +441,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{ {
return _io__RawIOBase_readall_impl(self); return _io__RawIOBase_readall_impl(self);
} }
/*[clinic end generated code: output=e7326fbefc52bfba input=a9049054013a1b77]*/ /*[clinic end generated code: output=dab5e9323d191e32 input=a9049054013a1b77]*/

View File

@ -4,7 +4,7 @@ preserve
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h" // PyGC_Head # include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID() # include "pycore_runtime.h" // _Py_SINGLETON()
#endif #endif
#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
@ -1292,4 +1292,4 @@ _io_TextIOWrapper__CHUNK_SIZE_set(textio *self, PyObject *value, void *Py_UNUSED
return return_value; return return_value;
} }
/*[clinic end generated code: output=93a5a91a22100a28 input=a9049054013a1b77]*/ /*[clinic end generated code: output=04cb7c67791a9ec1 input=a9049054013a1b77]*/

View File

@ -2,6 +2,9 @@
preserve preserve
[clinic start generated code]*/ [clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, PyDoc_STRVAR(_curses_panel_panel_bottom__doc__,
@ -418,4 +421,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored))
{ {
return _curses_panel_update_panels_impl(module); return _curses_panel_update_panels_impl(module);
} }
/*[clinic end generated code: output=7bac14e9a1194c87 input=a9049054013a1b77]*/ /*[clinic end generated code: output=18dc5571174c7189 input=a9049054013a1b77]*/

View File

@ -2,6 +2,9 @@
preserve preserve
[clinic start generated code]*/ [clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
PyDoc_STRVAR(_dbm_dbm_close__doc__, PyDoc_STRVAR(_dbm_dbm_close__doc__,
@ -218,4 +221,4 @@ skip_optional:
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=743ce0cea116747e input=a9049054013a1b77]*/ /*[clinic end generated code: output=f7d9a87d80a64278 input=a9049054013a1b77]*/

View File

@ -4,7 +4,7 @@ preserve
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h" // PyGC_Head # include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID() # include "pycore_runtime.h" // _Py_SINGLETON()
#endif #endif
#include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
@ -1236,4 +1236,4 @@ skip_optional:
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=aed9f53eeb0404e0 input=a9049054013a1b77]*/ /*[clinic end generated code: output=bd28eba33d9c1f25 input=a9049054013a1b77]*/

View File

@ -2,6 +2,9 @@
preserve preserve
[clinic start generated code]*/ [clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif
#include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_modsupport.h" // _PyArg_CheckPositional()
PyDoc_STRVAR(_gdbm_gdbm_get__doc__, PyDoc_STRVAR(_gdbm_gdbm_get__doc__,
@ -340,4 +343,4 @@ skip_optional:
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=6b4c19905ac9967d input=a9049054013a1b77]*/ /*[clinic end generated code: output=07bdeb4a8ecb328e input=a9049054013a1b77]*/

View File

@ -4,7 +4,7 @@ preserve
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h" // PyGC_Head # include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID() # include "pycore_runtime.h" // _Py_SINGLETON()
#endif #endif
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
@ -1077,4 +1077,4 @@ skip_optional_kwonly:
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=bd63c85a8737b0aa input=a9049054013a1b77]*/ /*[clinic end generated code: output=c7dd60d20ee4895f input=a9049054013a1b77]*/

View File

@ -2,6 +2,9 @@
preserve preserve
[clinic start generated code]*/ [clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif
#include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_modsupport.h" // _PyArg_CheckPositional()
@ -685,4 +688,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \ #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__}, {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
/*[clinic end generated code: output=52c55d9b1d026c1c input=a9049054013a1b77]*/ /*[clinic end generated code: output=f675e0d433ae34b6 input=a9049054013a1b77]*/

View File

@ -4,7 +4,7 @@ preserve
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h" // PyGC_Head # include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID() # include "pycore_runtime.h" // _Py_SINGLETON()
#endif #endif
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
@ -545,4 +545,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
/*[clinic end generated code: output=892e48e41f9b6e4b input=a9049054013a1b77]*/ /*[clinic end generated code: output=729eafd7abf72a57 input=a9049054013a1b77]*/

View File

@ -38,6 +38,8 @@ def declare_parser(
p for p in f.parameters.values() p for p in f.parameters.values()
if not p.is_positional_only() and not p.is_vararg() 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: if limited_capi:
declarations = """ declarations = """
#define KWTUPLE NULL #define KWTUPLE NULL
@ -50,6 +52,9 @@ def declare_parser(
# define KWTUPLE NULL # define KWTUPLE NULL
#endif #endif
""" """
codegen.add_include('pycore_runtime.h', '_Py_SINGLETON()',
condition=condition)
else: else:
# XXX Why do we not statically allocate the tuple # XXX Why do we not statically allocate the tuple
# for non-builtin modules? # for non-builtin modules?
@ -73,9 +78,10 @@ def declare_parser(
#endif // !Py_BUILD_CORE #endif // !Py_BUILD_CORE
""" % num_keywords """ % num_keywords
condition = '#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)' codegen.add_include('pycore_gc.h', 'PyGC_Head',
codegen.add_include('pycore_gc.h', 'PyGC_Head', condition=condition) condition=condition)
codegen.add_include('pycore_runtime.h', '_Py_ID()', condition=condition) codegen.add_include('pycore_runtime.h', '_Py_ID()',
condition=condition)
declarations += """ declarations += """
static const char * const _keywords[] = {{{keywords_c} NULL}}; static const char * const _keywords[] = {{{keywords_c} NULL}};