mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Issue #27039: Fixed bytearray.remove() for values greater than 127.
Based on patch by Joe Jevnik.
This commit is contained in:
commit
4b23494ded
4 changed files with 115 additions and 108 deletions
|
|
@ -1734,11 +1734,8 @@ bytearray_remove_impl(PyByteArrayObject *self, int value)
|
|||
Py_ssize_t where, n = Py_SIZE(self);
|
||||
char *buf = PyByteArray_AS_STRING(self);
|
||||
|
||||
for (where = 0; where < n; where++) {
|
||||
if (buf[where] == value)
|
||||
break;
|
||||
}
|
||||
if (where == n) {
|
||||
where = stringlib_find_char(buf, n, value);
|
||||
if (where < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "value not found in bytearray");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue