--- /dev/null
+.. change::
+ :tags: orm, bug
+ :tickets: 7389
+
+ Fixed issue where a list mapped with :func:`_orm.relationship` would go
+ into an endless loop if in-place added to itself, i.e. the ``+=`` operator
+ were used, as well as if ``.extend()`` were given the same list.
+
def extend(fn):
def extend(self, iterable):
- for value in iterable:
+ for value in list(iterable):
self.append(value)
_tidy(extend)
def __iadd__(self, iterable):
# list.__iadd__ takes any iterable and seems to let TypeError
# raise as-is instead of returning NotImplemented
- for value in iterable:
+ for value in list(iterable):
self.append(value)
return self
assert control == p.children
assert control == list(p.children)
+ # test #7389
+ if hasattr(p.children, "__iadd__"):
+ control += control
+ p.children += p.children
+ assert control == list(p.children)
+
+ control[:] = [o]
+ p.children[:] = [o]
+ if hasattr(p.children, "extend"):
+ control.extend(control)
+ p.children.extend(p.children)
+ assert control == list(p.children)
+
def test_custom(self):
someothertable, sometable = (
self.tables.someothertable,