You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ObservableList SET signal passes an exhausted generator as new when assigned a generator #3907
When an ObservableList is assigned a generator (or any other one-shot iterable), the ListSignals.SET signal's new payload is the already-exhausted iterator, so subscribers see no values.
setattr(
instance,
self.private_name,
SignalingList(value, instance, self.public_name), # consumes value
)
instance.notify(
self.public_name,
ListSignals.SET,
old=old_value,
new=value, # the consumed iterable
)
Why it is wrong
ObservableList.__set__ accepts any Iterable (per its signature), and SignalingList.__init__ materializes it with list(iterable). The signal then forwards the original value. For a generator, that object has already been consumed, so list(message.additional_kwargs["new"]) is [].
For a plain list, new is the caller's own list object. If the caller mutates that list later, the payload a subscriber kept changes with it.
The batched path already does the right thing. _aggregate_list emits SET with new = list(getattr(owner, name)), a snapshot of the stored values. So the same assignment produces different payloads depending on whether it happens inside batch().
Activity
Emit list snapshots in unbatched ObservableList SET signals (mesa#3988)
Emit list snapshots in unbatched ObservableList SET signals (#3988)