Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply review suggestions: shorten NEWS, use class attribute in test
  • Loading branch information
tonghuaroot committed Jul 30, 2026
commit 37b18f042762213da2fe5380e66625bca03eab20
7 changes: 3 additions & 4 deletions Lib/test/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,15 +941,14 @@ def m(self):

def test_deepcopy_memo_none_result(self):
# Objects whose deepcopy result is None must still be memoized.
call_count = 0
class C:
call_count = 0
def __deepcopy__(self, memo):
nonlocal call_count
call_count += 1
C.call_count += 1
return None
obj = C()
copy.deepcopy([obj, obj, obj])
self.assertEqual(call_count, 1)
self.assertEqual(C.call_count, 1)


class TestReplace(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
Fix :func:`copy.deepcopy` so that an object whose deep copy is ``None`` is
still memoized. The memo miss was detected with ``None``, which is a valid
result, so such objects were copied again on every reference. Patch by
tonghuaroot.
still memoized. Patch by tonghuaroot.
Loading