[Python-checkins] cpython (3.3): clear zip stat cache after each ref leak run
benjamin.peterson
python-checkins at python.org
Thu Jan 9 18:12:43 CET 2014
http://hg.python.org/cpython/rev/fafac90b69c4
changeset: 88370:fafac90b69c4
branch: 3.3
parent: 88368:1bdcaf6c0eb5
user: Benjamin Peterson <benjamin at python.org>
date: Thu Jan 09 11:10:30 2014 -0600
summary:
clear zip stat cache after each ref leak run
files:
Lib/test/regrtest.py | 11 +++++++----
Lib/test/test_pkgutil.py | 5 -----
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1318,9 +1318,10 @@
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 = {}
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
@@ -1343,13 +1344,13 @@
print("beginning", repcount, "repetitions", file=sys.stderr)
print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr)
sys.stderr.flush()
- 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('.')
sys.stderr.flush()
- 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)
@@ -1364,7 +1365,7 @@
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, copyreg
import _strptime, linecache
import urllib.parse, urllib.request, mimetypes, doctest
@@ -1390,6 +1391,8 @@
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()
diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py
--- a/Lib/test/test_pkgutil.py
+++ b/Lib/test/test_pkgutil.py
@@ -338,11 +338,6 @@
def test_main():
run_unittest(PkgutilTests, PkgutilPEP302Tests, ExtendPathTests,
NestedNamespacePackageTest, ImportlibMigrationTests)
- # this is necessary if test is run repeated (like when finding leaks)
- import zipimport
- import importlib
- zipimport._zip_directory_cache.clear()
- importlib.invalidate_caches()
if __name__ == '__main__':
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list