8000 gh-112136: Restore removed _PyArg_Parser · vstinner/cpython@c6703e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6703e5

Browse files
committed
pythongh-112136: Restore removed _PyArg_Parser
Restore removed private _PyArg_Parser structure and private _PyArg_ParseTupleAndKeywordsFast() function. Recreate Include/cpython/modsupport.h header file.
1 parent b505334 commit c6703e5

File tree

7 files changed

+33
-18
lines changed

7 files changed

+33
-18
lines changed

Include/cpython/modsupport.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef Py_CPYTHON_MODSUPPORT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
typedef struct _PyArg_Parser {
6+
const char *format;
7+
const char * const *keywords;
8+
const char *fname;
9+
const char *custom_msg;
10+
_PyOnceFlag once; /* atomic one-time initialization flag */
11+
int is_kwtuple_owned; /* does this parser own the kwtuple object? */
12+
int pos; /* number of positional-only arguments */
13+
int min; /* minimal number of arguments */
14+
int max; /* maximal number of positional arguments */
15+
PyObject *kwtuple; /* tuple of keyword parameter names */
16+
struct _PyArg_Parser *next;
17+
} _PyArg_Parser;
18+
19+
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
20+
struct _PyArg_Parser *, ...);

Include/internal/pycore_modsupport.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,6 @@ PyAPI_FUNC(void) _PyArg_BadArgument(
6767

6868
// --- _PyArg_Parser API ---------------------------------------------------
6969

70-
typedef struct _PyArg_Parser {
71-
const char *format;
72-
const char * const *keywords;
73-
const char *fname;
74-
const char *custom_msg;
75-
_PyOnceFlag once; /* atomic one-time initialization flag */
76-
int is_kwtuple_owned; /* does this parser own the kwtuple object? */
77-
int pos; /* number of positional-only arguments */
78-
int min; /* minimal number of arguments */
79-
int max; /* maximal number of positional arguments */
80-
PyObject *kwtuple; /* tuple of keyword parameter names */
81-
struct _PyArg_Parser *next;
82-
} _PyArg_Parser;
83-
84-
// Export for '_testclinic' shared extension
85-
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
86-
struct _PyArg_Parser *, ...);
87-
8870
// Export for '_dbm' shared extension
8971
PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
9072
PyObject *const *args,

Include/modsupport.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def,
134134

135135
#endif /* New in 3.5 */
136136

137+
#ifndef Py_LIMITED_API
138+
# define Py_CPYTHON_MODSUPPORT_H
139+
# include "cpython/modsupport.h"
140+
# undef Py_CPYTHON_MODSUPPORT_H
141+
#endif
142+
137143
#ifdef __cplusplus
138144
}
139145
#endif

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ PYTHON_HEADERS= \
10961096
$(srcdir)/Include/cpython/longobject.h \
10971097
$(srcdir)/Include/cpython/memoryobject.h \
10981098
$(srcdir)/Include/cpython/methodobject.h \
1099+
$(srcdir)/Include/cpython/modsupport.h \
10991100
$(srcdir)/Include/cpython/monitoring.h \
11001101
$(srcdir)/Include/cpython/object.h \
11011102
$(srcdir)/Include/cpython/objimpl.h \
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Restore removed private ``_PyArg_Parser`` structure and private
2+
``_PyArg_ParseTupleAndKeywordsFast()`` function. Patch by Victor Stinner.

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
<ClInclude Include="..\Include\cpython\longobject.h" />
161161
<ClInclude Include="..\Include\cpython\memoryobject.h" />
162162
<ClInclude Include="..\Include\cpython\methodobject.h" />
163+
<ClInclude Include="..\Include\cpython\modsupport.h" />
163164
<ClInclude Include="..\Include\cpython\object.h" />
164165
<ClInclude Include="..\Include\cpython\objimpl.h" />
165166
<ClInclude Include="..\Include\cpython\odictobject.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@
423423
<ClInclude Include="..\Include\cpython\methodobject.h">
424424
<Filter>Include\cpython</Filter>
425425
</ClInclude>
426+
<ClInclude Include="..\Include\cpython\modsupport.h">
427+
<Filter>Include\cpython</Filter>
428+
</ClInclude>
426429
<ClInclude Include="..\Include\cpython\objimpl.h">
427430
<Filter>Include\cpython</Filter>
428431
</ClInclude>

0 commit comments

Comments
 (0)
0