fix: create a copy of appliance_data when initializing an Appliance#30
Merged
kubasaw merged 1 commit intoIoTLabs-pl:masterfrom Feb 13, 2025
Conversation
Otherwise, on devices with multiple zones an error will occur when creating the second appliance (zone 1) since the `appliance_data` is changes inside the `Appliance` class and the format will be changed (https://github.com/IoTLabs-pl/pyhOn/blob/b869d137fddb865803efbcf9e9e940dd3c2a32f5/pyhon/appliances/_base.py#L54-L56) See IoTLabs-pl/hon#21 (comment)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request includes a change to the
create_from_datamethod in thepython/appliances/_base.pyfile to ensure that theappliance_datadictionary is copied before being passed to thetarget_clsconstructor. This prevents potential side effects from modifying the originalappliance_datadictionary.Indeed this is happening with devices with multiple zones: an error will occur when creating the second appliance (zone 1) since the
appliance_datais changes inside theApplianceclass and the format will be changed (pyhOn/pyhon/appliances/_base.py
Lines 54 to 56 in b869d13
See IoTLabs-pl/hon#21 (comment)
python/appliances/_base.py: Modifiedcreate_from_datamethod to useappliance_data.copy()when creatingapplianceinstances to avoid side effects.