Skip to content

Commit 0c4a828

Browse files
committed
Run Argument Clinic: METH_VARARGS=>METH_FASTCALL
Issue #29286. Run Argument Clinic to get the new faster METH_FASTCALL calling convention for functions using "boring" positional arguments. Manually fix _elementtree: _elementtree_XMLParser_doctype() must remain consistent with the clinic code.
1 parent 093119e commit 0c4a828

File tree

19 files changed

+357
-165
lines changed

19 files changed

+357
-165
lines changed

Modules/_elementtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,7 @@ typedef struct {
27432743
} XMLParserObject;
27442744

27452745
static PyObject*
2746-
_elementtree_XMLParser_doctype(XMLParserObject* self, PyObject* args);
2746+
_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames);
27472747
static PyObject *
27482748
_elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name,
27492749
PyObject *pubid, PyObject *system);

Modules/_io/clinic/bufferedio.c.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,22 +309,26 @@ PyDoc_STRVAR(_io__Buffered_truncate__doc__,
309309
"\n");
310310

311311
#define _IO__BUFFERED_TRUNCATE_METHODDEF \
312-
{"truncate", (PyCFunction)_io__Buffered_truncate, METH_VARARGS, _io__Buffered_truncate__doc__},
312+
{"truncate", (PyCFunction)_io__Buffered_truncate, METH_FASTCALL, _io__Buffered_truncate__doc__},
313313

314314
static PyObject *
315315
_io__Buffered_truncate_impl(buffered *self, PyObject *pos);
316316

317317
static PyObject *
318-
_io__Buffered_truncate(buffered *self, PyObject *args)
318+
_io__Buffered_truncate(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
319319
{
320320
PyObject *return_value = NULL;
321321
PyObject *pos = Py_None;
322322

323-
if (!PyArg_UnpackTuple(args, "truncate",
323+
if (!_PyArg_UnpackStack(args, nargs, "truncate",
324324
0, 1,
325325
&pos)) {
326326
goto exit;
327327
}
328+
329+
if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
330+
goto exit;
331+
}
328332
return_value = _io__Buffered_truncate_impl(self, pos);
329333

330334
exit:
@@ -496,4 +500,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
496500
exit:
497501
return return_value;
498502
}
499-
/*[clinic end generated code: output=e6e584216a10d67e input=a9049054013a1b77]*/
503+
/*[clinic end generated code: output=e37b969b1acaa09c input=a9049054013a1b77]*/

Modules/_io/clinic/bytesio.c.h

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,26 @@ PyDoc_STRVAR(_io_BytesIO_read__doc__,
158158
"Return an empty bytes object at EOF.");
159159

160160
#define _IO_BYTESIO_READ_METHODDEF \
161-
{"read", (PyCFunction)_io_BytesIO_read, METH_VARARGS, _io_BytesIO_read__doc__},
161+
{"read", (PyCFunction)_io_BytesIO_read, METH_FASTCALL, _io_BytesIO_read__doc__},
162162

163163
static PyObject *
164164
_io_BytesIO_read_impl(bytesio *self, PyObject *arg);
165165

166166
static PyObject *
167-
_io_BytesIO_read(bytesio *self, PyObject *args)
167+
_io_BytesIO_read(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
168168
{
169169
PyObject *return_value = NULL;
170170
PyObject *arg = Py_None;
171171

172-
if (!PyArg_UnpackTuple(args, "read",
172+
if (!_PyArg_UnpackStack(args, nargs, "read",
173173
0, 1,
174174
&arg)) {
175175
goto exit;
176176
}
177+
178+
if (!_PyArg_NoStackKeywords("read", kwnames)) {
179+
goto exit;
180+
}
177181
return_value = _io_BytesIO_read_impl(self, arg);
178182

179183
exit:
@@ -190,22 +194,26 @@ PyDoc_STRVAR(_io_BytesIO_read1__doc__,
190194
"Return an empty bytes object at EOF.");
191195

192196
#define _IO_BYTESIO_READ1_METHODDEF \
193-
{"read1", (PyCFunction)_io_BytesIO_read1, METH_VARARGS, _io_BytesIO_read1__doc__},
197+
{"read1", (PyCFunction)_io_BytesIO_read1, METH_FASTCALL, _io_BytesIO_read1__doc__},
194198

195199
static PyObject *
196200
_io_BytesIO_read1_impl(bytesio *self, PyObject *size);
197201

198202
static PyObject *
199-
_io_BytesIO_read1(bytesio *self, PyObject *args)
203+
_io_BytesIO_read1(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
200204
{
201205
PyObject *return_value = NULL;
202206
PyObject *size = Py_None;
203207

204-
if (!PyArg_UnpackTuple(args, "read1",
208+
if (!_PyArg_UnpackStack(args, nargs, "read1",
205209
0, 1,
206210
&size)) {
207211
goto exit;
208212
}
213+
214+
if (!_PyArg_NoStackKeywords("read1", kwnames)) {
215+
goto exit;
216+
}
209217
return_value = _io_BytesIO_read1_impl(self, size);
210218

211219
exit:
@@ -223,22 +231,26 @@ PyDoc_STRVAR(_io_BytesIO_readline__doc__,
223231
"Return an empty bytes object at EOF.");
224232

225233
#define _IO_BYTESIO_READLINE_METHODDEF \
226-
{"readline", (PyCFunction)_io_BytesIO_readline, METH_VARARGS, _io_BytesIO_readline__doc__},
234+
{"readline", (PyCFunction)_io_BytesIO_readline, METH_FASTCALL, _io_BytesIO_readline__doc__},
227235

228236
static PyObject *
229237
_io_BytesIO_readline_impl(bytesio *self, PyObject *arg);
230238

231239
static PyObject *
232-
_io_BytesIO_readline(bytesio *self, PyObject *args)
240+
_io_BytesIO_readline(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
233241
{
234242
PyObject *return_value = NULL;
235243
PyObject *arg = Py_None;
236244

237-
if (!PyArg_UnpackTuple(args, "readline",
245+
if (!_PyArg_UnpackStack(args, nargs, "readline",
238246
0, 1,
239247
&arg)) {
240248
goto exit;
241249
}
250+
251+
if (!_PyArg_NoStackKeywords("readline", kwnames)) {
252+
goto exit;
253+
}
242254
return_value = _io_BytesIO_readline_impl(self, arg);
243255

244256
exit:
@@ -256,22 +268,26 @@ PyDoc_STRVAR(_io_BytesIO_readlines__doc__,
256268
"total number of bytes in the lines returned.");
257269

258270
#define _IO_BYTESIO_READLINES_METHODDEF \
259-
{"readlines", (PyCFunction)_io_BytesIO_readlines, METH_VARARGS, _io_BytesIO_readlines__doc__},
271+
{"readlines", (PyCFunction)_io_BytesIO_readlines, METH_FASTCALL, _io_BytesIO_readlines__doc__},
260272

261273
static PyObject *
262274
_io_BytesIO_readlines_impl(bytesio *self, PyObject *arg);
263275

264276
static PyObject *
265-
_io_BytesIO_readlines(bytesio *self, PyObject *args)
277+
_io_BytesIO_readlines(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
266278
{
267279
PyObject *return_value = NULL;
268280
PyObject *arg = Py_None;
269281

270-
if (!PyArg_UnpackTuple(args, "readlines",
282+
if (!_PyArg_UnpackStack(args, nargs, "readlines",
271283
0, 1,
272284
&arg)) {
273285
goto exit;
274286
}
287+
288+
if (!_PyArg_NoStackKeywords("readlines", kwnames)) {
289+
goto exit;
290+
}
275291
return_value = _io_BytesIO_readlines_impl(self, arg);
276292

277293
exit:
@@ -323,22 +339,26 @@ PyDoc_STRVAR(_io_BytesIO_truncate__doc__,
323339
"The current file position is unchanged. Returns the new size.");
324340

325341
#define _IO_BYTESIO_TRUNCATE_METHODDEF \
326-
{"truncate", (PyCFunction)_io_BytesIO_truncate, METH_VARARGS, _io_BytesIO_truncate__doc__},
342+
{"truncate", (PyCFunction)_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__},
327343

328344
static PyObject *
329345
_io_BytesIO_truncate_impl(bytesio *self, PyObject *arg);
330346

331347
static PyObject *
332-
_io_BytesIO_truncate(bytesio *self, PyObject *args)
348+
_io_BytesIO_truncate(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
333349
{
334350
PyObject *return_value = NULL;
335351
PyObject *arg = Py_None;
336352

337-
if (!PyArg_UnpackTuple(args, "truncate",
353+
if (!_PyArg_UnpackStack(args, nargs, "truncate",
338354
0, 1,
339355
&arg)) {
340356
goto exit;
341357
}
358+
359+
if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
360+
goto exit;
361+
}
342362
return_value = _io_BytesIO_truncate_impl(self, arg);
343363

344364
exit:
@@ -452,4 +472,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
452472
exit:
453473
return return_value;
454474
}
455-
/*[clinic end generated code: output=056f24eece495a8f input=a9049054013a1b77]*/
475+
/*[clinic end generated code: output=138ee6ad6951bc84 input=a9049054013a1b77]*/

Modules/_io/clinic/fileio.c.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,22 +336,26 @@ PyDoc_STRVAR(_io_FileIO_truncate__doc__,
336336
"The current file position is changed to the value of size.");
337337

338338
#define _IO_FILEIO_TRUNCATE_METHODDEF \
339-
{"truncate", (PyCFunction)_io_FileIO_truncate, METH_VARARGS, _io_FileIO_truncate__doc__},
339+
{"truncate", (PyCFunction)_io_FileIO_truncate, METH_FASTCALL, _io_FileIO_truncate__doc__},
340340

341341
static PyObject *
342342
_io_FileIO_truncate_impl(fileio *self, PyObject *posobj);
343343

344344
static PyObject *
345-
_io_FileIO_truncate(fileio *self, PyObject *args)
345+
_io_FileIO_truncate(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
346346
{
347347
PyObject *return_value = NULL;
348348
PyObject *posobj = NULL;
349349

350-
if (!PyArg_UnpackTuple(args, "truncate",
350+
if (!_PyArg_UnpackStack(args, nargs, "truncate",
351351
0, 1,
352352
&posobj)) {
353353
goto exit;
354354
}
355+
356+
if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
357+
goto exit;
358+
}
355359
return_value = _io_FileIO_truncate_impl(self, posobj);
356360

357361
exit:
@@ -381,4 +385,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
381385
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
382386
#define _IO_FILEIO_TRUNCATE_METHODDEF
383387
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
384-
/*[clinic end generated code: output=5c2a0b493c0af58b input=a9049054013a1b77]*/
388+
/*[clinic end generated code: output=034d782a0daa82bd input=a9049054013a1b77]*/

Modules/_io/clinic/stringio.c.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,26 @@ PyDoc_STRVAR(_io_StringIO_read__doc__,
4848
"is reached. Return an empty string at EOF.");
4949

5050
#define _IO_STRINGIO_READ_METHODDEF \
51-
{"read", (PyCFunction)_io_StringIO_read, METH_VARARGS, _io_StringIO_read__doc__},
51+
{"read", (PyCFunction)_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__},
5252

5353
static PyObject *
5454
_io_StringIO_read_impl(stringio *self, PyObject *arg);
5555

5656
static PyObject *
57-
_io_StringIO_read(stringio *self, PyObject *args)
57+
_io_StringIO_read(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
5858
{
5959
PyObject *return_value = NULL;
6060
PyObject *arg = Py_None;
6161

62-
if (!PyArg_UnpackTuple(args, "read",
62+
if (!_PyArg_UnpackStack(args, nargs, "read",
6363
0, 1,
6464
&arg)) {
6565
goto exit;
6666
}
67+
68+
if (!_PyArg_NoStackKeywords("read", kwnames)) {
69+
goto exit;
70+
}
6771
return_value = _io_StringIO_read_impl(self, arg);
6872

6973
exit:
@@ -79,22 +83,26 @@ PyDoc_STRVAR(_io_StringIO_readline__doc__,
7983
"Returns an empty string if EOF is hit immediately.");
8084

8185
#define _IO_STRINGIO_READLINE_METHODDEF \
82-
{"readline", (PyCFunction)_io_StringIO_readline, METH_VARARGS, _io_StringIO_readline__doc__},
86+
{"readline", (PyCFunction)_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__},
8387

8488
static PyObject *
8589
_io_StringIO_readline_impl(stringio *self, PyObject *arg);
8690

8791
static PyObject *
88-
_io_StringIO_readline(stringio *self, PyObject *args)
92+
_io_StringIO_readline(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
8993
{
9094
PyObject *return_value = NULL;
9195
PyObject *arg = Py_None;
9296

93-
if (!PyArg_UnpackTuple(args, "readline",
97+
if (!_PyArg_UnpackStack(args, nargs, "readline",
9498
0, 1,
9599
&arg)) {
96100
goto exit;
97101
}
102+
103+
if (!_PyArg_NoStackKeywords("readline", kwnames)) {
104+
goto exit;
105+
}
98106
return_value = _io_StringIO_readline_impl(self, arg);
99107

100108
exit:
@@ -112,22 +120,26 @@ PyDoc_STRVAR(_io_StringIO_truncate__doc__,
112120
"Returns the new absolute position.");
113121

114122
#define _IO_STRINGIO_TRUNCATE_METHODDEF \
115-
{"truncate", (PyCFunction)_io_StringIO_truncate, METH_VARARGS, _io_StringIO_truncate__doc__},
123+
{"truncate", (PyCFunction)_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__},
116124

117125
static PyObject *
118126
_io_StringIO_truncate_impl(stringio *self, PyObject *arg);
119127

120128
static PyObject *
121-
_io_StringIO_truncate(stringio *self, PyObject *args)
129+
_io_StringIO_truncate(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
122130
{
123131
PyObject *return_value = NULL;
124132
PyObject *arg = Py_None;
125133

126-
if (!PyArg_UnpackTuple(args, "truncate",
134+
if (!_PyArg_UnpackStack(args, nargs, "truncate",
127135
0, 1,
128136
&arg)) {
129137
goto exit;
130138
}
139+
140+
if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
141+
goto exit;
142+
}
131143
return_value = _io_StringIO_truncate_impl(self, arg);
132144

133145
exit:
@@ -293,4 +305,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
293305
{
294306
return _io_StringIO_seekable_impl(self);
295307
}
296-
/*[clinic end generated code: output=69bf262268745061 input=a9049054013a1b77]*/
308+
/*[clinic end generated code: output=ce8018ec29def422 input=a9049054013a1b77]*/

Modules/_io/clinic/textio.c.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,22 +336,26 @@ PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__,
336336
"\n");
337337

338338
#define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \
339-
{"truncate", (PyCFunction)_io_TextIOWrapper_truncate, METH_VARARGS, _io_TextIOWrapper_truncate__doc__},
339+
{"truncate", (PyCFunction)_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__},
340340

341341
static PyObject *
342342
_io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos);
343343

344344
static PyObject *
345-
_io_TextIOWrapper_truncate(textio *self, PyObject *args)
345+
_io_TextIOWrapper_truncate(textio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
346346
{
347347
PyObject *return_value = NULL;
348348
PyObject *pos = Py_None;
349349

350-
if (!PyArg_UnpackTuple(args, "truncate",
350+
if (!_PyArg_UnpackStack(args, nargs, "truncate",
351351
0, 1,
352352
&pos)) {
353353
goto exit;
354354
}
355+
356+
if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
357+
goto exit;
358+
}
355359
return_value = _io_TextIOWrapper_truncate_impl(self, pos);
356360

357361
exit:
@@ -476,4 +480,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
476480
{
477481
return _io_TextIOWrapper_close_impl(self);
478482
}
479-
/*[clinic end generated code: output=1f8367c7a3301670 input=a9049054013a1b77]*/
483+
/*[clinic end generated code: output=67eba50449900a96 input=a9049054013a1b77]*/

0 commit comments

Comments
 (0)