Give each ModbusDeviceIdentification its own data - #3036
Merged
janiversen merged 1 commit intoSep 28, 2026
Merged
janiversen merged 1 commit into
janiversen merged 1 commit into
Conversation
stat_data is a class attribute and __init__ wrote into it, so every identity shared one dict. Creating any identity also changed the one held by the ModbusControlBlock, i.e. what a running server reports.
janiversen
approved these changes
Sep 28, 2026
janiversen
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, Thanks.
This is one that have been on my list for a long time, thanks for adding a solution.
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.
ModbusDeviceIdentification.stat_datais a class attribute and__init__,update()and__setitem__all write into it, so every identity object shares one dict. TheModbusControlBlockkeeps its own identity instance, so creating any identity anywhere also changes what a running server reports:The fix copies the defaults into an instance dict in
__init__. I added two tests totest/pdu/test_device.py, one for two independent identities and one for the control block case. Both fail on dev and pass with the change.test/pdu,test/serverandtest/simulatorpass (1035 tests), and ruff and pylint are clean.