From a2f88778109b5c565868a0ed2f1abbd5c5939428 Mon Sep 17 00:00:00 2001 From: Mysteryem Date: Fri, 14 Nov 2025 20:58:44 +0000 Subject: [PATCH] Core: Fix #5605 - Trigger values being shared by weights.yaml slots (#5636) The "+" and "-" trigger operations modify sets/lists in-place, but triggers could set a value to the same set/list for multiple slots using weights.yaml. This fix deep-copies all values set from new (trigger) weights to ensure that the values do not get shared across multiple slots. --- Generate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Generate.py b/Generate.py index 2b27cb222b..3bc383cac9 100644 --- a/Generate.py +++ b/Generate.py @@ -367,7 +367,10 @@ def update_weights(weights: dict, new_weights: dict, update_type: str, name: str f" received {type(new_value).__name__}.") cleaned_weights[option_name] = cleaned_value else: - cleaned_weights[option_name] = new_weights[option] + # Options starting with + and - may modify values in-place, and new_weights may be shared by multiple slots + # using the same .yaml, so ensure that the new value is a copy. + cleaned_value = copy.deepcopy(new_weights[option]) + cleaned_weights[option_name] = cleaned_value new_options = set(cleaned_weights) - set(weights) weights.update(cleaned_weights) if new_options: