[Python-Dev] [Python-checkins] Python Regression Test Failures refleak (101)

Tim Peters tim.peters at gmail.com
Sun May 28 13:23:23 CEST 2006


[... a huge number of reference leaks reported ...]

FYI, I "reduced" the relatively simple test_bisect's leaks to this
self-contained program:

libreftest = """
    No actual doctests here.
"""

import doctest
import gc

def main():
    from sys import gettotalrefcount as trc
    for i in range(10):
        doctest.testmod()
        print trc()
        doctest.master = None
        gc.collect()

if __name__ == "__main__":
    main()

Running that here in a debug build:

C:\Code\python\PCbuild>python_d blah.py
54867
54873
54879
54885
54891
54897
54903
54909
54915
54921

So it leaks 6 references per iteration, and merely invoking
doctest.testmod() is all it takes to provoke it.  Comment out the:

         test_support.run_doctest(test_bisect, verbose)

line in test_bisect.py, and test_bisect stops leaking too (which isn't
a trivial stmt:  its doctests are a small part of test_bisect --
_most_ of it isn't leaking).

What happens next isn't obvious to me -- nobody has touched doctest.py
in over 2 weeks, so that's not the _source_ of the problem.  Alas, I
won't have computer access for the next 13 hours or so, and have to
leave this here for now.

FWIW, the biggest change that went in since that last "normal" refleak
run is the new exception reworking, so that has to be a top suspect.


More information about the Python-Dev mailing list