Issue #27039: Fixed bytearray.remove() for values greater than 127.

Based on patch by Joe Jevnik.
This commit is contained in:
Serhiy Storchaka 2016-05-16 22:24:03 +03:00
commit 4b23494ded
4 changed files with 115 additions and 108 deletions

View file

@ -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;
}