https://github.com/python/cpython/commit/3d4e533be515767e7beae0c4ad55bfad02c23c1b
commit: 3d4e533be515767e7beae0c4ad55bfad02c23c1b
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2024-07-03T18:29:00Z
summary:

[3.13] gh-112136: Restore removed _PyArg_Parser (GH-121262) (#121344)

gh-112136: Restore removed _PyArg_Parser (GH-121262)

Restore the private _PyArg_Parser structure and the private
_PyArg_ParseTupleAndKeywordsFast() function, previously removed
in Python 3.13 alpha 1.

Recreate Include/cpython/modsupport.h header file.
(cherry picked from commit f8373db153920b890c2e2dd8def249e8df63bcc6)

Co-authored-by: Victor Stinner <[email protected]>

files:
A Include/cpython/modsupport.h
A Misc/NEWS.d/next/C API/2024-07-02-11-03-40.gh-issue-112136.f3fiY8.rst
M Include/internal/pycore_lock.h
M Include/internal/pycore_modsupport.h
M Include/modsupport.h
M Makefile.pre.in
M PCbuild/pythoncore.vcxproj
M PCbuild/pythoncore.vcxproj.filters

diff --git a/Include/cpython/modsupport.h b/Include/cpython/modsupport.h
new file mode 100644
index 00000000000000..d3b88f58c82ca3
--- /dev/null
+++ b/Include/cpython/modsupport.h
@@ -0,0 +1,26 @@
+#ifndef Py_CPYTHON_MODSUPPORT_H
+#  error "this header file must not be included directly"
+#endif
+
+// A data structure that can be used to run initialization code once in a
+// thread-safe manner. The C++11 equivalent is std::call_once.
+typedef struct {
+    uint8_t v;
+} _PyOnceFlag;
+
+typedef struct _PyArg_Parser {
+    const char *format;
+    const char * const *keywords;
+    const char *fname;
+    const char *custom_msg;
+    _PyOnceFlag once;       /* atomic one-time initialization flag */
+    int is_kwtuple_owned;   /* does this parser own the kwtuple object? */
+    int pos;                /* number of positional-only arguments */
+    int min;                /* minimal number of arguments */
+    int max;                /* maximal number of positional arguments */
+    PyObject *kwtuple;      /* tuple of keyword parameter names */
+    struct _PyArg_Parser *next;
+} _PyArg_Parser;
+
+PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
+                                                 struct _PyArg_Parser *, ...);
diff --git a/Include/internal/pycore_lock.h b/Include/internal/pycore_lock.h
index 80d609897b4f0c..e6930cc8eecb36 100644
--- a/Include/internal/pycore_lock.h
+++ b/Include/internal/pycore_lock.h
@@ -128,12 +128,6 @@ _PyRawMutex_Unlock(_PyRawMutex *m)
     _PyRawMutex_UnlockSlow(m);
 }
 
-// A data structure that can be used to run initialization code once in a
-// thread-safe manner. The C++11 equivalent is std::call_once.
-typedef struct {
-    uint8_t v;
-} _PyOnceFlag;
-
 // Type signature for one-time initialization functions. The function should
 // return 0 on success and -1 on failure.
 typedef int _Py_once_fn_t(void *arg);
diff --git a/Include/internal/pycore_modsupport.h 
b/Include/internal/pycore_modsupport.h
index 3d3cd6722528e9..11fde814875938 100644
--- a/Include/internal/pycore_modsupport.h
+++ b/Include/internal/pycore_modsupport.h
@@ -67,24 +67,6 @@ PyAPI_FUNC(void) _PyArg_BadArgument(
 
 // --- _PyArg_Parser API ---------------------------------------------------
 
-typedef struct _PyArg_Parser {
-    const char *format;
-    const char * const *keywords;
-    const char *fname;
-    const char *custom_msg;
-    _PyOnceFlag once;       /* atomic one-time initialization flag */
-    int is_kwtuple_owned;   /* does this parser own the kwtuple object? */
-    int pos;                /* number of positional-only arguments */
-    int min;                /* minimal number of arguments */
-    int max;                /* maximal number of positional arguments */
-    PyObject *kwtuple;      /* tuple of keyword parameter names */
-    struct _PyArg_Parser *next;
-} _PyArg_Parser;
-
-// Export for '_testclinic' shared extension
-PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
-                                                 struct _PyArg_Parser *, ...);
-
 // Export for '_dbm' shared extension
 PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
     PyObject *const *args,
diff --git a/Include/modsupport.h b/Include/modsupport.h
index ea4c0fce9f4562..af995f567b004c 100644
--- a/Include/modsupport.h
+++ b/Include/modsupport.h
@@ -134,6 +134,12 @@ PyAPI_FUNC(PyObject *) 
PyModule_FromDefAndSpec2(PyModuleDef *def,
 
 #endif /* New in 3.5 */
 
+#ifndef Py_LIMITED_API
+#  define Py_CPYTHON_MODSUPPORT_H
+#  include "cpython/modsupport.h"
+#  undef Py_CPYTHON_MODSUPPORT_H
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 9900560d31255a..0009374a84f07a 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1114,6 +1114,7 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/cpython/longobject.h \
                $(srcdir)/Include/cpython/memoryobject.h \
                $(srcdir)/Include/cpython/methodobject.h \
+               $(srcdir)/Include/cpython/modsupport.h \
                $(srcdir)/Include/cpython/monitoring.h \
                $(srcdir)/Include/cpython/object.h \
                $(srcdir)/Include/cpython/objimpl.h \
diff --git a/Misc/NEWS.d/next/C 
API/2024-07-02-11-03-40.gh-issue-112136.f3fiY8.rst b/Misc/NEWS.d/next/C 
API/2024-07-02-11-03-40.gh-issue-112136.f3fiY8.rst
new file mode 100644
index 00000000000000..a240b4e852c4d1
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2024-07-02-11-03-40.gh-issue-112136.f3fiY8.rst     
@@ -0,0 +1,3 @@
+Restore the private ``_PyArg_Parser`` structure and the private
+``_PyArg_ParseTupleAndKeywordsFast()`` function, previously removed in Python
+3.13 alpha 1. Patch by Victor Stinner.
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 33ab50fb8c4b6c..70212903c83781 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -163,6 +163,7 @@
     <ClInclude Include="..\Include\cpython\longobject.h" />
     <ClInclude Include="..\Include\cpython\memoryobject.h" />
     <ClInclude Include="..\Include\cpython\methodobject.h" />
+    <ClInclude Include="..\Include\cpython\modsupport.h" />
     <ClInclude Include="..\Include\cpython\object.h" />
     <ClInclude Include="..\Include\cpython\objimpl.h" />
     <ClInclude Include="..\Include\cpython\odictobject.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters 
b/PCbuild/pythoncore.vcxproj.filters
index 828f14db34e4a8..3eed5a9465bca4 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -429,6 +429,9 @@
     <ClInclude Include="..\Include\cpython\methodobject.h">
       <Filter>Include\cpython</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\cpython\modsupport.h">
+      <Filter>Include\cpython</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\cpython\objimpl.h">
       <Filter>Include\cpython</Filter>
     </ClInclude>

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to