Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7b876158
Commit
7b876158
authored
Jan 30, 2008
by
Christian Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #1969: split and rsplit in bytearray are inconsistent
parent
d4cb56d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
4 deletions
+15
-4
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+10
-1
Misc/NEWS
Misc/NEWS
+2
-0
Objects/bytesobject.c
Objects/bytesobject.c
+3
-3
No files found.
Lib/test/test_bytes.py
View file @
7b876158
...
...
@@ -706,7 +706,7 @@ class BytesTest(unittest.TestCase):
self
.
assertEqual
(
b
.
rsplit
(
None
,
2
),
[
b'arf'
,
b'barf'
])
self
.
assertEqual
(
b' a bb c '
.
rsplit
(
None
,
0
),
[
b' a bb c'
])
self
.
assertEqual
(
b' a bb c '
.
rsplit
(
None
,
1
),
[
b' a bb'
,
b'c'
])
self
.
assertEqual
(
b' a bb c '
.
rsplit
(
None
,
2
),
[
b' a'
,
b'bb'
,
b'c'
])
self
.
assertEqual
(
b' a bb c '
.
rsplit
(
None
,
2
),
[
b' a'
,
b'bb'
,
b'c'
])
self
.
assertEqual
(
b' a bb c '
.
rsplit
(
None
,
3
),
[
b'a'
,
b'bb'
,
b'c'
])
def
test_rsplit_bytearray
(
self
):
...
...
@@ -715,6 +715,15 @@ class BytesTest(unittest.TestCase):
def
test_rsplit_string_error
(
self
):
self
.
assertRaises
(
TypeError
,
b'a b'
.
rsplit
,
' '
)
def
test_rsplit_unicodewhitespace
(
self
):
b
=
b"
\
x09
\
x0A
\
x0B
\
x0C
\
x0D
\
x1C
\
x1D
\
x1E
\
x1F
"
self
.
assertEqual
(
b
.
split
(),
[
b'
\
x1c
\
x1d
\
x1e
\
x1f
'
])
self
.
assertEqual
(
b
.
rsplit
(),
[
b'
\
x1c
\
x1d
\
x1e
\
x1f
'
])
ba
=
bytearray
(
b
)
self
.
assertEqual
(
ba
.
split
(),
[
bytearray
(
b'
\
x1c
\
x1d
\
x1e
\
x1f
'
)])
self
.
assertEqual
(
ba
.
rsplit
(),
[
bytearray
(
b'
\
x1c
\
x1d
\
x1e
\
x1f
'
)])
def
test_partition
(
self
):
b
=
b'mississippi'
self
.
assertEqual
(
b
.
partition
(
b'ss'
),
(
b'mi'
,
b'ss'
,
b'issippi'
))
...
...
Misc/NEWS
View file @
7b876158
...
...
@@ -12,6 +12,8 @@ What's New in Python 3.0a3?
Core and Builtins
-----------------
- Issue #1969: split and rsplit in bytearray are inconsistent
- map() and itertools.imap() no longer accept None for the first argument.
Use zip() instead.
...
...
Objects/bytesobject.c
View file @
7b876158
...
...
@@ -2388,16 +2388,16 @@ rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxcount)
for
(
i
=
j
=
len
-
1
;
i
>=
0
;
)
{
/* find a token */
while
(
i
>=
0
&&
Py_UNICODE_
ISSPACE
(
s
[
i
]))
while
(
i
>=
0
&&
ISSPACE
(
s
[
i
]))
i
--
;
j
=
i
;
while
(
i
>=
0
&&
!
Py_UNICODE_
ISSPACE
(
s
[
i
]))
while
(
i
>=
0
&&
!
ISSPACE
(
s
[
i
]))
i
--
;
if
(
j
>
i
)
{
if
(
maxcount
--
<=
0
)
break
;
SPLIT_ADD
(
s
,
i
+
1
,
j
+
1
);
while
(
i
>=
0
&&
Py_UNICODE_
ISSPACE
(
s
[
i
]))
while
(
i
>=
0
&&
ISSPACE
(
s
[
i
]))
i
--
;
j
=
i
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment