mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
If any trash happened to be sitting around waiting to get collected at
the time it's called, test_saveall() made it look a leak, triggering bogus warnings from regrtest's -l (findleaks) mode.
This commit is contained in:
parent
75ea1e11dc
commit
c708c0a8c4
1 changed files with 8 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
from test.test_support import verify, verbose, TestFailed
|
from test.test_support import verify, verbose, TestFailed, vereq
|
||||||
import sys
|
import sys
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
|
@ -168,6 +168,12 @@ def test_frame():
|
||||||
def test_saveall():
|
def test_saveall():
|
||||||
# Verify that cyclic garbage like lists show up in gc.garbage if the
|
# Verify that cyclic garbage like lists show up in gc.garbage if the
|
||||||
# SAVEALL option is enabled.
|
# SAVEALL option is enabled.
|
||||||
|
|
||||||
|
# First make sure we don't save away other stuff that just happens to
|
||||||
|
# be waiting for collection.
|
||||||
|
gc.collect()
|
||||||
|
vereq(gc.garbage, []) # if this fails, someone else created immortal trash
|
||||||
|
|
||||||
debug = gc.get_debug()
|
debug = gc.get_debug()
|
||||||
gc.set_debug(debug | gc.DEBUG_SAVEALL)
|
gc.set_debug(debug | gc.DEBUG_SAVEALL)
|
||||||
l = []
|
l = []
|
||||||
|
@ -175,6 +181,7 @@ def test_saveall():
|
||||||
id_l = id(l)
|
id_l = id(l)
|
||||||
del l
|
del l
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
vereq(len(gc.garbage), 1)
|
||||||
try:
|
try:
|
||||||
for obj in gc.garbage:
|
for obj in gc.garbage:
|
||||||
if id(obj) == id_l:
|
if id(obj) == id_l:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue