Skip to content

Don't bool-test explicit datastores#2638

Merged
janiversen merged 1 commit into
pymodbus-dev:devfrom
smurfix:bool-ds
Apr 14, 2025
Merged

Don't bool-test explicit datastores#2638
janiversen merged 1 commit into
pymodbus-dev:devfrom
smurfix:bool-ds

Conversation

@smurfix
Copy link
Copy Markdown
Contributor

@smurfix smurfix commented Apr 14, 2025

Empty data stores tend to be false-y when tested,
which is not the intent here.

Should probably be backported to master

Empty data stores tend to be false-y when tested,
which is not the intent here.
@janiversen
Copy link
Copy Markdown
Collaborator

What do you mean "backported to master" ? we never work on master except when merging for a release, so this PR like other PRs will be part of the next release.

If you refer to making a new x.y.Z release of an old version, that is something we do not do, we only support v3.9.x. When v4.0.0 is released we will continue to support v3.9.x for 1-2 years allowing plenty of time to upgrade.

Copy link
Copy Markdown
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@janiversen janiversen merged commit e342eb5 into pymodbus-dev:dev Apr 14, 2025
1 check passed
janiversen pushed a commit that referenced this pull request Apr 18, 2025
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.

@smurfix
Copy link
Copy Markdown
Contributor Author

smurfix commented Apr 24, 2025

Yeah I did test the code, but unfortunately I did it with di. Surprise …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants