[Python-3000-checkins] r60437 - in python/branches/py3k: Lib/test/test_bytes.py Misc/NEWS Objects/bytesobject.c
christian.heimes
python-3000-checkins at python.org
Wed Jan 30 10:51:48 CET 2008
Author: christian.heimes
Date: Wed Jan 30 10:51:48 2008
New Revision: 60437
Modified:
python/branches/py3k/Lib/test/test_bytes.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Objects/bytesobject.c
Log:
Fixed #1969: split and rsplit in bytearray are inconsistent
Modified: python/branches/py3k/Lib/test/test_bytes.py
==============================================================================
--- python/branches/py3k/Lib/test/test_bytes.py (original)
+++ python/branches/py3k/Lib/test/test_bytes.py Wed Jan 30 10:51:48 2008
@@ -706,7 +706,7 @@
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 @@
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'))
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Wed Jan 30 10:51:48 2008
@@ -12,6 +12,8 @@
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.
Modified: python/branches/py3k/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k/Objects/bytesobject.c (original)
+++ python/branches/py3k/Objects/bytesobject.c Wed Jan 30 10:51:48 2008
@@ -2388,16 +2388,16 @@
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;
}
More information about the Python-3000-checkins
mailing list