Skip to content

Commit f118655

Browse files
committed
Fix test_tracemalloc.test_set_traceback_limit()
Previously, it creates an empty bytes string which became the empty string singleton.
1 parent f2ceace commit f118655

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Lib/test/test_tracemalloc.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def get_frames(nframe, lineno_delta):
4141
def allocate_bytes(size):
4242
nframe = tracemalloc.get_traceback_limit()
4343
bytes_len = (size - EMPTY_STRING_SIZE)
44+
if bytes_len < 0:
45+
raise ValueError(f"{size} bytes is too small")
4446
frames = get_frames(nframe, 1)
4547
data = b'x' * bytes_len
4648
return data, tracemalloc.Traceback(frames, min(len(frames), nframe))
@@ -158,7 +160,7 @@ def test_new_reference(self):
158160
self.assertEqual(traceback, obj_traceback)
159161

160162
def test_set_traceback_limit(self):
161-
obj_size = 10
163+
obj_size = 123
162164

163165
tracemalloc.stop()
164166
self.assertRaises(ValueError, tracemalloc.start, -1)

0 commit comments

Comments
 (0)