Skip to content

Commit 1009bf1

Browse files
Issue #23501: Argumen Clinic now generates code into separate files by default.
1 parent 0759f84 commit 1009bf1

Some content is hidden

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

54 files changed

+9283
-8752
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Library
6363
Build
6464
-----
6565

66+
- Issue #23501: Argumen Clinic now generates code into separate files by default.
67+
6668
Tests
6769
-----
6870

Modules/_bz2module.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,11 @@ compress(BZ2Compressor *c, char *data, size_t len, int action)
211211
}
212212

213213
/*[clinic input]
214-
output preset file
215214
module _bz2
216215
class _bz2.BZ2Compressor "BZ2Compressor *" "&BZ2Compressor_Type"
217216
class _bz2.BZ2Decompressor "BZ2Decompressor *" "&BZ2Decompressor_Type"
218217
[clinic start generated code]*/
219-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=e3b139924f5e18cc]*/
218+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=dc7d7992a79f9cb7]*/
220219

221220
#include "clinic/_bz2module.c.h"
222221

Modules/_codecsmodule.c

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module _codecs
4747
[clinic start generated code]*/
4848
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=e1390e3da3cb9deb]*/
4949

50+
#include "clinic/_codecsmodule.c.h"
5051

5152
/* --- Registry ----------------------------------------------------------- */
5253

@@ -153,37 +154,9 @@ _codecs._forget_codec
153154
Purge the named codec from the internal codec lookup cache
154155
[clinic start generated code]*/
155156

156-
PyDoc_STRVAR(_codecs__forget_codec__doc__,
157-
"_forget_codec($module, encoding, /)\n"
158-
"--\n"
159-
"\n"
160-
"Purge the named codec from the internal codec lookup cache");
161-
162-
#define _CODECS__FORGET_CODEC_METHODDEF \
163-
{"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_VARARGS, _codecs__forget_codec__doc__},
164-
165-
static PyObject *
166-
_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding);
167-
168-
static PyObject *
169-
_codecs__forget_codec(PyModuleDef *module, PyObject *args)
170-
{
171-
PyObject *return_value = NULL;
172-
const char *encoding;
173-
174-
if (!PyArg_ParseTuple(args,
175-
"s:_forget_codec",
176-
&encoding))
177-
goto exit;
178-
return_value = _codecs__forget_codec_impl(module, encoding);
179-
180-
exit:
181-
return return_value;
182-
}
183-
184157
static PyObject *
185158
_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding)
186-
/*[clinic end generated code: output=a75e631591702a5c input=18d5d92d0e386c38]*/
159+
/*[clinic end generated code: output=b56a9b99d2d28080 input=18d5d92d0e386c38]*/
187160
{
188161
if (_PyCodec_Forget(encoding) < 0) {
189162
return NULL;

Modules/_cryptmodule.c

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module crypt
1212
[clinic start generated code]*/
1313
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c6252cf4f2f2ae81]*/
1414

15+
#include "clinic/_cryptmodule.c.h"
1516

1617
/*[clinic input]
1718
crypt.crypt
@@ -29,43 +30,9 @@ results for a given *word*.
2930
3031
[clinic start generated code]*/
3132

32-
PyDoc_STRVAR(crypt_crypt__doc__,
33-
"crypt($module, word, salt, /)\n"
34-
"--\n"
35-
"\n"
36-
"Hash a *word* with the given *salt* and return the hashed password.\n"
37-
"\n"
38-
"*word* will usually be a user\'s password. *salt* (either a random 2 or 16\n"
39-
"character string, possibly prefixed with $digit$ to indicate the method)\n"
40-
"will be used to perturb the encryption algorithm and produce distinct\n"
41-
"results for a given *word*.");
42-
43-
#define CRYPT_CRYPT_METHODDEF \
44-
{"crypt", (PyCFunction)crypt_crypt, METH_VARARGS, crypt_crypt__doc__},
45-
46-
static PyObject *
47-
crypt_crypt_impl(PyModuleDef *module, const char *word, const char *salt);
48-
49-
static PyObject *
50-
crypt_crypt(PyModuleDef *module, PyObject *args)
51-
{
52-
PyObject *return_value = NULL;
53-
const char *word;
54-
const char *salt;
55-
56-
if (!PyArg_ParseTuple(args,
57-
"ss:crypt",
58-
&word, &salt))
59-
goto exit;
60-
return_value = crypt_crypt_impl(module, word, salt);
61-
62-
exit:
63-
return return_value;
64-
}
65-
6633
static PyObject *
6734
crypt_crypt_impl(PyModuleDef *module, const char *word, const char *salt)
68-
/*[clinic end generated code: output=3eaacdf994a6ff23 input=4d93b6d0f41fbf58]*/
35+
/*[clinic end generated code: output=995ad1e854d83069 input=4d93b6d0f41fbf58]*/
6936
{
7037
/* On some platforms (AtheOS) crypt returns NULL for an invalid
7138
salt. Return None in that case. XXX Maybe raise an exception? */

Modules/_cursesmodule.c

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class curses.window "PyCursesWindowObject *" "&PyCursesWindow_Type"
140140
[clinic start generated code]*/
141141
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=88c860abdbb50e0c]*/
142142

143+
#include "clinic/_cursesmodule.c.h"
144+
143145
/* Definition of exception curses.error */
144146

145147
static PyObject *PyCursesError;
@@ -583,75 +585,9 @@ By default, the character position and attributes are the
583585
current settings for the window object.
584586
[clinic start generated code]*/
585587

586-
PyDoc_STRVAR(curses_window_addch__doc__,
587-
"addch([y, x,] ch, [attr])\n"
588-
"Paint character ch at (y, x) with attributes attr.\n"
589-
"\n"
590-
" y\n"
591-
" Y-coordinate.\n"
592-
" x\n"
593-
" X-coordinate.\n"
594-
" ch\n"
595-
" Character to add.\n"
596-
" attr\n"
597-
" Attributes for the character.\n"
598-
"\n"
599-
"Paint character ch at (y, x) with attributes attr,\n"
600-
"overwriting any character previously painted at that location.\n"
601-
"By default, the character position and attributes are the\n"
602-
"current settings for the window object.");
603-
604-
#define CURSES_WINDOW_ADDCH_METHODDEF \
605-
{"addch", (PyCFunction)curses_window_addch, METH_VARARGS, curses_window_addch__doc__},
606-
607-
static PyObject *
608-
curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, int x, PyObject *ch, int group_right_1, long attr);
609-
610-
static PyObject *
611-
curses_window_addch(PyCursesWindowObject *self, PyObject *args)
612-
{
613-
PyObject *return_value = NULL;
614-
int group_left_1 = 0;
615-
int y = 0;
616-
int x = 0;
617-
PyObject *ch;
618-
int group_right_1 = 0;
619-
long attr = 0;
620-
621-
switch (PyTuple_GET_SIZE(args)) {
622-
case 1:
623-
if (!PyArg_ParseTuple(args, "O:addch", &ch))
624-
goto exit;
625-
break;
626-
case 2:
627-
if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr))
628-
goto exit;
629-
group_right_1 = 1;
630-
break;
631-
case 3:
632-
if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch))
633-
goto exit;
634-
group_left_1 = 1;
635-
break;
636-
case 4:
637-
if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr))
638-
goto exit;
639-
group_right_1 = 1;
640-
group_left_1 = 1;
641-
break;
642-
default:
643-
PyErr_SetString(PyExc_TypeError, "curses.window.addch requires 1 to 4 arguments");
644-
goto exit;
645-
}
646-
return_value = curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr);
647-
648-
exit:
649-
return return_value;
650-
}
651-
652588
static PyObject *
653589
curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, int x, PyObject *ch, int group_right_1, long attr)
654-
/*[clinic end generated code: output=d4b97cc287010c54 input=5a41efb34a2de338]*/
590+
/*[clinic end generated code: output=9fa34a5d80151f1a input=5a41efb34a2de338]*/
655591
{
656592
PyCursesWindowObject *cwself = (PyCursesWindowObject *)self;
657593
int coordinates_group = group_left_1;

Modules/_datetimemodule.c

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class datetime.datetime "PyDateTime_DateTime *" "&PyDateTime_DateTimeType"
2626
[clinic start generated code]*/
2727
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=78142cb64b9e98bc]*/
2828

29+
#include "clinic/_datetimemodule.c.h"
30+
2931
/* We require that C int be at least 32 bits, and use int virtually
3032
* everywhere. In just a few cases we use a temp long, where a Python
3133
* API returns a C long. In such cases, we have to ensure that the
@@ -4133,43 +4135,9 @@ Returns new datetime object representing current time local to tz.
41334135
If no tz is specified, uses local timezone.
41344136
[clinic start generated code]*/
41354137

4136-
PyDoc_STRVAR(datetime_datetime_now__doc__,
4137-
"now($type, /, tz=None)\n"
4138-
"--\n"
4139-
"\n"
4140-
"Returns new datetime object representing current time local to tz.\n"
4141-
"\n"
4142-
" tz\n"
4143-
" Timezone object.\n"
4144-
"\n"
4145-
"If no tz is specified, uses local timezone.");
4146-
4147-
#define DATETIME_DATETIME_NOW_METHODDEF \
4148-
{"now", (PyCFunction)datetime_datetime_now, METH_VARARGS|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__},
4149-
4150-
static PyObject *
4151-
datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz);
4152-
4153-
static PyObject *
4154-
datetime_datetime_now(PyTypeObject *type, PyObject *args, PyObject *kwargs)
4155-
{
4156-
PyObject *return_value = NULL;
4157-
static char *_keywords[] = {"tz", NULL};
4158-
PyObject *tz = Py_None;
4159-
4160-
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
4161-
"|O:now", _keywords,
4162-
&tz))
4163-
goto exit;
4164-
return_value = datetime_datetime_now_impl(type, tz);
4165-
4166-
exit:
4167-
return return_value;
4168-
}
4169-
41704138
static PyObject *
41714139
datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz)
4172-
/*[clinic end generated code: output=583c5637e3c843fa input=80d09869c5267d00]*/
4140+
/*[clinic end generated code: output=b3386e5345e2b47a input=80d09869c5267d00]*/
41734141
{
41744142
PyObject *self;
41754143

Modules/_dbmmodule.c

Lines changed: 4 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ typedef struct {
4040
DBM *di_dbm;
4141
} dbmobject;
4242

43+
#include "clinic/_dbmmodule.c.h"
44+
4345
static PyTypeObject Dbmtype;
4446

4547
#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype)
@@ -277,39 +279,9 @@ dbm.dbm.get
277279
Return the value for key if present, otherwise default.
278280
[clinic start generated code]*/
279281

280-
PyDoc_STRVAR(dbm_dbm_get__doc__,
281-
"get($self, key, default=None, /)\n"
282-
"--\n"
283-
"\n"
284-
"Return the value for key if present, otherwise default.");
285-
286-
#define DBM_DBM_GET_METHODDEF \
287-
{"get", (PyCFunction)dbm_dbm_get, METH_VARARGS, dbm_dbm_get__doc__},
288-
289-
static PyObject *
290-
dbm_dbm_get_impl(dbmobject *dp, const char *key, Py_ssize_clean_t key_length, PyObject *default_value);
291-
292-
static PyObject *
293-
dbm_dbm_get(dbmobject *dp, PyObject *args)
294-
{
295-
PyObject *return_value = NULL;
296-
const char *key;
297-
Py_ssize_clean_t key_length;
298-
PyObject *default_value = Py_None;
299-
300-
if (!PyArg_ParseTuple(args,
301-
"s#|O:get",
302-
&key, &key_length, &default_value))
303-
goto exit;
304-
return_value = dbm_dbm_get_impl(dp, key, key_length, default_value);
305-
306-
exit:
307-
return return_value;
308-
}
309-
310282
static PyObject *
311283
dbm_dbm_get_impl(dbmobject *dp, const char *key, Py_ssize_clean_t key_length, PyObject *default_value)
312-
/*[clinic end generated code: output=452ea11394e7e92d input=aecf5efd2f2b1a3b]*/
284+
/*[clinic end generated code: output=c2bdccaa734ad349 input=aecf5efd2f2b1a3b]*/
313285
{
314286
datum dbm_key, val;
315287

@@ -449,47 +421,9 @@ Return a database object.
449421
450422
[clinic start generated code]*/
451423

452-
PyDoc_STRVAR(dbmopen__doc__,
453-
"open($module, filename, flags=\'r\', mode=0o666, /)\n"
454-
"--\n"
455-
"\n"
456-
"Return a database object.\n"
457-
"\n"
458-
" filename\n"
459-
" The filename to open.\n"
460-
" flags\n"
461-
" How to open the file. \"r\" for reading, \"w\" for writing, etc.\n"
462-
" mode\n"
463-
" If creating a new file, the mode bits for the new file\n"
464-
" (e.g. os.O_RDWR).");
465-
466-
#define DBMOPEN_METHODDEF \
467-
{"open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__},
468-
469-
static PyObject *
470-
dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode);
471-
472-
static PyObject *
473-
dbmopen(PyModuleDef *module, PyObject *args)
474-
{
475-
PyObject *return_value = NULL;
476-
const char *filename;
477-
const char *flags = "r";
478-
int mode = 438;
479-
480-
if (!PyArg_ParseTuple(args,
481-
"s|si:open",
482-
&filename, &flags, &mode))
483-
goto exit;
484-
return_value = dbmopen_impl(module, filename, flags, mode);
485-
486-
exit:
487-
return return_value;
488-
}
489-
490424
static PyObject *
491425
dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode)
492-
/*[clinic end generated code: output=9a7b725f9c4dcec2 input=6499ab0fab1333ac]*/
426+
/*[clinic end generated code: output=8b618fe06b92bf86 input=6499ab0fab1333ac]*/
493427
{
494428
int iflags;
495429

Modules/_lzmamodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,11 @@ build_filter_spec(const lzma_filter *f)
478478

479479

480480
/*[clinic input]
481-
output preset file
482481
module _lzma
483482
class _lzma.LZMACompressor "Compressor *" "&Compressor_type"
484483
class _lzma.LZMADecompressor "Decompressor *" "&Decompressor_type"
485484
[clinic start generated code]*/
486-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=f17afc786525d6c2]*/
485+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=2c14bbe05ff0c147]*/
487486

488487
#include "clinic/_lzmamodule.c.h"
489488

0 commit comments

Comments
 (0)