New submission from Serhiy Storchaka:
There are a lot of format units supported in PyArg_Parse* functions, but some
of them are rarely or never used in current CPython code. Some of format units
are legacy from Python 2 and are not needed in modern Python 3 code or can be
replaced with custom converter.
Here are results of grepping (not including Modules/_testcapimodule.c).
"es", "es#", "et#", "z*", "Z#" are not used.
"y#":
Modules/_io/textio.c:2334: if (!PyArg_ParseTuple(_state, "y#i",
&dec_buffer, &dec_buffer_len, &dec_flags)) { \
"z#":
Modules/_ctypes/_ctypes.c:3327: if (!PyArg_ParseTuple(args, "is|Oz#",
&index, &name, ¶mflags, &iid, &iid_len))
"u#":
Modules/arraymodule.c:248: if (!PyArg_Parse(v, "u#;array item must be
unicode character", &p, &len))
PC/winreg.c:1547: if (!PyArg_ParseTuple(args, "OZiu#:SetValue",
"y":
Modules/_io/textio.c:2334: if (!PyArg_ParseTuple(_state, "y#i",
&dec_buffer, &dec_buffer_len, &dec_flags)) { \
Modules/_cursesmodule.c:2790: if (!PyArg_ParseTuple(args,"y;str", &str))
Modules/_cursesmodule.c:3026: if (!PyArg_ParseTuple(args,
"y|iiiiiiiii:tparm",
Modules/posixmodule.c:3767: if (!PyArg_ParseTuple (args,
"y:_getfullpathname",
Modules/posixmodule.c:3872: if (!PyArg_ParseTuple(args, "y:_isdir", &path))
Modules/faulthandler.c:941: if (!PyArg_ParseTuple(args, "y:fatal_error",
&message))
"et":
Modules/socketmodule.c:4499: if (!PyArg_ParseTuple(args, "et:gethostbyname",
"idna", &name))
Modules/socketmodule.c:4667: if (!PyArg_ParseTuple(args,
"et:gethostbyname_ex", "idna", &name))
Modules/socketmodule.c:4744: if (!PyArg_ParseTuple(args, "et:gethostbyaddr",
"idna", &ip_num))
Modules/_tkinter.c:2099: if (!PyArg_ParseTuple(args, "et:splitlist",
"utf-8", &list))
Modules/_tkinter.c:2162: if (!PyArg_ParseTuple(args, "et:split", "utf-8",
&list))
Modules/_ssl.c:3038: if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O!iet:_wrap_socket", kwlist,
Modules/_ssl.c:3070: if (!PyArg_Parse(hostname_obj, "et", "idna",
&hostname))
"s*":
Modules/_codecsmodule.c:188: if (!PyArg_ParseTuple(args,
"s*|z:escape_decode",
Modules/_codecsmodule.c:552: if (!PyArg_ParseTuple(args,
"s*|z:unicode_escape_decode",
Modules/_codecsmodule.c:569: if (!PyArg_ParseTuple(args,
"s*|z:raw_unicode_escape_decode",
Modules/_codecsmodule.c:696: if (!PyArg_ParseTuple(args,
"s*|z:readbuffer_encode",
Modules/_ssl.c:3734: if (!PyArg_ParseTuple(args, "s*d:RAND_add", &view,
&entropy))
Modules/fcntlmodule.c:225: if (PyArg_Parse(ob_arg, "s*:ioctl", &pstr)) {
Modules/clinic/arraymodule.c.h:278: if (!PyArg_Parse(arg, "s*:fromstring",
&buffer))
"s#":
Modules/_gdbmmodule.c:128: if (!PyArg_Parse(key, "s#", &krec.dptr,
&krec.dsize) )
Modules/_gdbmmodule.c:176: if (!PyArg_Parse(v, "s#", &krec.dptr,
&krec.dsize) ) {
Modules/_gdbmmodule.c:194: if (!PyArg_Parse(w, "s#", &drec.dptr,
&drec.dsize)) {
Modules/fcntlmodule.c:71: if (PyArg_Parse(arg, "s#", &str, &len)) {
Modules/_ctypes/_ctypes.c:2569: if (!PyArg_ParseTuple(args, "Os#", &dict,
&data, &len))
Modules/clinic/unicodedata.c.h:361: if (!PyArg_Parse(arg, "s#:lookup",
&name, &name_length))
Modules/clinic/_dbmmodule.c.h:62: if (!PyArg_ParseTuple(args, "s#|O:get",
Modules/clinic/_dbmmodule.c.h:95: if (!PyArg_ParseTuple(args,
"s#|O:setdefault",
Modules/clinic/_gdbmmodule.c.h:150: if (!PyArg_Parse(arg, "s#:nextkey",
&key, &key_length))
Modules/_dbmmodule.c:108: if (!PyArg_Parse(key, "s#", &krec.dptr, &tmp_size)
)
Modules/_dbmmodule.c:132: if ( !PyArg_Parse(v, "s#", &krec.dptr, &tmp_size)
) {
Modules/_dbmmodule.c:150: if ( !PyArg_Parse(w, "s#", &drec.dptr,
&tmp_size) ) {
Modules/_dbmmodule.c:336: if ( !PyArg_Parse(default_value, "s#",
&val.dptr, &tmp_size) ) {
In future may be we could deprecate some format units and remove them in 4.0.
This issue is a meta issue. Every case should be considered individually.
----------
assignee: serhiy.storchaka
components: Interpreter Core
messages: 241546
nosy: serhiy.storchaka
priority: low
severity: normal
status: open
title: Get rid of rare format units in PyArg_Parse*
type: enhancement
versions: Python 3.5, Python 3.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24009>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com