Martin Panter added the comment: A test case for this that would trigger when memory debugging is enabled could look something like the following. Would it be appropriate to add it to the test suite?
a = bytearray(10) size = sys.getsizeof(a) a.pop() # Defeat expanding buffer off-by-one quirk self.assertEqual(sys.getsizeof(a), size, "Quirk not defeated") del a[:1] # Or a.pop(0) # Does not trigger bug # Or a[:1] = () # Triggers bug self.assertEqual(sys.getsizeof(a), size, "Test assumes buffer not resized") a += bytes(2) # Add exactly the number of free bytes in buffer # Or a.extend(bytes(2)) # Unaffected # Or a.append(0); a.append(0) # Unaffected # Or a[8:] = bytes(2) # Unaffected del a # Trigger memory buffer to be freed, with verification ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23985> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com