mirror of
https://github.com/python/cpython.git
synced 2025-12-23 00:48:41 +00:00
gh-136517: Print uncollectable objects if DEBUG_UNCOLLECTABLE mode was set (#136518)
This commit is contained in:
parent
59acdba820
commit
c560df9658
3 changed files with 8 additions and 1 deletions
|
|
@ -732,6 +732,9 @@ class GCTests(unittest.TestCase):
|
|||
self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
|
||||
b"shutdown; use", stderr)
|
||||
self.assertNotIn(b"<X 'first'>", stderr)
|
||||
one_line_re = b"gc: uncollectable <X 0x[0-9A-Fa-f]+>"
|
||||
expected_re = one_line_re + b"\r?\n" + one_line_re
|
||||
self.assertNotRegex(stderr, expected_re)
|
||||
# With DEBUG_UNCOLLECTABLE, the garbage list gets printed
|
||||
stderr = run_command(code % "gc.DEBUG_UNCOLLECTABLE")
|
||||
self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
|
||||
|
|
@ -739,6 +742,8 @@ class GCTests(unittest.TestCase):
|
|||
self.assertTrue(
|
||||
(b"[<X 'first'>, <X 'second'>]" in stderr) or
|
||||
(b"[<X 'second'>, <X 'first'>]" in stderr), stderr)
|
||||
# we expect two lines with uncollectable objects
|
||||
self.assertRegex(stderr, expected_re)
|
||||
# With DEBUG_SAVEALL, no additional message should get printed
|
||||
# (because gc.garbage also contains normally reclaimable cyclic
|
||||
# references, and its elements get printed at runtime anyway).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue