Skip to content
Merged
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
test(operator): cover methodcaller cyclic GC
  • Loading branch information
ashm-dev committed Sep 11, 2026
commit 076c0cde578d1365e28460bf361a33c6caf035e7
15 changes: 15 additions & 0 deletions Lib/test/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import inspect
import pickle
import sys
import weakref
from decimal import Decimal
from fractions import Fraction

Expand Down Expand Up @@ -511,6 +512,20 @@ def return_arguments(self, *args, **kwds):
f = operator.methodcaller('return_arguments', *many_positional_arguments, **many_kw_arguments)
self.assertEqual(f(a), (many_positional_arguments, many_kw_arguments))

def test_methodcaller_cyclic_gc(self):
operator = self.module
Comment thread
ashm-dev marked this conversation as resolved.

class C:
pass

c = C()
ref = weakref.ref(c)
c.m = operator.methodcaller('foo', c)
del c

support.gc_collect()
self.assertIsNone(ref())

def test_inplace(self):
operator = self.module
class C(object):
Expand Down
Loading