Commit e8725e66 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #23492: Argument Clinic now generates argument parsing code with

PyArg_Parse instead of PyArg_ParseTuple if possible.
parent 4adc9d28
......@@ -63,7 +63,7 @@ Library
Build
-----
- Issue #23501: Argumen Clinic now generates code into separate files by default.
- Issue #23501: Argument Clinic now generates code into separate files by default.
Tests
-----
......@@ -71,6 +71,13 @@ Tests
Tools/Demos
-----------
- Issue #23492: Argument Clinic now generates argument parsing code with
PyArg_Parse instead of PyArg_ParseTuple if possible.
- Issue #23500: Argument Clinic is now smarter about generating the "#ifndef"
(empty) definition of the methoddef macro: it's only generated once, even
if Argument Clinic processes the same symbol multiple times, and it's emitted
at the end of all processing rather than immediately after the first use.
What's New in Python 3.5.0 alpha 3?
......@@ -270,11 +277,6 @@ Tests
Tools/Demos
-----------
- Issue #23500: Argument Clinic is now smarter about generating the "#ifndef"
(empty) definition of the methoddef macro: it's only generated once, even
if Argument Clinic processes the same symbol multiple times, and it's emitted
at the end of all processing rather than immediately after the first use.
- Issue #22826: The result of open() in Tools/freeze/bkfile.py is now better
compatible with regular files (in particular it now supports the context
management protocol).
......
......@@ -14,18 +14,18 @@ PyDoc_STRVAR(_bz2_BZ2Compressor_compress__doc__,
"flush() method to finish the compression process.");
#define _BZ2_BZ2COMPRESSOR_COMPRESS_METHODDEF \
{"compress", (PyCFunction)_bz2_BZ2Compressor_compress, METH_VARARGS, _bz2_BZ2Compressor_compress__doc__},
{"compress", (PyCFunction)_bz2_BZ2Compressor_compress, METH_O, _bz2_BZ2Compressor_compress__doc__},
static PyObject *
_bz2_BZ2Compressor_compress_impl(BZ2Compressor *self, Py_buffer *data);
static PyObject *
_bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *args)
_bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:compress",
&data))
goto exit;
......@@ -168,4 +168,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=8e65e3953430bc3d input=a9049054013a1b77]*/
/*[clinic end generated code: output=3565d163a360af01 input=a9049054013a1b77]*/
......@@ -9,18 +9,18 @@ PyDoc_STRVAR(_codecs__forget_codec__doc__,
"Purge the named codec from the internal codec lookup cache");
#define _CODECS__FORGET_CODEC_METHODDEF \
{"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_VARARGS, _codecs__forget_codec__doc__},
{"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_O, _codecs__forget_codec__doc__},
static PyObject *
_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding);
static PyObject *
_codecs__forget_codec(PyModuleDef *module, PyObject *args)
_codecs__forget_codec(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
const char *encoding;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"s:_forget_codec",
&encoding))
goto exit;
......@@ -29,4 +29,4 @@ _codecs__forget_codec(PyModuleDef *module, PyObject *args)
exit:
return return_value;
}
/*[clinic end generated code: output=cdea83e21d76a900 input=a9049054013a1b77]*/
/*[clinic end generated code: output=fc5ce4d3166f7d96 input=a9049054013a1b77]*/
......@@ -14,18 +14,18 @@ PyDoc_STRVAR(_lzma_LZMACompressor_compress__doc__,
"flush() method to finish the compression process.");
#define _LZMA_LZMACOMPRESSOR_COMPRESS_METHODDEF \
{"compress", (PyCFunction)_lzma_LZMACompressor_compress, METH_VARARGS, _lzma_LZMACompressor_compress__doc__},
{"compress", (PyCFunction)_lzma_LZMACompressor_compress, METH_O, _lzma_LZMACompressor_compress__doc__},
static PyObject *
_lzma_LZMACompressor_compress_impl(Compressor *self, Py_buffer *data);
static PyObject *
_lzma_LZMACompressor_compress(Compressor *self, PyObject *args)
_lzma_LZMACompressor_compress(Compressor *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:compress",
&data))
goto exit;
......@@ -162,18 +162,18 @@ PyDoc_STRVAR(_lzma_is_check_supported__doc__,
"Always returns True for CHECK_NONE and CHECK_CRC32.");
#define _LZMA_IS_CHECK_SUPPORTED_METHODDEF \
{"is_check_supported", (PyCFunction)_lzma_is_check_supported, METH_VARARGS, _lzma_is_check_supported__doc__},
{"is_check_supported", (PyCFunction)_lzma_is_check_supported, METH_O, _lzma_is_check_supported__doc__},
static PyObject *
_lzma_is_check_supported_impl(PyModuleDef *module, int check_id);
static PyObject *
_lzma_is_check_supported(PyModuleDef *module, PyObject *args)
_lzma_is_check_supported(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
int check_id;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"i:is_check_supported",
&check_id))
goto exit;
......@@ -192,18 +192,18 @@ PyDoc_STRVAR(_lzma__encode_filter_properties__doc__,
"The result does not include the filter ID itself, only the options.");
#define _LZMA__ENCODE_FILTER_PROPERTIES_METHODDEF \
{"_encode_filter_properties", (PyCFunction)_lzma__encode_filter_properties, METH_VARARGS, _lzma__encode_filter_properties__doc__},
{"_encode_filter_properties", (PyCFunction)_lzma__encode_filter_properties, METH_O, _lzma__encode_filter_properties__doc__},
static PyObject *
_lzma__encode_filter_properties_impl(PyModuleDef *module, lzma_filter filter);
static PyObject *
_lzma__encode_filter_properties(PyModuleDef *module, PyObject *args)
_lzma__encode_filter_properties(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
lzma_filter filter = {LZMA_VLI_UNKNOWN, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:_encode_filter_properties",
lzma_filter_converter, &filter))
goto exit;
......@@ -251,4 +251,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=dc42b73890609369 input=a9049054013a1b77]*/
/*[clinic end generated code: output=ea7f2b2c4019fe86 input=a9049054013a1b77]*/
......@@ -267,18 +267,18 @@ PyDoc_STRVAR(array_array_fromstring__doc__,
"This method is deprecated. Use frombytes instead.");
#define ARRAY_ARRAY_FROMSTRING_METHODDEF \
{"fromstring", (PyCFunction)array_array_fromstring, METH_VARARGS, array_array_fromstring__doc__},
{"fromstring", (PyCFunction)array_array_fromstring, METH_O, array_array_fromstring__doc__},
static PyObject *
array_array_fromstring_impl(arrayobject *self, Py_buffer *buffer);
static PyObject *
array_array_fromstring(arrayobject *self, PyObject *args)
array_array_fromstring(arrayobject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"s*:fromstring",
&buffer))
goto exit;
......@@ -299,18 +299,18 @@ PyDoc_STRVAR(array_array_frombytes__doc__,
"Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).");
#define ARRAY_ARRAY_FROMBYTES_METHODDEF \
{"frombytes", (PyCFunction)array_array_frombytes, METH_VARARGS, array_array_frombytes__doc__},
{"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__},
static PyObject *
array_array_frombytes_impl(arrayobject *self, Py_buffer *buffer);
static PyObject *
array_array_frombytes(arrayobject *self, PyObject *args)
array_array_frombytes(arrayobject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:frombytes",
&buffer))
goto exit;
......@@ -373,19 +373,19 @@ PyDoc_STRVAR(array_array_fromunicode__doc__,
"some other type.");
#define ARRAY_ARRAY_FROMUNICODE_METHODDEF \
{"fromunicode", (PyCFunction)array_array_fromunicode, METH_VARARGS, array_array_fromunicode__doc__},
{"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
static PyObject *
array_array_fromunicode_impl(arrayobject *self, Py_UNICODE *ustr, Py_ssize_clean_t ustr_length);
static PyObject *
array_array_fromunicode(arrayobject *self, PyObject *args)
array_array_fromunicode(arrayobject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_UNICODE *ustr;
Py_ssize_clean_t ustr_length;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"u#:fromunicode",
&ustr, &ustr_length))
goto exit;
......@@ -502,4 +502,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
/*[clinic end generated code: output=e1deb61c6a3bc8c8 input=a9049054013a1b77]*/
/*[clinic end generated code: output=a8fbe83c2026fa83 input=a9049054013a1b77]*/
......@@ -9,18 +9,18 @@ PyDoc_STRVAR(binascii_a2b_uu__doc__,
"Decode a line of uuencoded data.");
#define BINASCII_A2B_UU_METHODDEF \
{"a2b_uu", (PyCFunction)binascii_a2b_uu, METH_VARARGS, binascii_a2b_uu__doc__},
{"a2b_uu", (PyCFunction)binascii_a2b_uu, METH_O, binascii_a2b_uu__doc__},
static PyObject *
binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_a2b_uu(PyModuleDef *module, PyObject *args)
binascii_a2b_uu(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:a2b_uu",
ascii_buffer_converter, &data))
goto exit;
......@@ -41,18 +41,18 @@ PyDoc_STRVAR(binascii_b2a_uu__doc__,
"Uuencode line of data.");
#define BINASCII_B2A_UU_METHODDEF \
{"b2a_uu", (PyCFunction)binascii_b2a_uu, METH_VARARGS, binascii_b2a_uu__doc__},
{"b2a_uu", (PyCFunction)binascii_b2a_uu, METH_O, binascii_b2a_uu__doc__},
static PyObject *
binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_b2a_uu(PyModuleDef *module, PyObject *args)
binascii_b2a_uu(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:b2a_uu",
&data))
goto exit;
......@@ -73,18 +73,18 @@ PyDoc_STRVAR(binascii_a2b_base64__doc__,
"Decode a line of base64 data.");
#define BINASCII_A2B_BASE64_METHODDEF \
{"a2b_base64", (PyCFunction)binascii_a2b_base64, METH_VARARGS, binascii_a2b_base64__doc__},
{"a2b_base64", (PyCFunction)binascii_a2b_base64, METH_O, binascii_a2b_base64__doc__},
static PyObject *
binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_a2b_base64(PyModuleDef *module, PyObject *args)
binascii_a2b_base64(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:a2b_base64",
ascii_buffer_converter, &data))
goto exit;
......@@ -105,18 +105,18 @@ PyDoc_STRVAR(binascii_b2a_base64__doc__,
"Base64-code line of data.");
#define BINASCII_B2A_BASE64_METHODDEF \
{"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_VARARGS, binascii_b2a_base64__doc__},
{"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_O, binascii_b2a_base64__doc__},
static PyObject *
binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_b2a_base64(PyModuleDef *module, PyObject *args)
binascii_b2a_base64(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:b2a_base64",
&data))
goto exit;
......@@ -137,18 +137,18 @@ PyDoc_STRVAR(binascii_a2b_hqx__doc__,
"Decode .hqx coding.");
#define BINASCII_A2B_HQX_METHODDEF \
{"a2b_hqx", (PyCFunction)binascii_a2b_hqx, METH_VARARGS, binascii_a2b_hqx__doc__},
{"a2b_hqx", (PyCFunction)binascii_a2b_hqx, METH_O, binascii_a2b_hqx__doc__},
static PyObject *
binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_a2b_hqx(PyModuleDef *module, PyObject *args)
binascii_a2b_hqx(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:a2b_hqx",
ascii_buffer_converter, &data))
goto exit;
......@@ -169,18 +169,18 @@ PyDoc_STRVAR(binascii_rlecode_hqx__doc__,
"Binhex RLE-code binary data.");
#define BINASCII_RLECODE_HQX_METHODDEF \
{"rlecode_hqx", (PyCFunction)binascii_rlecode_hqx, METH_VARARGS, binascii_rlecode_hqx__doc__},
{"rlecode_hqx", (PyCFunction)binascii_rlecode_hqx, METH_O, binascii_rlecode_hqx__doc__},
static PyObject *
binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_rlecode_hqx(PyModuleDef *module, PyObject *args)
binascii_rlecode_hqx(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:rlecode_hqx",
&data))
goto exit;
......@@ -201,18 +201,18 @@ PyDoc_STRVAR(binascii_b2a_hqx__doc__,
"Encode .hqx data.");
#define BINASCII_B2A_HQX_METHODDEF \
{"b2a_hqx", (PyCFunction)binascii_b2a_hqx, METH_VARARGS, binascii_b2a_hqx__doc__},
{"b2a_hqx", (PyCFunction)binascii_b2a_hqx, METH_O, binascii_b2a_hqx__doc__},
static PyObject *
binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_b2a_hqx(PyModuleDef *module, PyObject *args)
binascii_b2a_hqx(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:b2a_hqx",
&data))
goto exit;
......@@ -233,18 +233,18 @@ PyDoc_STRVAR(binascii_rledecode_hqx__doc__,
"Decode hexbin RLE-coded string.");
#define BINASCII_RLEDECODE_HQX_METHODDEF \
{"rledecode_hqx", (PyCFunction)binascii_rledecode_hqx, METH_VARARGS, binascii_rledecode_hqx__doc__},
{"rledecode_hqx", (PyCFunction)binascii_rledecode_hqx, METH_O, binascii_rledecode_hqx__doc__},
static PyObject *
binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_rledecode_hqx(PyModuleDef *module, PyObject *args)
binascii_rledecode_hqx(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:rledecode_hqx",
&data))
goto exit;
......@@ -342,18 +342,18 @@ PyDoc_STRVAR(binascii_b2a_hex__doc__,
"available as \"hexlify()\".");
#define BINASCII_B2A_HEX_METHODDEF \
{"b2a_hex", (PyCFunction)binascii_b2a_hex, METH_VARARGS, binascii_b2a_hex__doc__},
{"b2a_hex", (PyCFunction)binascii_b2a_hex, METH_O, binascii_b2a_hex__doc__},
static PyObject *
binascii_b2a_hex_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_b2a_hex(PyModuleDef *module, PyObject *args)
binascii_b2a_hex(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:b2a_hex",
&data))
goto exit;
......@@ -376,18 +376,18 @@ PyDoc_STRVAR(binascii_hexlify__doc__,
"The return value is a bytes object.");
#define BINASCII_HEXLIFY_METHODDEF \
{"hexlify", (PyCFunction)binascii_hexlify, METH_VARARGS, binascii_hexlify__doc__},
{"hexlify", (PyCFunction)binascii_hexlify, METH_O, binascii_hexlify__doc__},
static PyObject *
binascii_hexlify_impl(PyModuleDef *module, Py_buffer *data);
static PyObject *
binascii_hexlify(PyModuleDef *module, PyObject *args)
binascii_hexlify(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:hexlify",
&data))
goto exit;
......@@ -411,18 +411,18 @@ PyDoc_STRVAR(binascii_a2b_hex__doc__,
"This function is also available as \"unhexlify()\".");
#define BINASCII_A2B_HEX_METHODDEF \
{"a2b_hex", (PyCFunction)binascii_a2b_hex, METH_VARARGS, binascii_a2b_hex__doc__},
{"a2b_hex", (PyCFunction)binascii_a2b_hex, METH_O, binascii_a2b_hex__doc__},
static PyObject *
binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr);
static PyObject *
binascii_a2b_hex(PyModuleDef *module, PyObject *args)
binascii_a2b_hex(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer hexstr = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:a2b_hex",
ascii_buffer_converter, &hexstr))
goto exit;
......@@ -445,18 +445,18 @@ PyDoc_STRVAR(binascii_unhexlify__doc__,
"hexstr must contain an even number of hex digits (upper or lower case).");
#define BINASCII_UNHEXLIFY_METHODDEF \
{"unhexlify", (PyCFunction)binascii_unhexlify, METH_VARARGS, binascii_unhexlify__doc__},
{"unhexlify", (PyCFunction)binascii_unhexlify, METH_O, binascii_unhexlify__doc__},
static PyObject *
binascii_unhexlify_impl(PyModuleDef *module, Py_buffer *hexstr);
static PyObject *
binascii_unhexlify(PyModuleDef *module, PyObject *args)
binascii_unhexlify(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer hexstr = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:unhexlify",
ascii_buffer_converter, &hexstr))
goto exit;
......@@ -543,4 +543,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=771126f8f53e84e7 input=a9049054013a1b77]*/
/*[clinic end generated code: output=31ccbd5fddc8fd75 input=a9049054013a1b77]*/
This diff is collapsed.
This diff is collapsed.
......@@ -22,18 +22,18 @@ PyDoc_STRVAR(pwd_getpwnam__doc__,
"See `help(pwd)` for more on password database entries.");
#define PWD_GETPWNAM_METHODDEF \
{"getpwnam", (PyCFunction)pwd_getpwnam, METH_VARARGS, pwd_getpwnam__doc__},
{"getpwnam", (PyCFunction)pwd_getpwnam, METH_O, pwd_getpwnam__doc__},
static PyObject *
pwd_getpwnam_impl(PyModuleDef *module, PyObject *arg);
static PyObject *
pwd_getpwnam(PyModuleDef *module, PyObject *args)
pwd_getpwnam(PyModuleDef *module, PyObject *arg_)
{
PyObject *return_value = NULL;
PyObject *arg;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg_,
"U:getpwnam",
&arg))
goto exit;
......@@ -70,4 +70,4 @@ pwd_getpwall(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
#ifndef PWD_GETPWALL_METHODDEF
#define PWD_GETPWALL_METHODDEF
#endif /* !defined(PWD_GETPWALL_METHODDEF) */
/*[clinic end generated code: output=2e23f920020a750a input=a9049054013a1b77]*/
/*[clinic end generated code: output=e7d5ac24b20e91ae input=a9049054013a1b77]*/
......@@ -49,18 +49,18 @@ PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__,
"Set the base URL for the parser.");
#define PYEXPAT_XMLPARSER_SETBASE_METHODDEF \
{"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_VARARGS, pyexpat_xmlparser_SetBase__doc__},
{"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_O, pyexpat_xmlparser_SetBase__doc__},
static PyObject *
pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base);
static PyObject *
pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *args)
pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
{
PyObject *return_value = NULL;
const char *base;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"s:SetBase",
&base))
goto exit;
......@@ -150,18 +150,18 @@ PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__,
"was successful.");
#define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF \
{"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_VARARGS, pyexpat_xmlparser_SetParamEntityParsing__doc__},
{"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_O, pyexpat_xmlparser_SetParamEntityParsing__doc__},
static PyObject *
pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag);
static PyObject *
pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *args)
pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
{
PyObject *return_value = NULL;
int flag;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"i:SetParamEntityParsing",
&flag))
goto exit;
......@@ -262,18 +262,18 @@ PyDoc_STRVAR(pyexpat_ErrorString__doc__,
"Returns string error for given number.");
#define PYEXPAT_ERRORSTRING_METHODDEF \
{"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_VARARGS, pyexpat_ErrorString__doc__},
{"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_O, pyexpat_ErrorString__doc__},
static PyObject *
pyexpat_ErrorString_impl(PyModuleDef *module, long code);
static PyObject *
pyexpat_ErrorString(PyModuleDef *module, PyObject *args)
pyexpat_ErrorString(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
long code;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"l:ErrorString",
&code))
goto exit;
......@@ -286,4 +286,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
/*[clinic end generated code: output=0198390005e40e1c input=a9049054013a1b77]*/
/*[clinic end generated code: output=9715b916f2d618fa input=a9049054013a1b77]*/
......@@ -13,18 +13,18 @@ PyDoc_STRVAR(spwd_getspnam__doc__,
"See `help(spwd)` for more on shadow password database entries.");
#define SPWD_GETSPNAM_METHODDEF \
{"getspnam", (PyCFunction)spwd_getspnam, METH_VARARGS, spwd_getspnam__doc__},
{"getspnam", (PyCFunction)spwd_getspnam, METH_O, spwd_getspnam__doc__},
static PyObject *
spwd_getspnam_impl(PyModuleDef *module, PyObject *arg);
static PyObject *
spwd_getspnam(PyModuleDef *module, PyObject *args)
spwd_getspnam(PyModuleDef *module, PyObject *arg_)
{
PyObject *return_value = NULL;
PyObject *arg;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg_,
"U:getspnam",
&arg))
goto exit;
......@@ -67,4 +67,4 @@ spwd_getspall(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
#ifndef SPWD_GETSPALL_METHODDEF
#define SPWD_GETSPALL_METHODDEF
#endif /* !defined(SPWD_GETSPALL_METHODDEF) */
/*[clinic end generated code: output=ab16125c5e5f2b1b input=a9049054013a1b77]*/
/*[clinic end generated code: output=67a4f8c47008f28f input=a9049054013a1b77]*/
......@@ -189,18 +189,18 @@ PyDoc_STRVAR(zlib_Compress_compress__doc__,
"Call the flush() method to clear these buffers.");
#define ZLIB_COMPRESS_COMPRESS_METHODDEF \
{"compress", (PyCFunction)zlib_Compress_compress, METH_VARARGS, zlib_Compress_compress__doc__},
{"compress", (PyCFunction)zlib_Compress_compress, METH_O, zlib_Compress_compress__doc__},
static PyObject *
zlib_Compress_compress_impl(compobject *self, Py_buffer *data);
static PyObject *
zlib_Compress_compress(compobject *self, PyObject *args)
zlib_Compress_compress(compobject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:compress",
&data))
goto exit;
......@@ -446,4 +446,4 @@ exit:
#ifndef ZLIB_COMPRESS_COPY_METHODDEF
#define ZLIB_COMPRESS_COPY_METHODDEF
#endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
/*[clinic end generated code: output=901c18189767dc08 input=a9049054013a1b77]*/
/*[clinic end generated code: output=0743b1aa908f0b68 input=a9049054013a1b77]*/
......@@ -339,18 +339,18 @@ PyDoc_STRVAR(bytearray_append__doc__,
" The item to be appended.");
#define BYTEARRAY_APPEND_METHODDEF \
{"append", (PyCFunction)bytearray_append, METH_VARARGS, bytearray_append__doc__},
{"append", (PyCFunction)bytearray_append, METH_O, bytearray_append__doc__},
static PyObject *
bytearray_append_impl(PyByteArrayObject *self, int item);
static PyObject *
bytearray_append(PyByteArrayObject *self, PyObject *args)
bytearray_append(PyByteArrayObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
int item;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:append",
_getbytevalue, &item))
goto exit;
......@@ -416,18 +416,18 @@ PyDoc_STRVAR(bytearray_remove__doc__,
" The value to remove.");
#define BYTEARRAY_REMOVE_METHODDEF \
{"remove", (PyCFunction)bytearray_remove, METH_VARARGS, bytearray_remove__doc__},
{"remove", (PyCFunction)bytearray_remove, METH_O, bytearray_remove__doc__},
static PyObject *
bytearray_remove_impl(PyByteArrayObject *self, int value);
static PyObject *
bytearray_remove(PyByteArrayObject *self, PyObject *args)
bytearray_remove(PyByteArrayObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
int value;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"O&:remove",
_getbytevalue, &value))
goto exit;
......@@ -621,18 +621,18 @@ PyDoc_STRVAR(bytearray_fromhex__doc__,
"Example: bytearray.fromhex(\'B9 01EF\') -> bytearray(b\'\\\\xb9\\\\x01\\\\xef\')");
#define BYTEARRAY_FROMHEX_METHODDEF \
{"fromhex", (PyCFunction)bytearray_fromhex, METH_VARARGS|METH_CLASS, bytearray_fromhex__doc__},
{"fromhex", (PyCFunction)bytearray_fromhex, METH_O|METH_CLASS, bytearray_fromhex__doc__},
static PyObject *
bytearray_fromhex_impl(PyObject*cls, PyObject *string);
static PyObject *
bytearray_fromhex(PyTypeObject *cls, PyObject *args)
bytearray_fromhex(PyTypeObject *cls, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *string;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:fromhex",
&string))
goto exit;
......@@ -705,4 +705,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
/*[clinic end generated code: output=70ea384faeca8d16 input=a9049054013a1b77]*/
/*[clinic end generated code: output=d763876718a66fc3 input=a9049054013a1b77]*/
......@@ -54,18 +54,18 @@ PyDoc_STRVAR(bytes_partition__doc__,
"object and two empty bytes objects.");
#define BYTES_PARTITION_METHODDEF \
{"partition", (PyCFunction)bytes_partition, METH_VARARGS, bytes_partition__doc__},
{"partition", (PyCFunction)bytes_partition, METH_O, bytes_partition__doc__},
static PyObject *
bytes_partition_impl(PyBytesObject *self, Py_buffer *sep);
static PyObject *
bytes_partition(PyBytesObject *self, PyObject *args)
bytes_partition(PyBytesObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:partition",
&sep))
goto exit;
......@@ -93,18 +93,18 @@ PyDoc_STRVAR(bytes_rpartition__doc__,
"objects and the original bytes object.");
#define BYTES_RPARTITION_METHODDEF \
{"rpartition", (PyCFunction)bytes_rpartition, METH_VARARGS, bytes_rpartition__doc__},
{"rpartition", (PyCFunction)bytes_rpartition, METH_O, bytes_rpartition__doc__},
static PyObject *
bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep);
static PyObject *
bytes_rpartition(PyBytesObject *self, PyObject *args)
bytes_rpartition(PyBytesObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"y*:rpartition",
&sep))
goto exit;
......@@ -473,18 +473,18 @@ PyDoc_STRVAR(bytes_fromhex__doc__,
"Example: bytes.fromhex(\'B9 01EF\') -> b\'\\\\xb9\\\\x01\\\\xef\'.");
#define BYTES_FROMHEX_METHODDEF \
{"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS, bytes_fromhex__doc__},
{"fromhex", (PyCFunction)bytes_fromhex, METH_O|METH_CLASS, bytes_fromhex__doc__},
static PyObject *
bytes_fromhex_impl(PyTypeObject *type, PyObject *string);
static PyObject *
bytes_fromhex(PyTypeObject *type, PyObject *args)
bytes_fromhex(PyTypeObject *type, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *string;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:fromhex",
&string))
goto exit;
......@@ -493,4 +493,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *args)
exit:
return return_value;
}
/*[clinic end generated code: output=dfe5c9a317b99f49 input=a9049054013a1b77]*/
/*[clinic end generated code: output=b9e69e1f7c8ccd14 input=a9049054013a1b77]*/
......@@ -109,18 +109,18 @@ PyDoc_STRVAR(builtin_chr__doc__,
"Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.");
#define BUILTIN_CHR_METHODDEF \
{"chr", (PyCFunction)builtin_chr, METH_VARARGS, builtin_chr__doc__},
{"chr", (PyCFunction)builtin_chr, METH_O, builtin_chr__doc__},
static PyObject *
builtin_chr_impl(PyModuleDef *module, int i);
static PyObject *
builtin_chr(PyModuleDef *module, PyObject *args)
builtin_chr(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
int i;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"i:chr",
&i))
goto exit;
......@@ -656,4 +656,4 @@ builtin_issubclass(PyModuleDef *module, PyObject *args)
exit:
return return_value;
}
/*[clinic end generated code: output=2da46de189e48d26 input=a9049054013a1b77]*/
/*[clinic end generated code: output=12db4cde92eb11b3 input=a9049054013a1b77]*/
......@@ -122,18 +122,18 @@ PyDoc_STRVAR(_imp_init_builtin__doc__,
"Initializes a built-in module.");
#define _IMP_INIT_BUILTIN_METHODDEF \
{"init_builtin", (PyCFunction)_imp_init_builtin, METH_VARARGS, _imp_init_builtin__doc__},
{"init_builtin", (PyCFunction)_imp_init_builtin, METH_O, _imp_init_builtin__doc__},
static PyObject *
_imp_init_builtin_impl(PyModuleDef *module, PyObject *name);
static PyObject *
_imp_init_builtin(PyModuleDef *module, PyObject *args)
_imp_init_builtin(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:init_builtin",
&name))
goto exit;
......@@ -150,18 +150,18 @@ PyDoc_STRVAR(_imp_init_frozen__doc__,
"Initializes a frozen module.");
#define _IMP_INIT_FROZEN_METHODDEF \
{"init_frozen", (PyCFunction)_imp_init_frozen, METH_VARARGS, _imp_init_frozen__doc__},
{"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, _imp_init_frozen__doc__},
static PyObject *
_imp_init_frozen_impl(PyModuleDef *module, PyObject *name);
static PyObject *
_imp_init_frozen(PyModuleDef *module, PyObject *args)
_imp_init_frozen(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:init_frozen",
&name))
goto exit;
......@@ -178,18 +178,18 @@ PyDoc_STRVAR(_imp_get_frozen_object__doc__,
"Create a code object for a frozen module.");
#define _IMP_GET_FROZEN_OBJECT_METHODDEF \
{"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_VARARGS, _imp_get_frozen_object__doc__},
{"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_O, _imp_get_frozen_object__doc__},
static PyObject *
_imp_get_frozen_object_impl(PyModuleDef *module, PyObject *name);
static PyObject *
_imp_get_frozen_object(PyModuleDef *module, PyObject *args)
_imp_get_frozen_object(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:get_frozen_object",
&name))
goto exit;
......@@ -206,18 +206,18 @@ PyDoc_STRVAR(_imp_is_frozen_package__doc__,
"Returns True if the module name is of a frozen package.");
#define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
{"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_VARARGS, _imp_is_frozen_package__doc__},
{"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, _imp_is_frozen_package__doc__},
static PyObject *
_imp_is_frozen_package_impl(PyModuleDef *module, PyObject *name);
static PyObject *
_imp_is_frozen_package(PyModuleDef *module, PyObject *args)
_imp_is_frozen_package(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:is_frozen_package",
&name))
goto exit;
......@@ -234,18 +234,18 @@ PyDoc_STRVAR(_imp_is_builtin__doc__,
"Returns True if the module name corresponds to a built-in module.");
#define _IMP_IS_BUILTIN_METHODDEF \
{"is_builtin", (PyCFunction)_imp_is_builtin, METH_VARARGS, _imp_is_builtin__doc__},
{"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
static PyObject *
_imp_is_builtin_impl(PyModuleDef *module, PyObject *name);
static PyObject *
_imp_is_builtin(PyModuleDef *module, PyObject *args)
_imp_is_builtin(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:is_builtin",
&name))
goto exit;
......@@ -262,18 +262,18 @@ PyDoc_STRVAR(_imp_is_frozen__doc__,
"Returns True if the module name corresponds to a frozen module.");
#define _IMP_IS_FROZEN_METHODDEF \
{"is_frozen", (PyCFunction)_imp_is_frozen, METH_VARARGS, _imp_is_frozen__doc__},
{"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
static PyObject *
_imp_is_frozen_impl(PyModuleDef *module, PyObject *name);
static PyObject *
_imp_is_frozen(PyModuleDef *module, PyObject *args)
_imp_is_frozen(PyModuleDef *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_ParseTuple(args,
if (!PyArg_Parse(arg,
"U:is_frozen",
&name))
goto exit;
......@@ -320,4 +320,4 @@ exit:
#ifndef _IMP_LOAD_DYNAMIC_METHODDEF
#define _IMP_LOAD_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_LOAD_DYNAMIC_METHODDEF) */
/*[clinic end generated code: output=087a1f22e9febcc7 input=a9049054013a1b77]*/
/*[clinic end generated code: output=d41c392510815c5b input=a9049054013a1b77]*/
......@@ -593,8 +593,6 @@ class CLanguage(Language):
meth_o = (len(parameters) == 1 and
parameters[0].kind == inspect.Parameter.POSITIONAL_ONLY and
not converters[0].is_optional() and
isinstance(converters[0], object_converter) and
converters[0].format_unit == 'O' and
not new_or_init)
# we have to set these things before we're done:
......@@ -700,22 +698,40 @@ class CLanguage(Language):
elif meth_o:
flags = "METH_O"
meth_o_prototype = normalize_snippet("""
static PyObject *
{c_basename}({impl_parameters})
""")
if (isinstance(converters[0], object_converter) and
converters[0].format_unit == 'O'):
meth_o_prototype = normalize_snippet("""
static PyObject *
{c_basename}({impl_parameters})
""")
if default_return_converter:
# maps perfectly to METH_O, doesn't need a return converter.
# so we skip making a parse function
# and call directly into the impl function.
impl_prototype = parser_prototype = parser_definition = ''
impl_definition = meth_o_prototype
else:
# SLIGHT HACK
# use impl_parameters for the parser here!
parser_prototype = meth_o_prototype
parser_definition = parser_body(parser_prototype)
if default_return_converter:
# maps perfectly to METH_O, doesn't need a return converter.
# so we skip making a parse function
# and call directly into the impl function.
impl_prototype = parser_prototype = parser_definition = ''
impl_definition = meth_o_prototype
else:
# SLIGHT HACK
# use impl_parameters for the parser here!
parser_prototype = meth_o_prototype
parser_definition = parser_body(parser_prototype)
argname = 'arg'
if parameters[0].name == argname:
argname += '_'
parser_prototype = normalize_snippet("""
static PyObject *
{c_basename}({self_type}{self_name}, PyObject *%s)
""" % argname)
parser_definition = parser_body(parser_prototype, normalize_snippet("""
if (!PyArg_Parse(%s,
"{format_units}:{name}",
{parse_arguments}))
goto exit;
""" % argname, indent=4))
elif has_option_groups:
# positional parameters with option groups
......@@ -1025,7 +1041,7 @@ class CLanguage(Language):
# METH_O, we have exactly one anyway, so we know exactly
# where it is.
if ("METH_O" in templates['methoddef_define'] and
not default_return_converter):
'{impl_parameters}' in templates['parser_prototype']):
data.declarations.pop(0)
template_dict = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment