This won't scale once there are other modules using ABCs, and there
will be (starting with io).

But you're right that the registries and caches keep stuff alive. I
need to start using weakrefs instead.

Regarding the name _abcoll: I read it as "ABstract Collections". :-)

--Guido

On 6/15/07, neal.norwitz <[email protected]> wrote:
> Author: neal.norwitz
> Date: Sat Jun 16 05:54:18 2007
> New Revision: 56004
>
> Modified:
>    python/branches/p3yk/Lib/test/regrtest.py
> Log:
> Fix it so test_os no longer reports ref leaks by clearing all the caches
> the ABCMeta stores on the class.  Apply this to all the ABC collections
> as well as the class of os.environ which inherits from an ABC collection.
>
>
> Modified: python/branches/p3yk/Lib/test/regrtest.py
> ==============================================================================
> --- python/branches/p3yk/Lib/test/regrtest.py   (original)
> +++ python/branches/p3yk/Lib/test/regrtest.py   Sat Jun 16 05:54:18 2007
> @@ -697,7 +697,7 @@
>      import gc, copy_reg
>      import _strptime, linecache, dircache
>      import urlparse, urllib, urllib2, mimetypes, doctest
> -    import struct, filecmp, collections
> +    import struct, filecmp, _abcoll
>      from distutils.dir_util import _path_created
>
>      # Restore some original values.
> @@ -708,8 +708,10 @@
>      sys.path_importer_cache.update(pic)
>
>      # Clear ABC registries.
> -    for obj in [collections.Hashable, collections.Iterable]:
> +    for obj in [getattr(_abcoll, a) for a in _abcoll.__all__] + [os.environ]:
>          obj._ABCMeta__registry.clear()
> +        obj._ABCMeta__cache.clear()
> +        obj._ABCMeta__negative_cache.clear()
>
>      # Clear assorted module caches.
>      _path_created.clear()
> _______________________________________________
> Python-3000-checkins mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-3000-checkins
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to