Skip to content

Commit 9ee6b67

Browse files
[3.13] gh-146059: Cleanup pickle fast_save_enter() test (GH-146481) (#146510)
gh-146059: Cleanup pickle fast_save_enter() test (GH-146481) Remove {"key": data}, it's not required to reproduce the bug. Simplify also deep_nested_struct(): remove the seed parameter. Fix a typo in a comment. (cherry picked from commit 0c7a75a) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent de1644c commit 9ee6b67

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Lib/test/pickletester.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3947,13 +3947,12 @@ def __reduce__(self):
39473947
self.assertIn(expected, str(e))
39483948

39493949
def fast_save_enter(self, create_data, minprotocol=0):
3950-
# gh-146059: Check that fast_save() is called when
3950+
# gh-146059: Check that fast_save_leave() is called when
39513951
# fast_save_enter() is called.
39523952
if not hasattr(self, "pickler"):
39533953
self.skipTest("need Pickler class")
39543954

39553955
data = [create_data(i) for i in range(FAST_NESTING_LIMIT * 2)]
3956-
data = {"key": data}
39573956
protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1)
39583957
for proto in protocols:
39593958
with self.subTest(proto=proto):
@@ -3987,18 +3986,17 @@ def test_fast_save_enter_frozendict(self):
39873986
def test_fast_save_enter_dict(self):
39883987
self.fast_save_enter(lambda i: {"key": i})
39893988

3990-
def deep_nested_struct(self, seed, create_nested,
3989+
def deep_nested_struct(self, create_nested,
39913990
minprotocol=0, compare_equal=True,
39923991
depth=FAST_NESTING_LIMIT * 2):
3993-
# gh-146059: Check that fast_save() is called when
3992+
# gh-146059: Check that fast_save_leave() is called when
39943993
# fast_save_enter() is called.
39953994
if not hasattr(self, "pickler"):
39963995
self.skipTest("need Pickler class")
39973996

3998-
data = seed
3997+
data = None
39993998
for i in range(depth):
40003999
data = create_nested(data)
4001-
data = {"key": data}
40024000
protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1)
40034001
for proto in protocols:
40044002
with self.subTest(proto=proto):
@@ -4014,30 +4012,28 @@ def deep_nested_struct(self, seed, create_nested,
40144012
self.assertEqual(data2, data)
40154013

40164014
def test_deep_nested_struct_tuple(self):
4017-
self.deep_nested_struct((1,), lambda data: (data,))
4015+
self.deep_nested_struct(lambda data: (data,))
40184016

40194017
def test_deep_nested_struct_list(self):
4020-
self.deep_nested_struct([1], lambda data: [data])
4018+
self.deep_nested_struct(lambda data: [data])
40214019

40224020
def test_deep_nested_struct_frozenset(self):
4023-
self.deep_nested_struct(frozenset((1,)),
4024-
lambda data: frozenset((1, data)))
4021+
self.deep_nested_struct(lambda data: frozenset((1, data)))
40254022

40264023
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
40274024
def test_deep_nested_struct_set(self):
4028-
self.deep_nested_struct({1}, lambda data: {K(data)},
4025+
self.deep_nested_struct(lambda data: {K(data)},
40294026
depth=FAST_NESTING_LIMIT+1,
40304027
compare_equal=False)
40314028

40324029
def test_deep_nested_struct_frozendict(self):
40334030
if self.py_version < (3, 15):
40344031
self.skipTest('need frozendict')
4035-
self.deep_nested_struct(frozendict(x=1),
4036-
lambda data: frozendict(x=data),
4032+
self.deep_nested_struct(lambda data: frozendict(x=data),
40374033
minprotocol=2)
40384034

40394035
def test_deep_nested_struct_dict(self):
4040-
self.deep_nested_struct({'x': 1}, lambda data: {'x': data})
4036+
self.deep_nested_struct(lambda data: {'x': data})
40414037

40424038

40434039
class BigmemPickleTests:

0 commit comments

Comments
 (0)