Ryan Heisler added the comment:
Perfect, thanks for your quick response. I was passing a bound method of obj as
the func to `weakref.finalize(obj, func, /, *args, **kwargs)`. It slipped my
mind that an instance variable like self.name and a bound method like
self.clean_up, though they both b
Tim Peters added the comment:
Not a problem. Arguments to a function are evaluated before the function is
invoked. So in
self._finalizer = weakref.finalize(self, shutil.rmtree, self.name)
self.name is evaluated before weakref.finalize is called(). `self.name`
_extracts_ the `.name` attribu
New submission from Ryan Heisler :
In the documentation for `weakref.finalize`
(https://docs.python.org/3.9/library/weakref.html#weakref.finalize), it says:
"Note It is important to ensure that func, args and kwargs do not own any
references to obj, either directly or indirectly, since otherw