]> granicus.if.org Git - python/commitdiff
clear zip stat cache after each ref leak run
authorBenjamin Peterson <benjamin@python.org>
Thu, 9 Jan 2014 17:10:30 +0000 (11:10 -0600)
committerBenjamin Peterson <benjamin@python.org>
Thu, 9 Jan 2014 17:10:30 +0000 (11:10 -0600)
Lib/test/regrtest.py
Lib/test/test_pkgutil.py

index 21709f7032a135e1ebfd90ba72c51d6cfa695cf0..da66c8feb1d0bc1f429e2a679e8639f62fb02aa6 100755 (executable)
@@ -1002,9 +1002,10 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
     try:
         import zipimport
     except ImportError:
-        zdc = None # Run unmodified on platforms without zipimport support
+        zsc = zdc = None # Run unmodified on platforms without zipimport support
     else:
         zdc = zipimport._zip_directory_cache.copy()
+        zsc = zipimport._zip_stat_cache.copy()
     abcs = {}
     modules = _abcoll, _pyio
     for abc in [getattr(mod, a) for mod in modules for a in mod.__all__]:
@@ -1027,12 +1028,12 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
     repcount = nwarmup + ntracked
     print >> sys.stderr, "beginning", repcount, "repetitions"
     print >> sys.stderr, ("1234567890"*(repcount//10 + 1))[:repcount]
-    dash_R_cleanup(fs, ps, pic, zdc, abcs)
+    dash_R_cleanup(fs, ps, pic, zdc, zsc, abcs)
     for i in range(repcount):
         rc_before = sys.gettotalrefcount()
         run_the_test()
         sys.stderr.write('.')
-        dash_R_cleanup(fs, ps, pic, zdc, abcs)
+        dash_R_cleanup(fs, ps, pic, zdc, zsc, abcs)
         rc_after = sys.gettotalrefcount()
         if i >= nwarmup:
             deltas.append(rc_after - rc_before)
@@ -1046,7 +1047,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
         return True
     return False
 
-def dash_R_cleanup(fs, ps, pic, zdc, abcs):
+def dash_R_cleanup(fs, ps, pic, zdc, zsc, abcs):
     import gc, copy_reg
     import _strptime, linecache
     dircache = test_support.import_module('dircache', deprecated=True)
@@ -1072,6 +1073,8 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
     else:
         zipimport._zip_directory_cache.clear()
         zipimport._zip_directory_cache.update(zdc)
+        zipimport._zip_stat_cache.clear()
+        zipimport._zip_stat_cache.update(zsc)
 
     # clear type cache
     sys._clear_type_cache()
index f665e960d4074b3cdc4f8576b4b94cf85f00ff25..382474d3cc6e6dd2436d5385b3adacbd74e24b5b 100644 (file)
@@ -133,9 +133,7 @@ class PkgutilPEP302Tests(unittest.TestCase):
 
 def test_main():
     run_unittest(PkgutilTests, PkgutilPEP302Tests)
-    # this is necessary if test is run repeated (like when finding leaks)
-    import zipimport
-    zipimport._zip_directory_cache.clear()
+
 
 if __name__ == '__main__':
     test_main()