On Nov 23, 2014 4:10 AM, "Patrick Stinson" <patrickk...@gmail.com> wrote:
> m = types.ModuleType('mine')
> exec(s, m.__dict__)
> print('deleting...')
> m = None
> print('done')
>
> and the output is:
>
> deleting...
> done
> __del__
>
> I the “__del__" to come between “deleting…” and “done”. This is not being
run from the interactive interpreter by via a .py file.

This suggests the presence of a reference cycle, since the object is
deleted afterward by the garbage collector. One cycle here is that the
__del__ function has a reference to the module's globals dict, which has a
reference to the class instance, which has a reference to the class, which
has a reference back to the function. There may be other cycles here as
well, but it may also be that the module object itself isn't part of them.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to