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

Method test_gc

Lib/test/test_faulthandler.py:180–213  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

178
179 @skip_segfault_on_android
180 def test_gc(self):
181 # bpo-44466: Detect if the GC is running
182 self.check_fatal_error("""
183 import faulthandler
184 import gc
185 import sys
186
187 faulthandler.enable()
188
189 class RefCycle:
190 def __del__(self):
191 faulthandler._sigsegv()
192
193 # create a reference cycle which triggers a fatal
194 # error in a destructor
195 a = RefCycle()
196 b = RefCycle()
197 a.b = b
198 b.a = a
199
200 # Delete the objects, not the cycle
201 a = None
202 b = None
203
204 # Break the reference cycle: call __del__()
205 gc.collect()
206
207 # Should not reach this line
208 print("exit", file=sys.stderr)
209 """,
210 9,
211 'Segmentation fault',
212 function='__del__',
213 garbage_collecting=True)
214
215 def test_fatal_error_c_thread(self):
216 self.check_fatal_error("""

Callers

nothing calls this directly

Calls 1

check_fatal_errorMethod · 0.95

Tested by

no test coverage detected