From 48ac9911c0d4f9e7a47a7644e7db621c02b6d037 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 11 May 2011 09:42:35 +0000 Subject: [PATCH] more graceful fix related to the last commit --- extra/oset/_abc.py | 7 +++---- extra/oset/pyoset.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/extra/oset/_abc.py b/extra/oset/_abc.py index 228e526fa..d3cf1b51e 100644 --- a/extra/oset/_abc.py +++ b/extra/oset/_abc.py @@ -467,10 +467,9 @@ class OrderedSet(MutableSet): return len(self) == len(other) and list(self) == list(other) return set(self) == set(other) - # causing "Exception TypeError: TypeError('list indices must be integers, not NoneType',)" - # in garbage collection phase - #def __del__(self): - #self.clear() # remove circular references + def __del__(self): + if all([KEY, PREV, NEXT]): + self.clear() # remove circular references if __name__ == '__main__': print(OrderedSet('abracadaba')) diff --git a/extra/oset/pyoset.py b/extra/oset/pyoset.py index ea3d3709f..2a67455bc 100644 --- a/extra/oset/pyoset.py +++ b/extra/oset/pyoset.py @@ -76,9 +76,8 @@ class OrderedSet(MutableSet): return len(self) == len(other) and list(self) == list(other) return set(self) == set(other) - # causing "Exception TypeError: TypeError('list indices must be integers, not NoneType',)" - # in garbage collection phase - #def __del__(self): - #self.clear() # remove circular references + def __del__(self): + if all([KEY, PREV, NEXT]): + self.clear() # remove circular references oset = OrderedSet