]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)
authorVictor Stinner <vstinner@python.org>
Wed, 29 May 2024 09:37:04 +0000 (11:37 +0200)
committerGitHub <noreply@github.com>
Wed, 29 May 2024 09:37:04 +0000 (11:37 +0200)
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.

12 files changed:
Modules/_ctypes/clinic/_ctypes.c.h
Modules/_io/clinic/bufferedio.c.h
Modules/_io/clinic/iobase.c.h
Modules/_io/clinic/textio.c.h
Modules/clinic/_curses_panel.c.h
Modules/clinic/_dbmmodule.c.h
Modules/clinic/_elementtree.c.h
Modules/clinic/_gdbmmodule.c.h
Modules/clinic/_pickle.c.h
Modules/clinic/arraymodule.c.h
Modules/clinic/pyexpat.c.h
Tools/clinic/libclinic/parse_args.py

index 98a84cc14f4386c8016fe263944e1b92062910d2..e1d5a17cbe7d680d7b22510b65d99e85f3cb040c 100644 (file)
@@ -2,6 +2,9 @@
 preserve
 [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_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);
 }
-/*[clinic end generated code: output=9c6539a3559e6088 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a90886be2a294ee6 input=a9049054013a1b77]*/
index 64eddcd314a803e7edd26212fa576c2ece42eaf2..708bef638887e2154e6da4a5999964a89371ebe8 100644 (file)
@@ -4,7 +4,7 @@ preserve
 
 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
 #  include "pycore_gc.h"          // PyGC_Head
-#  include "pycore_runtime.h"     // _Py_ID()
+#  include "pycore_runtime.h"     // _Py_SINGLETON()
 #endif
 #include "pycore_abstract.h"      // _PyNumber_Index()
 #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
@@ -1245,4 +1245,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=4249187a725a3b3e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8eead000083dc5fa input=a9049054013a1b77]*/
index bae80a265fab07546db49287a79b7eb21f228495..a35cac7dc0b8d7e16b4e199cb71e994473877be1 100644 (file)
@@ -2,6 +2,9 @@
 preserve
 [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_modsupport.h"    // _PyArg_UnpackKeywords()
 
@@ -438,4 +441,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
     return _io__RawIOBase_readall_impl(self);
 }
-/*[clinic end generated code: output=e7326fbefc52bfba input=a9049054013a1b77]*/
+/*[clinic end generated code: output=dab5e9323d191e32 input=a9049054013a1b77]*/
index f04ee729abc9edcad305d83af8352ab9bfd94f81..669e2aa637ebbfcc1cad9c80ef142c395b40d30e 100644 (file)
@@ -4,7 +4,7 @@ preserve
 
 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
 #  include "pycore_gc.h"          // PyGC_Head
-#  include "pycore_runtime.h"     // _Py_ID()
+#  include "pycore_runtime.h"     // _Py_SINGLETON()
 #endif
 #include "pycore_abstract.h"      // _Py_convert_optional_to_ssize_t()
 #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;
 }
-/*[clinic end generated code: output=93a5a91a22100a28 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=04cb7c67791a9ec1 input=a9049054013a1b77]*/
index 457f71370afda9f86eac55553bf8f29c5e87dd90..c8788c461f745ca3661ee84af1bddd4fc5a49332 100644 (file)
@@ -2,6 +2,9 @@
 preserve
 [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()
 
 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);
 }
-/*[clinic end generated code: output=7bac14e9a1194c87 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=18dc5571174c7189 input=a9049054013a1b77]*/
index d06271e18a49b2550b3c8e8f65e01fc2ac9f95fc..4379b433db3738559db8d6fdb7b77011563b8e02 100644 (file)
@@ -2,6 +2,9 @@
 preserve
 [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()
 
 PyDoc_STRVAR(_dbm_dbm_close__doc__,
@@ -218,4 +221,4 @@ skip_optional:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=743ce0cea116747e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f7d9a87d80a64278 input=a9049054013a1b77]*/
index 10b2dd1c15f7fd6acacdcf7b075dce1d9369ff0b..1a5a820d1f00b528d443047b6ba7f76e5db76055 100644 (file)
@@ -4,7 +4,7 @@ preserve
 
 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
 #  include "pycore_gc.h"          // PyGC_Head
-#  include "pycore_runtime.h"     // _Py_ID()
+#  include "pycore_runtime.h"     // _Py_SINGLETON()
 #endif
 #include "pycore_abstract.h"      // _PyNumber_Index()
 #include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
@@ -1236,4 +1236,4 @@ skip_optional:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=aed9f53eeb0404e0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=bd28eba33d9c1f25 input=a9049054013a1b77]*/
index 626e4678809d4f56e6fa438931ad81abf01fedc9..bbf4365114c0aa67cfa3f979127749b1678f6859 100644 (file)
@@ -2,6 +2,9 @@
 preserve
 [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()
 
 PyDoc_STRVAR(_gdbm_gdbm_get__doc__,
@@ -340,4 +343,4 @@ skip_optional:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=6b4c19905ac9967d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=07bdeb4a8ecb328e input=a9049054013a1b77]*/
index 5a6ae7be6b6ea7719bf6950795af3bd6fa2d19d2..693c7d59e9d7a61a2a9bf411b066900659a6c5d2 100644 (file)
@@ -4,7 +4,7 @@ preserve
 
 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
 #  include "pycore_gc.h"          // PyGC_Head
-#  include "pycore_runtime.h"     // _Py_ID()
+#  include "pycore_runtime.h"     // _Py_SINGLETON()
 #endif
 #include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
 
@@ -1077,4 +1077,4 @@ skip_optional_kwonly:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=bd63c85a8737b0aa input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c7dd60d20ee4895f input=a9049054013a1b77]*/
index 8427f92de0d2e3247779fb8b193b8d933d20fae8..2ed7eaa6abf7af6b74cefd7808fd6ee1a7710b25 100644 (file)
@@ -2,6 +2,9 @@
 preserve
 [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_modsupport.h"    // _PyArg_CheckPositional()
 
@@ -688,4 +691,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
 
 #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF    \
     {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=9a3276ffd499c796 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ecd63acd7924c223 input=a9049054013a1b77]*/
index e23c910d0ac6619197baf13d5029e775c9df4c52..682d8481a2a2f4f9047f7ac03516242e11eb53bb 100644 (file)
@@ -4,7 +4,7 @@ preserve
 
 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
 #  include "pycore_gc.h"          // PyGC_Head
-#  include "pycore_runtime.h"     // _Py_ID()
+#  include "pycore_runtime.h"     // _Py_SINGLETON()
 #endif
 #include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
 
@@ -545,4 +545,4 @@ exit:
 #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
     #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
 #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
-/*[clinic end generated code: output=51874bfaf4992ba2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9f1e9a7192d29976 input=a9049054013a1b77]*/
index 7ac88bd0458b82d79a984224b7e7e97b99ce11d5..0f67901dd8609abb8438e1062de82f6182642116 100644 (file)
@@ -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
@@ -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?
@@ -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}};