import time
import traceback
import warnings
-from inspect import isabstract
# I see no other way to suppress these warnings;
# putting them in test_grammar.py has no effect:
def dash_R(the_module, test, indirect_test, huntrleaks):
# This code is hackish and inelegant, but it seems to do the job.
- import copy_reg, _abcoll
+ import copy_reg, _abcoll, io
if not hasattr(sys, 'gettotalrefcount'):
raise Exception("Tracking reference leaks requires a debug build "
ps = copy_reg.dispatch_table.copy()
pic = sys.path_importer_cache.copy()
abcs = {}
- for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
- if not isabstract(abc):
+ modules = _abcoll, io
+ for abc in [getattr(mod, a) for mod in modules for a in mod.__all__]:
+ # XXX isinstance(abc, ABCMeta) leads to infinite recursion
+ if not hasattr(abc, '_abc_registry'):
continue
for obj in abc.__subclasses__() + [abc]:
abcs[obj] = obj._abc_registry.copy()
import gc, copy_reg
import _strptime, linecache, dircache
import urlparse, urllib, urllib2, mimetypes, doctest
- import struct, filecmp, _abcoll
+ import struct, filecmp
from distutils.dir_util import _path_created
# Restore some original values.
sys._clear_type_cache()
# Clear ABC registries, restoring previously saved ABC registries.
- for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
- if not isabstract(abc):
- continue
- for obj in abc.__subclasses__() + [abc]:
- obj._abc_registry = abcs.get(obj, {}).copy()
- obj._abc_cache.clear()
- obj._abc_negative_cache.clear()
+ for abc, registry in abcs.items():
+ abc._abc_registry = registry.copy()
+ abc._abc_cache.clear()
+ abc._abc_negative_cache.clear()
# Clear assorted module caches.
_path_created.clear()