]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/test/crashers/gc_inspection.py
2 gc.get_referrers() can be used to see objects before they are fully built.
4 Note that this is only an example. There are many ways to crash Python
5 by using gc.get_referrers(), as well as many extension modules (even
6 when they are using perfectly documented patterns to build objects).
8 Identifying and removing all places that expose to the GC a
9 partially-built object is a long-term project. A patch was proposed on
10 SF specifically for this example but I consider fixing just this single
11 example a bit pointless (#1517042).
13 A fix would include a whole-scale code review, possibly with an API
14 change to decouple object creation and GC registration, and according
15 fixes to the documentation for extension module writers. It's unlikely
16 to happen, though. So this is currently classified as
17 "gc.get_referrers() is dangerous, use only for debugging".
26 # now the marker is in the tuple being constructed
27 [tup
] = [x
for x
in gc
.get_referrers(marker
) if type(x
) is tuple]