https://github.com/python/cpython/commit/9ee6b67ee9839dd46fc7c27aab24deae403b1bbc
commit: 9ee6b67ee9839dd46fc7c27aab24deae403b1bbc
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-03-27T10:49:57Z
summary:
[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 0c7a75aeef4dae87f02536ed4c42a57c13ef20e2)
Co-authored-by: Victor Stinner <[email protected]>
files:
M Lib/test/pickletester.py
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 9f5b6161b8d201..fa67dec4b5c91a 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -3947,13 +3947,12 @@ def __reduce__(self):
self.assertIn(expected, str(e))
def fast_save_enter(self, create_data, minprotocol=0):
- # gh-146059: Check that fast_save() is called when
+ # gh-146059: Check that fast_save_leave() is called when
# fast_save_enter() is called.
if not hasattr(self, "pickler"):
self.skipTest("need Pickler class")
data = [create_data(i) for i in range(FAST_NESTING_LIMIT * 2)]
- data = {"key": data}
protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1)
for proto in protocols:
with self.subTest(proto=proto):
@@ -3987,18 +3986,17 @@ def test_fast_save_enter_frozendict(self):
def test_fast_save_enter_dict(self):
self.fast_save_enter(lambda i: {"key": i})
- def deep_nested_struct(self, seed, create_nested,
+ def deep_nested_struct(self, create_nested,
minprotocol=0, compare_equal=True,
depth=FAST_NESTING_LIMIT * 2):
- # gh-146059: Check that fast_save() is called when
+ # gh-146059: Check that fast_save_leave() is called when
# fast_save_enter() is called.
if not hasattr(self, "pickler"):
self.skipTest("need Pickler class")
- data = seed
+ data = None
for i in range(depth):
data = create_nested(data)
- data = {"key": data}
protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1)
for proto in protocols:
with self.subTest(proto=proto):
@@ -4014,30 +4012,28 @@ def deep_nested_struct(self, seed, create_nested,
self.assertEqual(data2, data)
def test_deep_nested_struct_tuple(self):
- self.deep_nested_struct((1,), lambda data: (data,))
+ self.deep_nested_struct(lambda data: (data,))
def test_deep_nested_struct_list(self):
- self.deep_nested_struct([1], lambda data: [data])
+ self.deep_nested_struct(lambda data: [data])
def test_deep_nested_struct_frozenset(self):
- self.deep_nested_struct(frozenset((1,)),
- lambda data: frozenset((1, data)))
+ self.deep_nested_struct(lambda data: frozenset((1, data)))
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
def test_deep_nested_struct_set(self):
- self.deep_nested_struct({1}, lambda data: {K(data)},
+ self.deep_nested_struct(lambda data: {K(data)},
depth=FAST_NESTING_LIMIT+1,
compare_equal=False)
def test_deep_nested_struct_frozendict(self):
if self.py_version < (3, 15):
self.skipTest('need frozendict')
- self.deep_nested_struct(frozendict(x=1),
- lambda data: frozendict(x=data),
+ self.deep_nested_struct(lambda data: frozendict(x=data),
minprotocol=2)
def test_deep_nested_struct_dict(self):
- self.deep_nested_struct({'x': 1}, lambda data: {'x': data})
+ self.deep_nested_struct(lambda data: {'x': data})
class BigmemPickleTests:
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]