diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-05-16 19:24:03 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-05-16 19:24:03 (GMT) |
commit | 4b23494ded6c452d2b777938654a10b2ad5122aa (patch) | |
tree | e2c4246fce610ef83e0b188cda41f0508c2cd4ef /Objects | |
parent | aa99b8e36594242d7ef2f61cd03a1dd35bd018c8 (diff) | |
parent | 7bf36dace8c3d3714dfe5175891612450cb82ce5 (diff) | |
download | cpython-4b23494ded6c452d2b777938654a10b2ad5122aa.zip cpython-4b23494ded6c452d2b777938654a10b2ad5122aa.tar.gz cpython-4b23494ded6c452d2b777938654a10b2ad5122aa.tar.bz2 |
Issue #27039: Fixed bytearray.remove() for values greater than 127.
Based on patch by Joe Jevnik.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytearrayobject.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 9457768..b7dfd6f 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -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; } |