commit: 6aacc38b118eac54ecbb6dfdd53fc4df962f3f03 Author: Brian Harring <ferringb <AT> gmail <DOT> com> AuthorDate: Fri Nov 28 20:37:05 2025 +0000 Commit: Brian Harring <ferringb <AT> gmail <DOT> com> CommitDate: Fri Nov 28 21:46:31 2025 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=6aacc38b
feat!: drop weakrefs module This was a way to do a safely attached a __delete__ to an object. That's not relevant now, nor was it in use. Signed-off-by: Brian Harring <ferringb <AT> gmail.com> src/snakeoil/weakrefs.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/snakeoil/weakrefs.py b/src/snakeoil/weakrefs.py deleted file mode 100644 index 83a79c0..0000000 --- a/src/snakeoil/weakrefs.py +++ /dev/null @@ -1,33 +0,0 @@ -import os -from functools import partial -from weakref import ref - -from .obj import BaseDelayedObject - - -def finalize_instance(obj, weakref_inst): - try: - obj.__finalizer__() - finally: - obj.__disable_finalization__() - - -class WeakRefProxy(BaseDelayedObject): - def __instantiate_proxy_instance__(self): - obj = BaseDelayedObject.__instantiate_proxy_instance__(self) - weakref = ref(self, partial(finalize_instance, obj)) - obj.__enable_finalization__(weakref) - return obj - - -def __enable_finalization__(self, weakref): - # note we directly access the class, to ensure the instance hasn't overshadowed. - self.__class__.__finalizer_weakrefs__[os.getpid()][id(self)] = weakref - - -def __disable_finalization__(self): - # note we directly access the class, to ensure the instance hasn't overshadowed. - # use pop to allow for repeat invocations of __disable_finalization__ - d = self.__class__.__finalizer_weakrefs__.get(os.getpid) - if d is not None: - d.pop(id(self), None)
