summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2019-12-29 16:08:00 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2019-12-29 16:08:00 +0000
commit9d4a58d35c53484a1de66396139fc34cd65f5be8 (patch)
tree386b5b6c13ec841fd790cb701edc6c88a06fadbf /lib/sqlalchemy
parentb59f87e6185b26e286147316c20022df4d729f77 (diff)
parentf7a7af70c4f6f07011fa2d521fb1560917896427 (diff)
downloadsqlalchemy-9d4a58d35c53484a1de66396139fc34cd65f5be8.tar.gz
Merge "Fix WeakSequence circular reference"
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/util/_collections.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py
index 75e1727df..04409cfd9 100644
--- a/lib/sqlalchemy/util/_collections.py
+++ b/lib/sqlalchemy/util/_collections.py
@@ -676,16 +676,18 @@ class IdentitySet(object):
class WeakSequence(object):
def __init__(self, __elements=()):
+ def _remove(item, selfref=weakref.ref(self)):
+ self = selfref()
+ if self is not None:
+ self._storage.remove(item)
+ self._remove = _remove
self._storage = [
- weakref.ref(element, self._remove) for element in __elements
+ weakref.ref(element, _remove) for element in __elements
]
def append(self, item):
self._storage.append(weakref.ref(item, self._remove))
- def _remove(self, ref):
- self._storage.remove(ref)
-
def __len__(self):
return len(self._storage)