bpo-43439: Add audit hooks for gc functions (GH-24794)

This commit is contained in:
Pablo Galindo 2021-03-10 00:53:57 +00:00 committed by GitHub
parent 62a03cd490
commit b4f9089d4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 0 deletions

View file

@ -323,6 +323,24 @@ def test_socket():
sock.close()
def test_gc():
import gc
def hook(event, args):
if event.startswith("gc."):
print(event, *args)
sys.addaudithook(hook)
gc.get_objects(generation=1)
x = object()
y = [x]
gc.get_referrers(x)
gc.get_referents(y)
if __name__ == "__main__":
from test.support import suppress_msvcrt_asserts