From 475f0a6b161b7c1513e0e42d18dc3ee6e293cdf3 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 24 Mar 2022 13:41:55 +0100 Subject: [PATCH 1/7] refactor implementation of lstrip, rstrip and strip for the bytearray object --- Objects/bytearrayobject.c | 104 +++++++---------------------- Objects/clinic/bytearrayobject.c.h | 6 +- 2 files changed, 29 insertions(+), 81 deletions(-) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index cbe673acd0a3a9..9d2ced53bf0e98 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1838,7 +1838,7 @@ bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index) buf = PyByteArray_AS_STRING(self); value = buf[index]; memmove(buf + index, buf + index + 1, n - index); - if (PyByteArray_Resize((PyObject *)self, n - 1) < 0) + if (PyByteArray_Resize((PyObject*)self, n - 1) < 0) return NULL; return PyLong_FromLong((unsigned char)value); @@ -1855,7 +1855,7 @@ Remove the first occurrence of a value in the bytearray. [clinic start generated code]*/ static PyObject * -bytearray_remove_impl(PyByteArrayObject *self, int value) +bytearray_remove_impl(PyByteArrayObject* self, int value) /*[clinic end generated code: output=d659e37866709c13 input=121831240cd51ddf]*/ { Py_ssize_t where, n = Py_SIZE(self); @@ -1876,27 +1876,6 @@ bytearray_remove_impl(PyByteArrayObject *self, int value) Py_RETURN_NONE; } -/* XXX These two helpers could be optimized if argsize == 1 */ - -static Py_ssize_t -lstrip_helper(const char *myptr, Py_ssize_t mysize, - const void *argptr, Py_ssize_t argsize) -{ - Py_ssize_t i = 0; - while (i < mysize && memchr(argptr, (unsigned char) myptr[i], argsize)) - i++; - return i; -} - -static Py_ssize_t -rstrip_helper(const char *myptr, Py_ssize_t mysize, - const void *argptr, Py_ssize_t argsize) -{ - Py_ssize_t i = mysize - 1; - while (i >= 0 && memchr(argptr, (unsigned char) myptr[i], argsize)) - i--; - return i + 1; -} /*[clinic input] bytearray.strip @@ -1909,13 +1888,13 @@ Strip leading and trailing bytes contained in the argument. If the argument is omitted or None, strip leading and trailing ASCII whitespace. [clinic start generated code]*/ -static PyObject * -bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes) +static PyObject* +bytearray_strip_impl(PyByteArrayObject* self, PyObject* bytes, enum StripType striptype) /*[clinic end generated code: output=760412661a34ad5a input=ef7bb59b09c21d62]*/ { - Py_ssize_t left, right, mysize, byteslen; - char *myptr; - const char *bytesptr; + Py_ssize_t mysize, byteslen; + const char* myptr; + const char* bytesptr; Py_buffer vbytes; if (bytes == Py_None) { @@ -1925,16 +1904,24 @@ bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes) else { if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0) return NULL; - bytesptr = (const char *) vbytes.buf; + bytesptr = (const char*)vbytes.buf; byteslen = vbytes.len; } myptr = PyByteArray_AS_STRING(self); mysize = Py_SIZE(self); - left = lstrip_helper(myptr, mysize, bytesptr, byteslen); - if (left == mysize) - right = left; - else - right = rstrip_helper(myptr, mysize, bytesptr, byteslen); + + Py_ssize_t left = 0; + if (striptype != RIGHTSTRIP) { + while (left < mysize && memchr(bytesptr, (unsigned char)myptr[left], byteslen)) + left++; + } + Py_ssize_t right = mysize; + if (striptype != LEFTSTRIP) { + do { + right--; + } while (right >= left && memchr(bytesptr, (unsigned char)myptr[right], byteslen)); + right++; + } if (bytes != Py_None) PyBuffer_Release(&vbytes); return PyByteArray_FromStringAndSize(myptr + left, right - left); @@ -1951,32 +1938,11 @@ Strip leading bytes contained in the argument. If the argument is omitted or None, strip leading ASCII whitespace. [clinic start generated code]*/ -static PyObject * +static inline PyObject * bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes) /*[clinic end generated code: output=d005c9d0ab909e66 input=80843f975dd7c480]*/ { - Py_ssize_t left, right, mysize, byteslen; - char *myptr; - const char *bytesptr; - Py_buffer vbytes; - - if (bytes == Py_None) { - bytesptr = "\t\n\r\f\v "; - byteslen = 6; - } - else { - if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0) - return NULL; - bytesptr = (const char *) vbytes.buf; - byteslen = vbytes.len; - } - myptr = PyByteArray_AS_STRING(self); - mysize = Py_SIZE(self); - left = lstrip_helper(myptr, mysize, bytesptr, byteslen); - right = mysize; - if (bytes != Py_None) - PyBuffer_Release(&vbytes); - return PyByteArray_FromStringAndSize(myptr + left, right - left); + return bytearray_strip_impl(self, bytes, LEFTSTRIP); } /*[clinic input] @@ -1990,31 +1956,11 @@ Strip trailing bytes contained in the argument. If the argument is omitted or None, strip trailing ASCII whitespace. [clinic start generated code]*/ -static PyObject * +static inline PyObject * bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes) /*[clinic end generated code: output=030e2fbd2f7276bd input=e728b994954cfd91]*/ { - Py_ssize_t right, mysize, byteslen; - char *myptr; - const char *bytesptr; - Py_buffer vbytes; - - if (bytes == Py_None) { - bytesptr = "\t\n\r\f\v "; - byteslen = 6; - } - else { - if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0) - return NULL; - bytesptr = (const char *) vbytes.buf; - byteslen = vbytes.len; - } - myptr = PyByteArray_AS_STRING(self); - mysize = Py_SIZE(self); - right = rstrip_helper(myptr, mysize, bytesptr, byteslen); - if (bytes != Py_None) - PyBuffer_Release(&vbytes); - return PyByteArray_FromStringAndSize(myptr, right); + return bytearray_strip_impl(self, bytes, RIGHTSTRIP); } /*[clinic input] diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index 1e3f197561523f..5966bdbd594b30 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -726,8 +726,10 @@ PyDoc_STRVAR(bytearray_strip__doc__, #define BYTEARRAY_STRIP_METHODDEF \ {"strip", (PyCFunction)(void(*)(void))bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, +enum StripType { LEFTSTRIP, RIGHTSTRIP, BOTHSTRIP }; + static PyObject * -bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); +bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes, enum StripType striptype ); static PyObject * bytearray_strip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) @@ -743,7 +745,7 @@ bytearray_strip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs } bytes = args[0]; skip_optional: - return_value = bytearray_strip_impl(self, bytes); + return_value = bytearray_strip_impl(self, bytes, BOTHSTRIP); exit: return return_value; From a1dc9d1dc2b7a2e0e7818626b992e2ca77e531bd Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 24 Mar 2022 13:48:08 +0100 Subject: [PATCH 2/7] remove redundant bytearray_[lr]strip_impl --- Objects/bytearrayobject.c | 12 ------------ Objects/clinic/bytearrayobject.c.h | 9 ++------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 9d2ced53bf0e98..46f1227b1ae3ec 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1938,12 +1938,6 @@ Strip leading bytes contained in the argument. If the argument is omitted or None, strip leading ASCII whitespace. [clinic start generated code]*/ -static inline PyObject * -bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes) -/*[clinic end generated code: output=d005c9d0ab909e66 input=80843f975dd7c480]*/ -{ - return bytearray_strip_impl(self, bytes, LEFTSTRIP); -} /*[clinic input] bytearray.rstrip @@ -1956,12 +1950,6 @@ Strip trailing bytes contained in the argument. If the argument is omitted or None, strip trailing ASCII whitespace. [clinic start generated code]*/ -static inline PyObject * -bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes) -/*[clinic end generated code: output=030e2fbd2f7276bd input=e728b994954cfd91]*/ -{ - return bytearray_strip_impl(self, bytes, RIGHTSTRIP); -} /*[clinic input] bytearray.decode diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index 5966bdbd594b30..9087106cfd4f2b 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -762,8 +762,6 @@ PyDoc_STRVAR(bytearray_lstrip__doc__, #define BYTEARRAY_LSTRIP_METHODDEF \ {"lstrip", (PyCFunction)(void(*)(void))bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__}, -static PyObject * -bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * bytearray_lstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) @@ -779,7 +777,7 @@ bytearray_lstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg } bytes = args[0]; skip_optional: - return_value = bytearray_lstrip_impl(self, bytes); + return_value = bytearray_strip_impl(self, bytes, LEFTSTRIP); exit: return return_value; @@ -796,9 +794,6 @@ PyDoc_STRVAR(bytearray_rstrip__doc__, #define BYTEARRAY_RSTRIP_METHODDEF \ {"rstrip", (PyCFunction)(void(*)(void))bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__}, -static PyObject * -bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); - static PyObject * bytearray_rstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) { @@ -813,7 +808,7 @@ bytearray_rstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg } bytes = args[0]; skip_optional: - return_value = bytearray_rstrip_impl(self, bytes); + return_value = bytearray_strip_impl(self, bytes, RIGHTSTRIP); exit: return return_value; From 3f12de3ca56f8d54e640852ec099be8177d40219 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 24 Mar 2022 13:54:08 +0100 Subject: [PATCH 3/7] undo autoformatting --- Objects/bytearrayobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 46f1227b1ae3ec..6de3f138c5737a 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1838,7 +1838,7 @@ bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index) buf = PyByteArray_AS_STRING(self); value = buf[index]; memmove(buf + index, buf + index + 1, n - index); - if (PyByteArray_Resize((PyObject*)self, n - 1) < 0) + if (PyByteArray_Resize((PyObject *)self, n - 1) < 0) return NULL; return PyLong_FromLong((unsigned char)value); @@ -1855,7 +1855,7 @@ Remove the first occurrence of a value in the bytearray. [clinic start generated code]*/ static PyObject * -bytearray_remove_impl(PyByteArrayObject* self, int value) +bytearray_remove_impl(PyByteArrayObject *self, int value) /*[clinic end generated code: output=d659e37866709c13 input=121831240cd51ddf]*/ { Py_ssize_t where, n = Py_SIZE(self); From 755c495af1849fa6fa049c0cddb910c0a8645754 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Fri, 25 Mar 2022 10:24:17 +0100 Subject: [PATCH 4/7] fix argument clinic --- Objects/bytearrayobject.c | 22 +++++++++++++++++++--- Objects/clinic/bytearrayobject.c.h | 29 ++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 6de3f138c5737a..a8ebba06c2786a 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1876,11 +1876,15 @@ bytearray_remove_impl(PyByteArrayObject *self, int value) Py_RETURN_NONE; } +#define LEFTSTRIP 0 +#define RIGHTSTRIP 1 +#define BOTHSTRIP 2 /*[clinic input] bytearray.strip bytes: object = None + striptype: int = 2 / Strip leading and trailing bytes contained in the argument. @@ -1888,9 +1892,9 @@ Strip leading and trailing bytes contained in the argument. If the argument is omitted or None, strip leading and trailing ASCII whitespace. [clinic start generated code]*/ -static PyObject* -bytearray_strip_impl(PyByteArrayObject* self, PyObject* bytes, enum StripType striptype) -/*[clinic end generated code: output=760412661a34ad5a input=ef7bb59b09c21d62]*/ +static PyObject * +bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes, int striptype) +/*[clinic end generated code: output=73625dcc8efbcd32 input=d61349e4106f35d5]*/ { Py_ssize_t mysize, byteslen; const char* myptr; @@ -1938,6 +1942,12 @@ Strip leading bytes contained in the argument. If the argument is omitted or None, strip leading ASCII whitespace. [clinic start generated code]*/ +static PyObject * +bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes) +/*[clinic end generated code: output=d005c9d0ab909e66 input=80843f975dd7c480]*/ +{ + return bytearray_strip_impl(self, bytes, LEFTSTRIP); +} /*[clinic input] bytearray.rstrip @@ -1950,6 +1960,12 @@ Strip trailing bytes contained in the argument. If the argument is omitted or None, strip trailing ASCII whitespace. [clinic start generated code]*/ +static PyObject * +bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes) +/*[clinic end generated code: output=030e2fbd2f7276bd input=e728b994954cfd91]*/ +{ + return bytearray_strip_impl(self, bytes, RIGHTSTRIP); +} /*[clinic input] bytearray.decode diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index 9087106cfd4f2b..e51239ce48ae64 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -716,7 +716,7 @@ bytearray_remove(PyByteArrayObject *self, PyObject *arg) } PyDoc_STRVAR(bytearray_strip__doc__, -"strip($self, bytes=None, /)\n" +"strip($self, bytes=None, striptype=2, /)\n" "--\n" "\n" "Strip leading and trailing bytes contained in the argument.\n" @@ -726,26 +726,32 @@ PyDoc_STRVAR(bytearray_strip__doc__, #define BYTEARRAY_STRIP_METHODDEF \ {"strip", (PyCFunction)(void(*)(void))bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, -enum StripType { LEFTSTRIP, RIGHTSTRIP, BOTHSTRIP }; - static PyObject * -bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes, enum StripType striptype ); +bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes, int striptype); static PyObject * bytearray_strip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; + int striptype = 2; - if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("strip", nargs, 0, 2)) { goto exit; } if (nargs < 1) { goto skip_optional; } bytes = args[0]; + if (nargs < 2) { + goto skip_optional; + } + striptype = _PyLong_AsInt(args[1]); + if (striptype == -1 && PyErr_Occurred()) { + goto exit; + } skip_optional: - return_value = bytearray_strip_impl(self, bytes, BOTHSTRIP); + return_value = bytearray_strip_impl(self, bytes, striptype); exit: return return_value; @@ -762,6 +768,8 @@ PyDoc_STRVAR(bytearray_lstrip__doc__, #define BYTEARRAY_LSTRIP_METHODDEF \ {"lstrip", (PyCFunction)(void(*)(void))bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__}, +static PyObject * +bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * bytearray_lstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) @@ -777,7 +785,7 @@ bytearray_lstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg } bytes = args[0]; skip_optional: - return_value = bytearray_strip_impl(self, bytes, LEFTSTRIP); + return_value = bytearray_lstrip_impl(self, bytes); exit: return return_value; @@ -794,6 +802,9 @@ PyDoc_STRVAR(bytearray_rstrip__doc__, #define BYTEARRAY_RSTRIP_METHODDEF \ {"rstrip", (PyCFunction)(void(*)(void))bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__}, +static PyObject * +bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); + static PyObject * bytearray_rstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) { @@ -808,7 +819,7 @@ bytearray_rstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg } bytes = args[0]; skip_optional: - return_value = bytearray_strip_impl(self, bytes, RIGHTSTRIP); + return_value = bytearray_rstrip_impl(self, bytes); exit: return return_value; @@ -1117,4 +1128,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=a82659f581e55629 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b1866b0be02055e0 input=a9049054013a1b77]*/ From 6b01f7aca8cd7a6abb66234cc46524be5080d338 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Sat, 26 Mar 2022 10:56:03 +0100 Subject: [PATCH 5/7] keep public api identical --- Objects/bytearrayobject.c | 39 +++++++++++++++++------------- Objects/clinic/bytearrayobject.c.h | 18 ++++---------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index a8ebba06c2786a..505e810a928b27 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1880,21 +1880,8 @@ bytearray_remove_impl(PyByteArrayObject *self, int value) #define RIGHTSTRIP 1 #define BOTHSTRIP 2 -/*[clinic input] -bytearray.strip - - bytes: object = None - striptype: int = 2 - / - -Strip leading and trailing bytes contained in the argument. - -If the argument is omitted or None, strip leading and trailing ASCII whitespace. -[clinic start generated code]*/ - -static PyObject * -bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes, int striptype) -/*[clinic end generated code: output=73625dcc8efbcd32 input=d61349e4106f35d5]*/ +static PyObject* +bytearray_strip_impl_helper(PyByteArrayObject* self, PyObject* bytes, int striptype) { Py_ssize_t mysize, byteslen; const char* myptr; @@ -1931,6 +1918,24 @@ bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes, int striptype) return PyByteArray_FromStringAndSize(myptr + left, right - left); } +/*[clinic input] +bytearray.strip + + bytes: object = None + / + +Strip leading and trailing bytes contained in the argument. + +If the argument is omitted or None, strip leading and trailing ASCII whitespace. +[clinic start generated code]*/ + +static PyObject * +bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes) +/*[clinic end generated code: output=760412661a34ad5a input=ef7bb59b09c21d62]*/ +{ + return bytearray_strip_impl_helper(self, bytes, BOTHSTRIP); +} + /*[clinic input] bytearray.lstrip @@ -1946,7 +1951,7 @@ static PyObject * bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes) /*[clinic end generated code: output=d005c9d0ab909e66 input=80843f975dd7c480]*/ { - return bytearray_strip_impl(self, bytes, LEFTSTRIP); + return bytearray_strip_impl_helper(self, bytes, LEFTSTRIP); } /*[clinic input] @@ -1964,7 +1969,7 @@ static PyObject * bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes) /*[clinic end generated code: output=030e2fbd2f7276bd input=e728b994954cfd91]*/ { - return bytearray_strip_impl(self, bytes, RIGHTSTRIP); + return bytearray_strip_impl_helper(self, bytes, RIGHTSTRIP); } /*[clinic input] diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index e51239ce48ae64..1e3f197561523f 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -716,7 +716,7 @@ bytearray_remove(PyByteArrayObject *self, PyObject *arg) } PyDoc_STRVAR(bytearray_strip__doc__, -"strip($self, bytes=None, striptype=2, /)\n" +"strip($self, bytes=None, /)\n" "--\n" "\n" "Strip leading and trailing bytes contained in the argument.\n" @@ -727,31 +727,23 @@ PyDoc_STRVAR(bytearray_strip__doc__, {"strip", (PyCFunction)(void(*)(void))bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, static PyObject * -bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes, int striptype); +bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * bytearray_strip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - int striptype = 2; - if (!_PyArg_CheckPositional("strip", nargs, 0, 2)) { + if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { goto exit; } if (nargs < 1) { goto skip_optional; } bytes = args[0]; - if (nargs < 2) { - goto skip_optional; - } - striptype = _PyLong_AsInt(args[1]); - if (striptype == -1 && PyErr_Occurred()) { - goto exit; - } skip_optional: - return_value = bytearray_strip_impl(self, bytes, striptype); + return_value = bytearray_strip_impl(self, bytes); exit: return return_value; @@ -1128,4 +1120,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=b1866b0be02055e0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a82659f581e55629 input=a9049054013a1b77]*/ From 6d42118551c9e95f1e8c7cb928e0b12682523cee Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 13 Apr 2022 07:14:31 +0000 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst new file mode 100644 index 00000000000000..9148fd6f8b757f --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst @@ -0,0 +1 @@ +Refactor the `bytearray` strips method `strip`, `lstrip` and `rstrip` to use a common implementation. From 0474d6f4ab13a954b411d4d08879c700b3a92371 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Wed, 13 Apr 2022 09:36:38 +0200 Subject: [PATCH 7/7] Update Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> --- .../2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst index 9148fd6f8b757f..bb1d7dd90f17f7 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-13-07-14-30.gh-issue-91266.6Vkzzt.rst @@ -1 +1 @@ -Refactor the `bytearray` strips method `strip`, `lstrip` and `rstrip` to use a common implementation. +Refactor the ``bytearray`` strip methods ``strip``, ``lstrip`` and ``rstrip`` to use a common implementation.