diff options
Diffstat (limited to 'Lib/test/crashers/gc_inspection.py')
-rw-r--r-- | Lib/test/crashers/gc_inspection.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/crashers/gc_inspection.py b/Lib/test/crashers/gc_inspection.py new file mode 100644 index 0000000..b439ad9 --- /dev/null +++ b/Lib/test/crashers/gc_inspection.py @@ -0,0 +1,17 @@ +""" +gc.get_referrers() can be used to see objects before they are fully built. +""" + +import gc + + +def g(): + marker = object() + yield marker + # now the marker is in the tuple being constructed + [tup] = [x for x in gc.get_referrers(marker) if type(x) is tuple] + print tup + print tup[1] + + +tuple(g()) |