This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bytearray.remove cannot remove bytes with value greater than 127
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Damien George, SilentGhost, llllllllll, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-05-16 16:29 by Damien George, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bytearray-remove.patch llllllllll, 2016-05-16 17:38 review
Messages (8)
msg265709 - (view) Author: Damien George (Damien George) Date: 2016-05-16 16:29
The following code fails with a ValueError (but I expect it to succeed):

>>> bytearray([128]).remove(128)

Tested with Python 2.7.11 and 3.5.1.  Probably it's a case of comparing a char (signed byte) with an unsigned value.
msg265711 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-05-16 16:41
Test is not catching it, because it only deals with ascii part.
msg265714 - (view) Author: Joe Jevnik (llllllllll) * Date: 2016-05-16 17:38
This seems to just be a bug in the implementation of remove. I have a patch to fix this and a test case.
msg265717 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-16 18:58
LGTM.
msg265719 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-16 19:02
But we first need to test that value is in the range from 0 to 255.
msg265720 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-16 19:03
But we first need to test that value is in the range from 0 to 255.
msg265722 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-16 19:07
Ah, this is already checked in the converter.
msg265726 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-16 19:25
New changeset 10444778d41c by Serhiy Storchaka in branch '3.5':
Issue #27039: Fixed bytearray.remove() for values greater than 127.
https://hg.python.org/cpython/rev/10444778d41c

New changeset 9acf44b7ff7b by Serhiy Storchaka in branch '2.7':
Issue #27039: Fixed bytearray.remove() for values greater than 127.
https://hg.python.org/cpython/rev/9acf44b7ff7b

New changeset 3eb502d43616 by Serhiy Storchaka in branch 'default':
Issue #27039: Fixed bytearray.remove() for values greater than 127.
https://hg.python.org/cpython/rev/3eb502d43616
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71226
2016-05-16 19:25:52serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2016-05-16 19:25:07python-devsetnosy: + python-dev
messages: + msg265726
2016-05-16 19:07:35serhiy.storchakasetmessages: + msg265722
2016-05-16 19:03:01serhiy.storchakasetmessages: + msg265720
2016-05-16 19:02:57serhiy.storchakasetmessages: + msg265719
2016-05-16 18:58:43serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg265717
stage: commit review
2016-05-16 17:38:20llllllllllsetfiles: + bytearray-remove.patch

nosy: + llllllllll
messages: + msg265714

keywords: + patch
2016-05-16 16:41:58SilentGhostsetnosy: + SilentGhost
messages: + msg265711
2016-05-16 16:39:45SilentGhostsetnosy: + serhiy.storchaka

versions: + Python 3.6
2016-05-16 16:29:48Damien Georgecreate