@@ -689,6 +689,7 @@ def cleanup_test_droppings(testname, verbose):
689689def dash_R (the_module , test , indirect_test , huntrleaks ):
690690 # This code is hackish and inelegant, but it seems to do the job.
691691 import copy_reg , _abcoll
692+ from abc import _Abstract
692693
693694 if not hasattr (sys , 'gettotalrefcount' ):
694695 raise Exception ("Tracking reference leaks requires a debug build "
@@ -699,7 +700,8 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
699700 ps = copy_reg .dispatch_table .copy ()
700701 pic = sys .path_importer_cache .copy ()
701702 abcs = {obj : obj ._abc_registry .copy ()
702- for abc in [getattr (_abcoll , a ) for a in _abcoll .__all__ ]
703+ for abc in [getattr (_abcoll , a ) for a in _abcoll .__all__
704+ if isinstance (getattr (_abcoll , a ), _Abstract )]
703705 for obj in abc .__subclasses__ () + [abc ]}
704706
705707 if indirect_test :
@@ -737,6 +739,7 @@ def dash_R_cleanup(fs, ps, pic, abcs):
737739 import _strptime , linecache , dircache
738740 import urlparse , urllib , urllib2 , mimetypes , doctest
739741 import struct , filecmp , _abcoll
742+ from abc import _Abstract
740743 from distutils .dir_util import _path_created
741744
742745 # Restore some original values.
@@ -748,6 +751,8 @@ def dash_R_cleanup(fs, ps, pic, abcs):
748751
749752 # Clear ABC registries, restoring previously saved ABC registries.
750753 for abc in [getattr (_abcoll , a ) for a in _abcoll .__all__ ]:
754+ if not isinstance (abc , _Abstract ):
755+ continue
751756 for obj in abc .__subclasses__ () + [abc ]:
752757 obj ._abc_registry = abcs .get (obj , {}).copy ()
753758 obj ._abc_cache .clear ()
0 commit comments