pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/c560df9658f1a24edea995fe6f9c84c55b37cfb3

ylesheet" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> gh-136517: Print uncollectable objects if DEBUG_UNCOLLECTABLE mode wa… · python/cpython@c560df9 · GitHub
Skip to content

Commit c560df9

Browse files
gh-136517: Print uncollectable objects if DEBUG_UNCOLLECTABLE mode was set (#136518)
1 parent 59acdba commit c560df9

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/test/test_gc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,13 +732,18 @@ def run_command(code):
732732
self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
733733
b"shutdown; use", stderr)
734734
self.assertNotIn(b"<X 'first'>", stderr)
735+
one_line_re = b"gc: uncollectable <X 0x[0-9A-Fa-f]+>"
736+
expected_re = one_line_re + b"\r?\n" + one_line_re
737+
self.assertNotRegex(stderr, expected_re)
735738
# With DEBUG_UNCOLLECTABLE, the garbage list gets printed
736739
stderr = run_command(code % "gc.DEBUG_UNCOLLECTABLE")
737740
self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
738741
b"shutdown", stderr)
739742
self.assertTrue(
740743
(b"[<X 'first'>, <X 'second'>]" in stderr) or
741744
(b"[<X 'second'>, <X 'first'>]" in stderr), stderr)
745+
# we expect two lines with uncollectable objects
746+
self.assertRegex(stderr, expected_re)
742747
# With DEBUG_SAVEALL, no additional message should get printed
743748
# (because gc.garbage also contains normally reclaimable cyclic
744749
# references, and its elements get printed at runtime anyway).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed a typo that prevented printing of uncollectable objects when the
2+
:const:`gc.DEBUG_UNCOLLECTABLE` mode was set.

Python/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ gc_collect_region(PyThreadState *tstate,
17821782
Py_ssize_t n = 0;
17831783
for (gc = GC_NEXT(&finalizers); gc != &finalizers; gc = GC_NEXT(gc)) {
17841784
n++;
1785-
if (gcstate->debug & _PyGC_DEBUG_COLLECTABLE)
1785+
if (gcstate->debug & _PyGC_DEBUG_UNCOLLECTABLE)
17861786
debug_cycle("uncollectable", FROM_GC(gc));
17871787
}
17881788
stats->uncollectable = n;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy