diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-03-10 08:50:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 08:50:16 (GMT) |
commit | a6d0182879d0bf275c4feb38b57f73236ab9c06c (patch) | |
tree | 96ea6d412c90761f0c526e4c8e230ea3926baaf2 /Lib/test/audit-tests.py | |
parent | e89380765df8f0f02c90ad417e164d1597bd0b05 (diff) | |
download | cpython-a6d0182879d0bf275c4feb38b57f73236ab9c06c.zip cpython-a6d0182879d0bf275c4feb38b57f73236ab9c06c.tar.gz cpython-a6d0182879d0bf275c4feb38b57f73236ab9c06c.tar.bz2 |
[3.8] bpo-43439: Add audit hooks for gc functions (GH-24794). (GH-24810)
(cherry picked from commit b4f9089d4aa787c5b74134c98e5f0f11d9e63095)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/audit-tests.py')
-rw-r--r-- | Lib/test/audit-tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/audit-tests.py b/Lib/test/audit-tests.py index ee6fc93..8e66594 100644 --- a/Lib/test/audit-tests.py +++ b/Lib/test/audit-tests.py @@ -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 |