Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split and rsplit in bytearray are inconsistent #46261

Closed
pitrou opened this issue Jan 29, 2008 · 3 comments
Closed

split and rsplit in bytearray are inconsistent #46261

pitrou opened this issue Jan 29, 2008 · 3 comments
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Jan 29, 2008

BPO 1969
Nosy @gvanrossum, @pitrou, @tiran

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-01-30.09:52:14.734>
created_at = <Date 2008-01-29.23:53:34.715>
labels = ['interpreter-core', 'easy', 'type-bug']
title = 'split and rsplit in bytearray are inconsistent'
updated_at = <Date 2008-01-30.09:52:14.725>
user = 'https://github.com/pitrou'

bugs.python.org fields:

activity = <Date 2008-01-30.09:52:14.725>
actor = 'christian.heimes'
assignee = 'none'
closed = True
closed_date = <Date 2008-01-30.09:52:14.734>
closer = 'christian.heimes'
components = ['Interpreter Core']
creation = <Date 2008-01-29.23:53:34.715>
creator = 'pitrou'
dependencies = []
files = []
hgrepos = []
issue_num = 1969
keywords = ['easy']
message_count = 3.0
messages = ['61836', '61838', '61846']
nosy_count = 3.0
nosy_names = ['gvanrossum', 'pitrou', 'christian.heimes']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue1969'
versions = ['Python 3.0']

@pitrou
Copy link
Member Author

pitrou commented Jan 29, 2008

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()
[]

@pitrou pitrou added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jan 29, 2008
@gvanrossum
Copy link
Member

Yeah, that looks like a bug.

@tiran
Copy link
Member

tiran commented Jan 30, 2008

Fixed in r60437 with unit test.

Thanks for the report!

@tiran tiran closed this as completed Jan 30, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants