]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-146059: Cleanup pickle fast_save_enter() test (GH-146481) (#146510)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 27 Mar 2026 10:49:57 +0000 (11:49 +0100)
committerGitHub <noreply@github.com>
Fri, 27 Mar 2026 10:49:57 +0000 (10:49 +0000)
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 <vstinner@python.org>
Lib/test/pickletester.py

index 9f5b6161b8d2017ab0ba9e393534ccd191a81787..fa67dec4b5c91a15f16da597b403b60f1ec11ccd 100644 (file)
@@ -3947,13 +3947,12 @@ class AbstractPickleTests(ExtraAssertions):
                     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 @@ class AbstractPickleTests(ExtraAssertions):
     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 @@ class AbstractPickleTests(ExtraAssertions):
                     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: