Skip to content

Commit dbfdc38

Browse files
committed
Issue python#24001: Argument Clinic converters now use accept={type}
instead of types={'type'} to specify the types the converter accepts.
1 parent cb98556 commit dbfdc38

File tree

16 files changed

+163
-122
lines changed

16 files changed

+163
-122
lines changed

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ Documentation
6868
Tools/Demos
6969
-----------
7070

71+
- Issue #24001: Argument Clinic converters now use accept={type}
72+
instead of types={'type'} to specify the types the converter accepts.
73+
7174
- Issue #23330: h2py now supports arbitrary filenames in #include.
7275

7376
- Issue #24031: make patchcheck now supports git checkouts, too.

Modules/_dbmmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static PySequenceMethods dbm_as_sequence = {
274274
/*[clinic input]
275275
_dbm.dbm.get
276276
277-
key: str(types={'str', 'robuffer'}, length=True)
277+
key: str(accept={str, robuffer}, length=True)
278278
default: object(c_default="NULL") = b''
279279
/
280280
@@ -284,7 +284,7 @@ Return the value for key if present, otherwise default.
284284
static PyObject *
285285
_dbm_dbm_get_impl(dbmobject *self, const char *key,
286286
Py_ssize_clean_t key_length, PyObject *default_value)
287-
/*[clinic end generated code: output=b44f95eba8203d93 input=fee97bbe85e84822]*/
287+
/*[clinic end generated code: output=b44f95eba8203d93 input=3c7c1afd9c508457]*/
288288
{
289289
datum dbm_key, val;
290290

@@ -301,7 +301,7 @@ _dbm_dbm_get_impl(dbmobject *self, const char *key,
301301

302302
/*[clinic input]
303303
_dbm.dbm.setdefault
304-
key: str(types={'str', 'robuffer'}, length=True)
304+
key: str(accept={str, robuffer}, length=True)
305305
default: object(c_default="NULL") = b''
306306
/
307307
@@ -314,7 +314,7 @@ static PyObject *
314314
_dbm_dbm_setdefault_impl(dbmobject *self, const char *key,
315315
Py_ssize_clean_t key_length,
316316
PyObject *default_value)
317-
/*[clinic end generated code: output=52545886cf272161 input=6a3b99ae91f20203]*/
317+
/*[clinic end generated code: output=52545886cf272161 input=a66fcb7f18ee2f50]*/
318318
{
319319
datum dbm_key, val;
320320
Py_ssize_t tmp_size;

Modules/_elementtree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,14 +3206,14 @@ _elementtree.XMLParser.__init__
32063206
32073207
html: object = NULL
32083208
target: object = NULL
3209-
encoding: str(nullable=True) = NULL
3209+
encoding: str(accept={str, NoneType}) = NULL
32103210
32113211
[clinic start generated code]*/
32123212

32133213
static int
32143214
_elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *html,
32153215
PyObject *target, const char *encoding)
3216-
/*[clinic end generated code: output=d6a16c63dda54441 input=a870da39c80d7d68]*/
3216+
/*[clinic end generated code: output=d6a16c63dda54441 input=155bc5695baafffd]*/
32173217
{
32183218
self->entity = PyDict_New();
32193219
if (!self->entity)

Modules/_gdbmmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ _gdbm_gdbm_firstkey_impl(dbmobject *self)
383383
/*[clinic input]
384384
_gdbm.gdbm.nextkey
385385
386-
key: str(types={'str', 'robuffer'}, length=True)
386+
key: str(accept={str, robuffer}, length=True)
387387
/
388388
389389
Returns the key that follows key in the traversal.
@@ -400,7 +400,7 @@ to create a list in memory that contains them all:
400400
static PyObject *
401401
_gdbm_gdbm_nextkey_impl(dbmobject *self, const char *key,
402402
Py_ssize_clean_t key_length)
403-
/*[clinic end generated code: output=192ab892de6eb2f6 input=df8e8828201214a6]*/
403+
/*[clinic end generated code: output=192ab892de6eb2f6 input=1eb2ff9b4b0e6ffd]*/
404404
{
405405
PyObject *v;
406406
datum dbm_key, nextkey;

Modules/_io/_iomodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ _io.open
100100
file: object
101101
mode: str = "r"
102102
buffering: int = -1
103-
encoding: str(nullable=True) = NULL
104-
errors: str(nullable=True) = NULL
105-
newline: str(nullable=True) = NULL
103+
encoding: str(accept={str, NoneType}) = NULL
104+
errors: str(accept={str, NoneType}) = NULL
105+
newline: str(accept={str, NoneType}) = NULL
106106
closefd: int(c_default="1") = True
107107
opener: object = None
108108
@@ -230,7 +230,7 @@ static PyObject *
230230
_io_open_impl(PyModuleDef *module, PyObject *file, const char *mode,
231231
int buffering, const char *encoding, const char *errors,
232232
const char *newline, int closefd, PyObject *opener)
233-
/*[clinic end generated code: output=7615d0d746eb14d2 input=0541ce15691a82f2]*/
233+
/*[clinic end generated code: output=7615d0d746eb14d2 input=f4e1ca75223987bc]*/
234234
{
235235
unsigned i;
236236

Modules/_io/bufferedio.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,26 @@ _bufferediobase_readinto_generic(PyObject *self, Py_buffer *buffer, char readint
101101

102102
/*[clinic input]
103103
_io._BufferedIOBase.readinto
104-
buffer: Py_buffer(types={'rwbuffer'})
104+
buffer: Py_buffer(accept={rwbuffer})
105105
/
106106
[clinic start generated code]*/
107107

108108
static PyObject *
109109
_io__BufferedIOBase_readinto_impl(PyObject *self, Py_buffer *buffer)
110-
/*[clinic end generated code: output=8c8cda6684af8038 input=f8242a06c21763a0]*/
110+
/*[clinic end generated code: output=8c8cda6684af8038 input=00a6b9a38f29830a]*/
111111
{
112112
return _bufferediobase_readinto_generic(self, buffer, 0);
113113
}
114114

115115
/*[clinic input]
116116
_io._BufferedIOBase.readinto1
117-
buffer: Py_buffer(types={'rwbuffer'})
117+
buffer: Py_buffer(accept={rwbuffer})
118118
/
119119
[clinic start generated code]*/
120120

121121
static PyObject *
122122
_io__BufferedIOBase_readinto1_impl(PyObject *self, Py_buffer *buffer)
123-
/*[clinic end generated code: output=358623e4fd2b69d3 input=2003e706c730bd21]*/
123+
/*[clinic end generated code: output=358623e4fd2b69d3 input=ebad75b4aadfb9be]*/
124124
{
125125
return _bufferediobase_readinto_generic(self, buffer, 1);
126126
}
@@ -1065,26 +1065,26 @@ _buffered_readinto_generic(buffered *self, Py_buffer *buffer, char readinto1)
10651065

10661066
/*[clinic input]
10671067
_io._Buffered.readinto
1068-
buffer: Py_buffer(types={'rwbuffer'})
1068+
buffer: Py_buffer(accept={rwbuffer})
10691069
/
10701070
[clinic start generated code]*/
10711071

10721072
static PyObject *
10731073
_io__Buffered_readinto_impl(buffered *self, Py_buffer *buffer)
1074-
/*[clinic end generated code: output=bcb376580b1d8170 input=962b7496eac38b3a]*/
1074+
/*[clinic end generated code: output=bcb376580b1d8170 input=ed6b98b7a20a3008]*/
10751075
{
10761076
return _buffered_readinto_generic(self, buffer, 0);
10771077
}
10781078

10791079
/*[clinic input]
10801080
_io._Buffered.readinto1
1081-
buffer: Py_buffer(types={'rwbuffer'})
1081+
buffer: Py_buffer(accept={rwbuffer})
10821082
/
10831083
[clinic start generated code]*/
10841084

10851085
static PyObject *
10861086
_io__Buffered_readinto1_impl(buffered *self, Py_buffer *buffer)
1087-
/*[clinic end generated code: output=6e5c6ac5868205d6 input=834614d93f0adeb5]*/
1087+
/*[clinic end generated code: output=6e5c6ac5868205d6 input=4455c5d55fdf1687]*/
10881088
{
10891089
return _buffered_readinto_generic(self, buffer, 1);
10901090
}

Modules/_io/bytesio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg)
541541

542542
/*[clinic input]
543543
_io.BytesIO.readinto
544-
buffer: Py_buffer(types={'rwbuffer'})
544+
buffer: Py_buffer(accept={rwbuffer})
545545
/
546546
547547
Read up to len(buffer) bytes into buffer.
@@ -552,7 +552,7 @@ is set not to block as has no data to read.
552552

553553
static PyObject *
554554
_io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer)
555-
/*[clinic end generated code: output=a5d407217dcf0639 input=d289da851c7c4159]*/
555+
/*[clinic end generated code: output=a5d407217dcf0639 input=71581f32635c3a31]*/
556556
{
557557
Py_ssize_t len, n;
558558

Modules/_io/fileio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,15 +603,15 @@ _io_FileIO_seekable_impl(fileio *self)
603603

604604
/*[clinic input]
605605
_io.FileIO.readinto
606-
buffer: Py_buffer(types={'rwbuffer'})
606+
buffer: Py_buffer(accept={rwbuffer})
607607
/
608608
609609
Same as RawIOBase.readinto().
610610
[clinic start generated code]*/
611611

612612
static PyObject *
613613
_io_FileIO_readinto_impl(fileio *self, Py_buffer *buffer)
614-
/*[clinic end generated code: output=b01a5a22c8415cb4 input=5edd8327498d468c]*/
614+
/*[clinic end generated code: output=b01a5a22c8415cb4 input=4721d7b68b154eaf]*/
615615
{
616616
Py_ssize_t n;
617617
int err;

Modules/_io/textio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,9 @@ static encodefuncentry encodefuncs[] = {
789789
/*[clinic input]
790790
_io.TextIOWrapper.__init__
791791
buffer: object
792-
encoding: str(nullable=True) = NULL
793-
errors: str(nullable=True) = NULL
794-
newline: str(nullable=True) = NULL
792+
encoding: str(accept={str, NoneType}) = NULL
793+
errors: str(accept={str, NoneType}) = NULL
794+
newline: str(accept={str, NoneType}) = NULL
795795
line_buffering: int(c_default="0") = False
796796
write_through: int(c_default="0") = False
797797
@@ -830,7 +830,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
830830
const char *encoding, const char *errors,
831831
const char *newline, int line_buffering,
832832
int write_through)
833-
/*[clinic end generated code: output=56a83402ce2a8381 input=1f20decb8d54a4ec]*/
833+
/*[clinic end generated code: output=56a83402ce2a8381 input=3126cb3101a2c99b]*/
834834
{
835835
PyObject *raw, *codec_info = NULL;
836836
_PyIO_State *state = NULL;

Modules/_ssl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ _ssl__SSLSocket_pending_impl(PySSLSocket *self)
18771877
_ssl._SSLSocket.read
18781878
size as len: int
18791879
[
1880-
buffer: Py_buffer(types={'rwbuffer'})
1880+
buffer: Py_buffer(accept={rwbuffer})
18811881
]
18821882
/
18831883
@@ -1887,7 +1887,7 @@ Read up to size bytes from the SSL socket.
18871887
static PyObject *
18881888
_ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
18891889
Py_buffer *buffer)
1890-
/*[clinic end generated code: output=00097776cec2a0af input=4a0bbd2859e817b0]*/
1890+
/*[clinic end generated code: output=00097776cec2a0af input=ff157eb918d0905b]*/
18911891
{
18921892
PyObject *dest = NULL;
18931893
char *mem;
@@ -3799,7 +3799,7 @@ static PyTypeObject PySSLMemoryBIO_Type = {
37993799
/* helper routines for seeding the SSL PRNG */
38003800
/*[clinic input]
38013801
_ssl.RAND_add
3802-
string as view: Py_buffer(types={'str', 'buffer'})
3802+
string as view: Py_buffer(accept={str, buffer})
38033803
entropy: double
38043804
/
38053805
@@ -3811,7 +3811,7 @@ string. See RFC 1750.
38113811

38123812
static PyObject *
38133813
_ssl_RAND_add_impl(PyModuleDef *module, Py_buffer *view, double entropy)
3814-
/*[clinic end generated code: output=0f8d5c8cce328958 input=c98b11d606b354bc]*/
3814+
/*[clinic end generated code: output=0f8d5c8cce328958 input=580c85e6a3a4fe29]*/
38153815
{
38163816
const char *buf;
38173817
Py_ssize_t len, written;

0 commit comments

Comments
 (0)