Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pymodbus/datastore/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ def __init__(self, *_args,
):
"""Initialize the datastores."""
self.store = {}
self.store["d"] = di or ModbusSequentialDataBlock.create()
self.store["c"] = co or ModbusSequentialDataBlock.create()
self.store["i"] = ir or ModbusSequentialDataBlock.create()
self.store["h"] = hr or ModbusSequentialDataBlock.create()
self.store["d"] = di if di is not None else ModbusSequentialDataBlock.create()
self.store["c"] = co if di is not None else ModbusSequentialDataBlock.create()
self.store["i"] = ir if di is not None else ModbusSequentialDataBlock.create()
self.store["h"] = hr if di is not None else ModbusSequentialDataBlock.create()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last 3 lines of the new code look like cut'n'paste mistakes.

e.g. the original code
self.store["c"] = co or ModbusSequentialDataBlock.create()
tested variable co and conditionally assigned it

in the new code, co is conditionally assigned but di was tested:
self.store["c"] = co if di is not None else ModbusSequentialDataBlock.create()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. Obviously. Thanks, will fix ASAP.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smurfix I thought you had tested the code, if you open a new PR please add tests to ensure it works correctly.

But you have time, because unless a serious bug is found there will be no 3.9 updates before late summer.


def __str__(self):
"""Return a string representation of the context.
Expand Down