MCPcopy Index your code
hub / github.com/python/cpython / Uncollectable

Class Uncollectable

Lib/test/test_gc.py:67–80  ·  view source on GitHub ↗

Create a reference cycle with multiple __del__ methods. An object in a reference cycle will never have zero references, and so must be garbage collected. If one or more objects in the cycle have __del__ methods, the gc refuses to guess an order, and leaves the cycle uncollected.

Source from the content-addressed store, hash-verified

65
66@with_tp_del
67class Uncollectable(object):
68 """Create a reference cycle with multiple __del__ methods.
69
70 An object in a reference cycle will never have zero references,
71 and so must be garbage collected. If one or more objects in the
72 cycle have __del__ methods, the gc refuses to guess an order,
73 and leaves the cycle uncollected."""
74 def __init__(self, partner=None):
75 if partner is None:
76 self.partner = Uncollectable(partner=self)
77 else:
78 self.partner = partner
79 def __tp_del__(self):
80 pass
81
82if sysconfig.get_config_vars().get('PY_CFLAGS', ''):
83 BUILD_WITH_NDEBUG = ('-DNDEBUG' in sysconfig.get_config_vars()['PY_CFLAGS'])

Callers 2

__init__Method · 0.85
test_collect_garbageMethod · 0.85

Calls

no outgoing calls

Tested by 2

__init__Method · 0.68
test_collect_garbageMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…