diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-11-19 21:49:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-11-19 21:49:09 (GMT) |
commit | 46cc6d11020d0bfa7b245b18679a613e9bc2b325 (patch) | |
tree | 28f96eb5e12156eb4039be6191e699759a5af720 /Lib/test/test_bytes.py | |
parent | 3b30e2c86d45f6718b0a79784cda36b2cf30a9db (diff) | |
download | cpython-46cc6d11020d0bfa7b245b18679a613e9bc2b325.zip cpython-46cc6d11020d0bfa7b245b18679a613e9bc2b325.tar.gz cpython-46cc6d11020d0bfa7b245b18679a613e9bc2b325.tar.bz2 |
make sure that bytearray methods return a new bytearray even if there is no change
Fixes #4348
Reviewed by Brett
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index a583a48..6e5ffa9 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -721,6 +721,16 @@ class ByteArrayTest(BaseBytesTest): b.insert(0, Indexable(ord('A'))) self.assertEqual(b, b'A') + def test_copied(self): + # Issue 4348. Make sure that operations that don't mutate the array + # copy the bytes. + b = bytearray(b'abc') + #self.assertFalse(b is b.replace(b'abc', b'cde', 0)) + + t = bytearray([i for i in range(256)]) + x = bytearray(b'') + self.assertFalse(x is x.translate(t)) + def test_partition_bytearray_doesnt_share_nullstring(self): a, b, c = bytearray(b"x").partition(b"y") self.assertEqual(b, b"") |