diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-02 17:16:38 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-02 17:16:38 (GMT) |
commit | b2677c739729ace08c4185d1e459210373477497 (patch) | |
tree | a0a8166ddcc05cfa59ecfe3632e318553ac080f6 /Lib/test/test_marshal.py | |
parent | 92818d5383087d238f24b0a93d31a41bf6a75735 (diff) | |
parent | 679e9d36f78de3ac18abaaddbcf4f73fcef55b7e (diff) | |
download | cpython-b2677c739729ace08c4185d1e459210373477497.zip cpython-b2677c739729ace08c4185d1e459210373477497.tar.gz cpython-b2677c739729ace08c4185d1e459210373477497.tar.bz2 |
Issue #14172: Fix reference leak when marshalling a buffer-like object (other than a bytes object).
Diffstat (limited to 'Lib/test/test_marshal.py')
-rw-r--r-- | Lib/test/test_marshal.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index dec8129..bd81a1a 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from test import support +import array import marshal import sys import unittest @@ -154,6 +155,27 @@ class ContainerTestCase(unittest.TestCase, HelperMixin): for constructor in (set, frozenset): self.helper(constructor(self.d.keys())) + +class BufferTestCase(unittest.TestCase, HelperMixin): + + def test_bytearray(self): + b = bytearray(b"abc") + self.helper(b) + new = marshal.loads(marshal.dumps(b)) + self.assertEqual(type(new), bytes) + + def test_memoryview(self): + b = memoryview(b"abc") + self.helper(b) + new = marshal.loads(marshal.dumps(b)) + self.assertEqual(type(new), bytes) + + def test_array(self): + a = array.array('B', b"abc") + new = marshal.loads(marshal.dumps(a)) + self.assertEqual(new, b"abc") + + class BugsTestCase(unittest.TestCase): def test_bug_5888452(self): # Simple-minded check for SF 588452: Debug build crashes @@ -260,6 +282,7 @@ def test_main(): CodeTestCase, ContainerTestCase, ExceptionTestCase, + BufferTestCase, BugsTestCase) if __name__ == "__main__": |