pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/be5e8a010341c4d2d28ef53a1baed402ee06466e

41e157469407.css" /> gh-110964: Remove private _PyArg functions (#110966) · python/cpython@be5e8a0 · GitHub
Skip to content

Commit be5e8a0

Browse files
authored
gh-110964: Remove private _PyArg functions (#110966)
Move the following private functions and structures to pycore_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 parent 054f496 commit be5e8a0

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(const char *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(const char *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(const char *, 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
extern PyObject ** _Py_VaBuildStack(
1735
PyObject **small_stack,
1836
Py_ssize_t small_stack_len,
@@ -22,6 +40,80 @@ extern PyObject ** _Py_VaBuildStack(
2240

2341
extern PyObject* _PyModule_CreateInitialized(PyModuleDef*, int apiver);
2442

43+
// Export for '_curses' shared extension
44+
PyAPI_FUNC(int) _PyArg_ParseStack(
45+
PyObject *const *args,
46+
Py_ssize_t nargs,
47+
const char *format,
48+
...);
49+
50+
extern int _PyArg_UnpackStack(
51+
PyObject *const *args,
52+
Py_ssize_t nargs,
53+
const char *name,
54+
Py_ssize_t min,
55+
Py_ssize_t max,
56+
...);
57+
58+
// Export for '_heapq' shared extension
59+
PyAPI_FUNC(void) _PyArg_BadArgument(
60+
const char *fname,
61+
const char *displayname,
62+
const char *expected,
63+
PyObject *arg);
64+
65+
// --- _PyArg_Parser API ---------------------------------------------------
66+
67+
typedef struct _PyArg_Parser {
68+
int initialized;
69+
const char *format;
70+
const char * const *keywords;
71+
const char *fname;
72+
const char *custom_msg;
73+
int pos; /* number of positional-only arguments */
74+
int min; /* minimal number of arguments */
75+
int max; /* 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_t nargs,
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_t nargs,
96+
PyObject *kwargs,
97+
PyObject *kwnames,
98+
struct _PyArg_Parser *parser,
99+
int minpos,
100+
int maxpos,
101+
int minkw,
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_t nargs,
112+
PyObject *kwargs, PyObject *kwnames,
113+
struct _PyArg_Parser *parser,
114+
int minpos, int maxpos, int minkw,
115+
int vararg, 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-
#ifndef Py_LIMITED_API
138-
# define Py_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 about customizing 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 about customizing 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
#define MODULE_VERSION "1.0"
1212

13+
// clinic/_csv.c.h uses internal pycore_modsupport.h API
14+
#ifndef Py_BUILD_CORE_BUILTIN
15+
# define Py_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+
#ifdef MS_WIN32
114+
# include "pycore_modsupport.h" // _PyArg_NoKeywords()
115+
#endif
113116
#include "pycore_pyerrors.h" // _PyErr_WriteUnraisableMsg()
114117

115118

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy