diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-10-09 21:25:06 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-10-09 21:25:06 (GMT) |
commit | 0bd9fac7a866ec886ae8f93f9c24dcda6d436929 (patch) | |
tree | 63be35574a9e5e8cbd9d1655d655bddc8b283a8e /Modules/gcmodule.c | |
parent | 359a1975cbca488ccd5ea13bd7268d7e88664078 (diff) | |
download | cpython-0bd9fac7a866ec886ae8f93f9c24dcda6d436929.zip cpython-0bd9fac7a866ec886ae8f93f9c24dcda6d436929.tar.gz cpython-0bd9fac7a866ec886ae8f93f9c24dcda6d436929.tar.bz2 |
[3.8] bpo-38379: don't claim objects are collected when they aren't (GH-16658) (GH-16683)
* [bpo-38379](https://bugs.python.org/issue38379): when a finalizer resurrects an object,
nothing is actually collected in this run of gc.
Change the stats to relect that truth.
(cherry picked from commit ecbf35f9335b0420cb8adfda6f299d6747a16515)
Co-authored-by: Tim Peters <tim.peters@gmail.com>
https://bugs.python.org/issue38379
Automerge-Triggered-By: @pablogsal
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r-- | Modules/gcmodule.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 8bdbafe..8d7d67c 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -1095,12 +1095,9 @@ collect(struct _gc_runtime_state *state, int generation, validate_list(&finalizers, 0); validate_list(&unreachable, PREV_MASK_COLLECTING); - /* Collect statistics on collectable objects found and print - * debugging information. - */ - for (gc = GC_NEXT(&unreachable); gc != &unreachable; gc = GC_NEXT(gc)) { - m++; - if (state->debug & DEBUG_COLLECTABLE) { + /* Print debugging information. */ + if (state->debug & DEBUG_COLLECTABLE) { + for (gc = GC_NEXT(&unreachable); gc != &unreachable; gc = GC_NEXT(gc)) { debug_cycle("collectable", FROM_GC(gc)); } } @@ -1122,6 +1119,7 @@ collect(struct _gc_runtime_state *state, int generation, * the reference cycles to be broken. It may also cause some objects * in finalizers to be freed. */ + m += gc_list_size(&unreachable); delete_garbage(state, &unreachable, old); } |