mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-140358: Bring back elapsed time and unreachable count to gc debug output (GH-140359) (#140405)
Co-authored-by: Pål Grønås Drange <paal.drange+pgdr@gmail.com>
This commit is contained in:
parent
ce1deb947e
commit
c1bfd4cb9c
3 changed files with 43 additions and 0 deletions
|
|
@ -776,6 +776,32 @@ def __del__(self):
|
|||
rc, out, err = assert_python_ok('-c', code)
|
||||
self.assertEqual(out.strip(), b'__del__ called')
|
||||
|
||||
@unittest.skipIf(Py_GIL_DISABLED, "requires GC generations or increments")
|
||||
def test_gc_debug_stats(self):
|
||||
# Checks that debug information is printed to stderr
|
||||
# when DEBUG_STATS is set.
|
||||
code = """if 1:
|
||||
import gc
|
||||
gc.set_debug(%s)
|
||||
gc.collect()
|
||||
"""
|
||||
_, _, err = assert_python_ok("-c", code % "gc.DEBUG_STATS")
|
||||
self.assertRegex(err, b"gc: collecting generation [0-9]+")
|
||||
self.assertRegex(
|
||||
err,
|
||||
b"gc: objects in each generation: [0-9]+ [0-9]+ [0-9]+",
|
||||
)
|
||||
self.assertRegex(
|
||||
err, b"gc: objects in permanent generation: [0-9]+"
|
||||
)
|
||||
self.assertRegex(
|
||||
err,
|
||||
b"gc: done, .* unreachable, .* uncollectable, .* elapsed",
|
||||
)
|
||||
|
||||
_, _, err = assert_python_ok("-c", code % "0")
|
||||
self.assertNotIn(b"elapsed", err)
|
||||
|
||||
def test_global_del_SystemExit(self):
|
||||
code = """if 1:
|
||||
class ClassWithDel:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue