Repository navigation
fix(send-receive): refuse token arguments that read_csv dropped - #163
Merged
Merged
Conversation
read_csv, Send.from_csv_token() and Receive.from_csv_token() now raise CsvReadError for an argument of a send, a receive, a target or a ModbusAddress(...) that has no keyword, is written twice, is not one of the call's keywords, is empty, or runs into the next argument because a comma is missing. A keyword of the other class is refused with the keyword to write instead. A target that is neither a ModbusTcpTarget nor a ModbusRtuTarget raises CsvReadError instead of FieldError. Send.to_csv(), Receive.to_csv() and write_csv write each quote in a target's name twice, and read_csv reads it back once, so a name with a quote round-trips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
send(...)andreceive(...)tokens now refuse arguments they used to drop or misread. Coil and Copy already refuse these. The change applies toread_csv,Send.from_csv_token()andReceive.from_csv_token().Behaviour changes
CsvReadErrorfor an argument that can't be read. This covers an argument of asend, areceive, a target or aModbusAddress(...)that:v0.4.0 dropped these, or read them into another field. For example,
send(DS9,...)lostDS9,sucess=C2was dropped, anddest=on a send gave a blank source.A target of neither kind raises
CsvReadError. This is a target that is neitherModbusTcpTarget(...)norModbusRtuTarget(...), such astarget=garbage. v0.4.0 raised a plainValueErrorhere, and main raisedFieldError(invalid-token).CsvReadErrorsubclassesValueError.A quote in a Modbus target name is written twice.
read_csvreads it back once, soto_csvthenfrom_csv_tokenround-trips a name such asa"b"c. A file that v0.4.0 wrote for such a name now raisesCsvReadError, or reads as another name.A keyword that belongs to the other class gets the right keyword in the message:
send(...) has dest=. Only receive(...) accepts it. Write source=DS1 instead.A missing comma between two of the send's own values, such as
success=C2 error=C3, still raises that field'sFieldError, as in v0.4.0.Checks
read_csvandfrom_csv_token, with the same class and message apart from the location.to_csvthenfrom_csv_token, andread_csvthenwrite_csvthenread_csv.Follow-ups (not in this PR)
FieldErrormessages still advisequantity=N, which CSV refuses.Gate
make lint: passed.make docs-build: passed.make test: 18969 passed, 139 skipped.