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: split and rsplit in bytearray are inconsistent
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, gvanrossum, pitrou
Priority: normal Keywords: easy

Created on 2008-01-29 23:53 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg61836 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-01-29 23:53
In the bytearray type, the split and rsplit methods use a different
definition of what is a whitespace character. split_whitespace calls
ISSPACE(), while rsplit_whitespace calls Py_UNICODE_ISSPACE(). The
latter is probably an error since it is also inconsistent with behaviour
of the bytes type:

>>> s = b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F"
>>> s.split()
[b'\x1c\x1d\x1e\x1f']
>>> s.rsplit()
[b'\x1c\x1d\x1e\x1f']
>>> b = bytearray(s)
>>> b.split()
[bytearray(b'\x1c\x1d\x1e\x1f')]
>>> b.rsplit()
[]
msg61838 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-30 01:26
Yeah, that looks like a bug.
msg61846 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-30 09:52
Fixed in r60437 with unit test.

Thanks for the report!
History
Date User Action Args
2022-04-11 14:56:30adminsetgithub: 46261
2008-01-30 09:52:14christian.heimessetstatus: open -> closed
nosy: + christian.heimes
resolution: fixed
messages: + msg61846
2008-01-30 01:26:27gvanrossumsetkeywords: + easy
nosy: + gvanrossum
messages: + msg61838
2008-01-29 23:53:34pitroucreate