Skip to content
Merged
Prev Previous commit
Next Next commit
Address Inada-san's review: endswith's first param is named 'suffix'
  • Loading branch information
erlend-aasland committed Apr 3, 2024
commit 2c54b79ab333a05fe0c6e297e54b505a05ffc268
16 changes: 12 additions & 4 deletions Objects/bytearrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,16 +1211,24 @@ bytearray_startswith_impl(PyByteArrayObject *self, PyObject *subobj,
}

/*[clinic input]
@text_signature "($self, prefix[, start[, end]], /)"
bytearray.endswith = bytearray.startswith
@text_signature "($self, suffix[, start[, end]], /)"
bytearray.endswith

suffix as subobj: object
A bytes or a tuple of bytes to try.
start: slice_index(accept={int, NoneType}, c_default='0') = None
Optional start position. Default: start of the bytearray.
end: slice_index(accept={int, NoneType}, c_default='PY_SSIZE_T_MAX') = None
Optional stop position. Default: end of the bytearray.
/

Return True if the byte string ends with the specified prefix, False otherwise.
Return True if the byte string ends with the specified suffix, False otherwise.
[clinic start generated code]*/

static PyObject *
bytearray_endswith_impl(PyByteArrayObject *self, PyObject *subobj,
Py_ssize_t start, Py_ssize_t end)
/*[clinic end generated code: output=e75ea8c227954caa input=6b8a65e1d0071201]*/
/*[clinic end generated code: output=e75ea8c227954caa input=3b63c2dc878407c2]*/
{
return _Py_bytes_endswith(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self),
subobj, start, end);
Expand Down
16 changes: 12 additions & 4 deletions Objects/bytesobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2310,16 +2310,24 @@ bytes_startswith_impl(PyBytesObject *self, PyObject *subobj,
}

/*[clinic input]
@text_signature "($self, prefix[, start[, end]], /)"
bytes.endswith = bytes.startswith
@text_signature "($self, suffix[, start[, end]], /)"
bytes.endswith

suffix as subobj: object
A bytes or a tuple of bytes to try.
start: slice_index(accept={int, NoneType}, c_default='0') = None
Optional start position. Default: start of the bytes.
Comment thread
erlend-aasland marked this conversation as resolved.
end: slice_index(accept={int, NoneType}, c_default='PY_SSIZE_T_MAX') = None
Optional stop position. Default: end of the bytes.
/

Return True if the byte string ends with the specified prefix, False otherwise.
Return True if the byte string ends with the specified suffix, False otherwise.
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
[clinic start generated code]*/

static PyObject *
bytes_endswith_impl(PyBytesObject *self, PyObject *subobj, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=038b633111f3629d input=38d3f36990facc7b]*/
/*[clinic end generated code: output=038b633111f3629d input=66b64eccac830889]*/
{
return _Py_bytes_endswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
subobj, start, end);
Expand Down
8 changes: 4 additions & 4 deletions Objects/clinic/bytearrayobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Objects/clinic/bytesobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.