Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe5e8a0

Browse files
authored
gh-110964: Remove private _PyArg functions (#110966)
Move the following private functions and structures topycore_modsupport.h internal C API:* _PyArg_BadArgument()* _PyArg_CheckPositional()* _PyArg_NoKeywords()* _PyArg_NoPositional()* _PyArg_ParseStack()* _PyArg_ParseStackAndKeywords()* _PyArg_Parser structure* _PyArg_UnpackKeywords()* _PyArg_UnpackKeywordsWithVararg()* _PyArg_UnpackStack()* _Py_ANY_VARARGS()Changes:* Python/getargs.h now includes pycore_modsupport.h to export functions.* clinic.py now adds pycore_modsupport.h when one of these functions is used.* Add pycore_modsupport.h includes when a C extension uses one of these functions.* Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog* _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple().* _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c.* Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file.* Fix mypy clinic.py
1 parent054f496 commitbe5e8a0

File tree

166 files changed

+510
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+510
-228
lines changed

‎Include/cpython/modsupport.h

Lines changed: 0 additions & 73 deletions
This file was deleted.

‎Include/internal/pycore_modsupport.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ extern int _PyArg_NoKwnames(const char *funcname, PyObject *kwnames);
1313
#define_PyArg_NoKwnames(funcname,kwnames) \
1414
((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames)))
1515

16+
// Export for '_bz2' shared extension
17+
PyAPI_FUNC(int)_PyArg_NoPositional(constchar*funcname,PyObject*args);
18+
#define_PyArg_NoPositional(funcname,args) \
19+
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
20+
21+
// Export for '_asyncio' shared extension
22+
PyAPI_FUNC(int)_PyArg_NoKeywords(constchar*funcname,PyObject*kwargs);
23+
#define_PyArg_NoKeywords(funcname,kwargs) \
24+
((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs)))
25+
26+
// Export for 'zlib' shared extension
27+
PyAPI_FUNC(int)_PyArg_CheckPositional(constchar*,Py_ssize_t,
28+
Py_ssize_t,Py_ssize_t);
29+
#define_Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX)
30+
#define_PyArg_CheckPositional(funcname,nargs,min,max) \
31+
((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \
32+
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
33+
1634
externPyObject**_Py_VaBuildStack(
1735
PyObject**small_stack,
1836
Py_ssize_tsmall_stack_len,
@@ -22,6 +40,80 @@ extern PyObject ** _Py_VaBuildStack(
2240

2341
externPyObject*_PyModule_CreateInitialized(PyModuleDef*,intapiver);
2442

43+
// Export for '_curses' shared extension
44+
PyAPI_FUNC(int)_PyArg_ParseStack(
45+
PyObject*const*args,
46+
Py_ssize_tnargs,
47+
constchar*format,
48+
...);
49+
50+
externint_PyArg_UnpackStack(
51+
PyObject*const*args,
52+
Py_ssize_tnargs,
53+
constchar*name,
54+
Py_ssize_tmin,
55+
Py_ssize_tmax,
56+
...);
57+
58+
// Export for '_heapq' shared extension
59+
PyAPI_FUNC(void)_PyArg_BadArgument(
60+
constchar*fname,
61+
constchar*displayname,
62+
constchar*expected,
63+
PyObject*arg);
64+
65+
// --- _PyArg_Parser API ---------------------------------------------------
66+
67+
typedefstruct_PyArg_Parser {
68+
intinitialized;
69+
constchar*format;
70+
constchar*const*keywords;
71+
constchar*fname;
72+
constchar*custom_msg;
73+
intpos;/* number of positional-only arguments */
74+
intmin;/* minimal number of arguments */
75+
intmax;/* maximal number of positional arguments */
76+
PyObject*kwtuple;/* tuple of keyword parameter names */
77+
struct_PyArg_Parser*next;
78+
}_PyArg_Parser;
79+
80+
// Export for '_testclinic' shared extension
81+
PyAPI_FUNC(int)_PyArg_ParseTupleAndKeywordsFast(PyObject*,PyObject*,
82+
struct_PyArg_Parser*, ...);
83+
84+
// Export for '_dbm' shared extension
85+
PyAPI_FUNC(int)_PyArg_ParseStackAndKeywords(
86+
PyObject*const*args,
87+
Py_ssize_tnargs,
88+
PyObject*kwnames,
89+
struct_PyArg_Parser*,
90+
...);
91+
92+
// Export for 'math' shared extension
93+
PyAPI_FUNC(PyObject*const*)_PyArg_UnpackKeywords(
94+
PyObject*const*args,
95+
Py_ssize_tnargs,
96+
PyObject*kwargs,
97+
PyObject*kwnames,
98+
struct_PyArg_Parser*parser,
99+
intminpos,
100+
intmaxpos,
101+
intminkw,
102+
PyObject**buf);
103+
#define_PyArg_UnpackKeywords(args,nargs,kwargs,kwnames,parser,minpos,maxpos,minkw,buf) \
104+
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
105+
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \
106+
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
107+
(minpos), (maxpos), (minkw), (buf)))
108+
109+
// Export for '_testclinic' shared extension
110+
PyAPI_FUNC(PyObject*const*)_PyArg_UnpackKeywordsWithVararg(
111+
PyObject*const*args,Py_ssize_tnargs,
112+
PyObject*kwargs,PyObject*kwnames,
113+
struct_PyArg_Parser*parser,
114+
intminpos,intmaxpos,intminkw,
115+
intvararg,PyObject**buf);
116+
25117
#ifdef__cplusplus
26118
}
27119
#endif

‎Include/modsupport.h

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

135135
#endif/* New in 3.5 */
136136

137-
#ifndefPy_LIMITED_API
138-
# definePy_CPYTHON_MODSUPPORT_H
139-
# include"cpython/modsupport.h"
140-
# undef Py_CPYTHON_MODSUPPORT_H
141-
#endif
142-
143137
#ifdef__cplusplus
144138
}
145139
#endif

‎Makefile.pre.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,6 @@ PYTHON_HEADERS= \
17201720
$(srcdir)/Include/cpython/longobject.h \
17211721
$(srcdir)/Include/cpython/memoryobject.h \
17221722
$(srcdir)/Include/cpython/methodobject.h \
1723-
$(srcdir)/Include/cpython/modsupport.h \
17241723
$(srcdir)/Include/cpython/object.h \
17251724
$(srcdir)/Include/cpython/objimpl.h \
17261725
$(srcdir)/Include/cpython/odictobject.h \
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Move the undocumented private _PyArg functions and _PyArg_Parser structure
2+
to internal C API (``pycore_modsupport.h``). Patch by Victor Stinner.

‎Modules/_asynciomodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include"Python.h"
66
#include"pycore_dict.h"// _PyDict_GetItem_KnownHash()
7+
#include"pycore_modsupport.h"// _PyArg_CheckPositional()
78
#include"pycore_moduleobject.h"// _PyModule_GetState()
89
#include"pycore_pyerrors.h"// _PyErr_ClearExcState()
910
#include"pycore_pylifecycle.h"// _Py_IsInterpreterFinalizing()

‎Modules/_blake2/clinic/blake2b_impl.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Modules/_blake2/clinic/blake2s_impl.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Modules/_csv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ module instead.
1010

1111
#defineMODULE_VERSION "1.0"
1212

13+
// clinic/_csv.c.h uses internal pycore_modsupport.h API
14+
#ifndefPy_BUILD_CORE_BUILTIN
15+
# definePy_BUILD_CORE_MODULE 1
16+
#endif
17+
1318
#include"Python.h"
1419

1520
#include<stddef.h>// offsetof()

‎Modules/_ctypes/_ctypes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ bytes(cdata)
110110

111111
#include"pycore_call.h"// _PyObject_CallNoArgs()
112112
#include"pycore_ceval.h"// _Py_EnterRecursiveCall()
113+
#ifdefMS_WIN32
114+
# include"pycore_modsupport.h"// _PyArg_NoKeywords()
115+
#endif
113116
#include"pycore_pyerrors.h"// _PyErr_WriteUnraisableMsg()
114117

115118

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp