From 271403abe36069797ac332e1c6eae3473878db20 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Jan 2017 01:29:01 +0100 Subject: Rename _PyArg_ParseStack to _PyArg_ParseStackAndKeywords Issue #29286. --- Objects/clinic/bytesobject.c.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Objects/clinic/bytesobject.c.h') diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index a11ebd2774..dd1ec918bd 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -31,7 +31,7 @@ bytes_split(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kw PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &sep, &maxsplit)) { goto exit; } @@ -150,7 +150,7 @@ bytes_rsplit(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *k PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &sep, &maxsplit)) { goto exit; } @@ -296,7 +296,7 @@ bytes_translate(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *table; PyObject *deletechars = NULL; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &table, &deletechars)) { goto exit; } @@ -427,7 +427,7 @@ bytes_decode(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *k const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &encoding, &errors)) { goto exit; } @@ -460,7 +460,7 @@ bytes_splitlines(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObjec static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0}; int keepends = 0; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &keepends)) { goto exit; } -- cgit v1.2.1 From 7372e18fa83aa35766f8f6fdf3aed27fac2d52d2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Jan 2017 01:35:17 +0100 Subject: Run Argument Clinic: METH_VARARGS=>METH_FASTCALL Issue #29286. Run Argument Clinic to get the new faster METH_FASTCALL calling convention for functions using only positional arguments. --- Objects/clinic/bytesobject.c.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'Objects/clinic/bytesobject.c.h') diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index dd1ec918bd..330cb84853 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -318,22 +318,26 @@ PyDoc_STRVAR(bytes_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTES_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__}, + {"maketrans", (PyCFunction)bytes_maketrans, METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, static PyObject * bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); static PyObject * -bytes_maketrans(void *null, PyObject *args) +bytes_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:maketrans", + if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans", &frm, &to)) { goto exit; } + + if (!_PyArg_NoStackKeywords("maketrans", kwnames)) { + goto exit; + } return_value = bytes_maketrans_impl(&frm, &to); exit: @@ -363,24 +367,28 @@ PyDoc_STRVAR(bytes_replace__doc__, "replaced."); #define BYTES_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__}, + {"replace", (PyCFunction)bytes_replace, METH_FASTCALL, bytes_replace__doc__}, static PyObject * bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytes_replace(PyBytesObject *self, PyObject *args) +bytes_replace(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "y*y*|n:replace", + if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace", &old, &new, &count)) { goto exit; } + + if (!_PyArg_NoStackKeywords("replace", kwnames)) { + goto exit; + } return_value = bytes_replace_impl(self, &old, &new, count); exit: @@ -499,4 +507,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=2dc3c93cfd2dc440 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2b8d3cff7e11045e input=a9049054013a1b77]*/ -- cgit v1.2.1 From 104cb4a3bacdf9764f9f8670a80da16390231337 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Jan 2017 02:21:47 +0100 Subject: 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. --- Objects/clinic/bytesobject.c.h | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'Objects/clinic/bytesobject.c.h') diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index 330cb84853..c73b56023d 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -184,22 +184,26 @@ PyDoc_STRVAR(bytes_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTES_STRIP_METHODDEF \ - {"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__}, + {"strip", (PyCFunction)bytes_strip, METH_FASTCALL, bytes_strip__doc__}, static PyObject * bytes_strip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_strip(PyBytesObject *self, PyObject *args) +bytes_strip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "strip", + if (!_PyArg_UnpackStack(args, nargs, "strip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("strip", kwnames)) { + goto exit; + } return_value = bytes_strip_impl(self, bytes); exit: @@ -215,22 +219,26 @@ PyDoc_STRVAR(bytes_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTES_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__}, + {"lstrip", (PyCFunction)bytes_lstrip, METH_FASTCALL, bytes_lstrip__doc__}, static PyObject * bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_lstrip(PyBytesObject *self, PyObject *args) +bytes_lstrip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "lstrip", + if (!_PyArg_UnpackStack(args, nargs, "lstrip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("lstrip", kwnames)) { + goto exit; + } return_value = bytes_lstrip_impl(self, bytes); exit: @@ -246,22 +254,26 @@ PyDoc_STRVAR(bytes_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTES_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__}, + {"rstrip", (PyCFunction)bytes_rstrip, METH_FASTCALL, bytes_rstrip__doc__}, static PyObject * bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_rstrip(PyBytesObject *self, PyObject *args) +bytes_rstrip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "rstrip", + if (!_PyArg_UnpackStack(args, nargs, "rstrip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("rstrip", kwnames)) { + goto exit; + } return_value = bytes_rstrip_impl(self, bytes); exit: @@ -507,4 +519,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=2b8d3cff7e11045e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2504c1225108d348 input=a9049054013a1b77]*/ -- cgit v1.2.1