Skip to content

Commit 8992704

Browse files
authored
gh-144175: Remove internal _PyArg_ParseStack() function (#159150)
Replace internal _PyArg_ParseStack() with public PyArg_ParseArray() in Argument Clinic.
1 parent 16309c4 commit 8992704

14 files changed

Lines changed: 46 additions & 63 deletions

File tree

‎Include/internal/pycore_modsupport.h‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ extern PyObject ** _Py_VaBuildStack(
4141

4242
extern PyObject* _PyModule_CreateInitialized(PyModuleDef*, int apiver);
4343

44-
// Export for '_curses' shared extension
45-
PyAPI_FUNC(int) _PyArg_ParseStack(
46-
PyObject *const *args,
47-
Py_ssize_t nargs,
48-
const char *format,
49-
...);
50-
5144
extern int _PyArg_UnpackStack(
5245
PyObject *const *args,
5346
Py_ssize_t nargs,
@@ -65,7 +58,9 @@ PyAPI_FUNC(void) _PyArg_BadArgument(
6558

6659
// --- _PyArg_Parser API ---------------------------------------------------
6760

68-
// Export for '_dbm' shared extension
61+
// Similar to public PyArg_ParseArrayAndKeywords(), but faster thanks
62+
// to "struct _PyArg_Parser *parser" cache.
63+
// Export for '_dbm' shared extension.
6964
PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
7065
PyObject *const *args,
7166
Py_ssize_t nargs,

‎Lib/test/clinic.test.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ test_str_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
20492049
const char *h = "mn";
20502050
Py_ssize_t h_length;
20512051

2052-
if (!_PyArg_ParseStack(args, nargs, "|sssyzy#s#z#:test_str_converter",
2052+
if (!PyArg_ParseArray(args, nargs, "|sssyzy#s#z#:test_str_converter",
20532053
&a, &b, &c, &d, &e, &f, &f_length, &g, &g_length, &h, &h_length)) {
20542054
goto exit;
20552055
}
@@ -2065,7 +2065,7 @@ test_str_converter_impl(PyObject *module, const char *a, const char *b,
20652065
const char *f, Py_ssize_t f_length, const char *g,
20662066
Py_ssize_t g_length, const char *h,
20672067
Py_ssize_t h_length)
2068-
/*[clinic end generated code: output=82cb06d5237ef062 input=8afe9da8185cd38c]*/
2068+
/*[clinic end generated code: output=58dc0fad26cd4c5d input=8afe9da8185cd38c]*/
20692069

20702070

20712071
/*[clinic input]
@@ -2105,7 +2105,7 @@ test_str_converter_encoding(PyObject *module, PyObject *const *args, Py_ssize_t
21052105
char *e = NULL;
21062106
Py_ssize_t e_length;
21072107

2108-
if (!_PyArg_ParseStack(args, nargs, "esesetes#et#:test_str_converter_encoding",
2108+
if (!PyArg_ParseArray(args, nargs, "esesetes#et#:test_str_converter_encoding",
21092109
"idna", &a, "idna", &b, "idna", &c, "idna", &d, &d_length, "idna", &e, &e_length)) {
21102110
goto exit;
21112111
}
@@ -2129,7 +2129,7 @@ static PyObject *
21292129
test_str_converter_encoding_impl(PyObject *module, char *a, char *b, char *c,
21302130
char *d, Py_ssize_t d_length, char *e,
21312131
Py_ssize_t e_length)
2132-
/*[clinic end generated code: output=999c1deecfa15b0a input=eb4c38e1f898f402]*/
2132+
/*[clinic end generated code: output=5bab02bfd6a20cf4 input=eb4c38e1f898f402]*/
21332133

21342134

21352135
/*[clinic input]
@@ -2170,7 +2170,7 @@ test_Py_UNICODE_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
21702170
const wchar_t *e = NULL;
21712171
Py_ssize_t e_length;
21722172

2173-
if (!_PyArg_ParseStack(args, nargs, "O&O&O&u#Z#:test_Py_UNICODE_converter",
2173+
if (!PyArg_ParseArray(args, nargs, "O&O&O&u#Z#:test_Py_UNICODE_converter",
21742174
_PyUnicode_WideCharString_Converter, &a, _PyUnicode_WideCharString_Converter, &b, _PyUnicode_WideCharString_Opt_Converter, &c, &d, &d_length, &e, &e_length)) {
21752175
goto exit;
21762176
}
@@ -2192,7 +2192,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const wchar_t *a,
21922192
const wchar_t *b, const wchar_t *c,
21932193
const wchar_t *d, Py_ssize_t d_length,
21942194
const wchar_t *e, Py_ssize_t e_length)
2195-
/*[clinic end generated code: output=529af9cda2a20349 input=064a3b68ad7f04b0]*/
2195+
/*[clinic end generated code: output=020370db41973be0 input=064a3b68ad7f04b0]*/
21962196

21972197

21982198
/*[clinic input]
@@ -2229,7 +2229,7 @@ test_Py_buffer_converter(PyObject *module, PyObject *const *args, Py_ssize_t nar
22292229
Py_buffer d = {NULL, NULL};
22302230
Py_buffer e = {NULL, NULL};
22312231

2232-
if (!_PyArg_ParseStack(args, nargs, "y*y*s*z*w*:test_Py_buffer_converter",
2232+
if (!PyArg_ParseArray(args, nargs, "y*y*s*z*w*:test_Py_buffer_converter",
22332233
&a, &b, &c, &d, &e)) {
22342234
goto exit;
22352235
}
@@ -2263,7 +2263,7 @@ test_Py_buffer_converter(PyObject *module, PyObject *const *args, Py_ssize_t nar
22632263
static PyObject *
22642264
test_Py_buffer_converter_impl(PyObject *module, Py_buffer *a, Py_buffer *b,
22652265
Py_buffer *c, Py_buffer *d, Py_buffer *e)
2266-
/*[clinic end generated code: output=a153b71b4f45f952 input=6a9da0f56f9525fd]*/
2266+
/*[clinic end generated code: output=14bb6138c13c4085 input=6a9da0f56f9525fd]*/
22672267

22682268

22692269
/*[clinic input]
@@ -6038,7 +6038,7 @@ Test__pyarg_parsestackandkeywords(PyObject *self, PyTypeObject *cls, PyObject *c
60386038
if (!_PyArg_NoKwnames("_pyarg_parsestackandkeywords", kwnames)) {
60396039
goto exit;
60406040
}
6041-
if (!_PyArg_ParseStack(args, nargs, "s#:_pyarg_parsestackandkeywords",
6041+
if (!PyArg_ParseArray(args, nargs, "s#:_pyarg_parsestackandkeywords",
60426042
&key, &key_length)) {
60436043
goto exit;
60446044
}
@@ -6052,7 +6052,7 @@ static PyObject *
60526052
Test__pyarg_parsestackandkeywords_impl(TestObj *self, PyTypeObject *cls,
60536053
const char *key,
60546054
Py_ssize_t key_length)
6055-
/*[clinic end generated code: output=21bbb9a8d0100d72 input=fc72ef4b4cfafabc]*/
6055+
/*[clinic end generated code: output=4acb456c0ebbbd40 input=fc72ef4b4cfafabc]*/
60566056

60576057

60586058
/*[clinic input]

‎Modules/_ctypes/clinic/_ctypes.c.h‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/_multiprocessing/clinic/semaphore.c.h‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/_testcapi/clinic/exceptions.c.h‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/_testcapi/clinic/file.c.h‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/_testcapi/clinic/float.c.h‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/clinic/_cursesmodule.c.h‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/clinic/_dbmmodule.c.h‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/clinic/_gdbmmodule.c.h‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)