Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python accessors and packet restore_defaults #1399

Merged
merged 2 commits into from
Jul 13, 2024
Merged

Fix python accessors and packet restore_defaults #1399

merged 2 commits into from
Jul 13, 2024

Conversation

jmthomas
Copy link
Member

closes #1376

Copy link

codecov bot commented Jul 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.40%. Comparing base (de1fa10) to head (31d3190).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1399      +/-   ##
==========================================
+ Coverage   75.37%   75.40%   +0.02%     
==========================================
  Files         600      600              
  Lines       44689    44701      +12     
  Branches      777      777              
==========================================
+ Hits        33686    33707      +21     
+ Misses      10916    10907       -9     
  Partials       87       87              
Flag Coverage Δ
frontend 55.40% <ø> (ø)
python 84.01% <ø> (+0.08%) ⬆️
ruby-api 48.60% <ø> (ø)
ruby-backend 80.20% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -38,6 +38,7 @@ def class_write_item(cls, item, value, buffer):
else:
decoded = buffer

print(f"cbor item:{item.name} value:{value} decoded:{decoded}")
Copy link
Member

Choose a reason for hiding this comment

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

Remove debugging print.


print(f"json key:{item.key} value:{value} decoded:{decoded}")
Copy link
Member

Choose a reason for hiding this comment

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

Remove debugging print

buffer = json.loads(buffer.decode())
except (UnicodeDecodeError, AttributeError):
Copy link
Member

Choose a reason for hiding this comment

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

What is going on here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Attempt at duck-typing the input so we could use bytes or bytearray ... I think we need bytearray (mutable) so I'll revert back.

Copy link

buffer[0:-1] = self.template
# Set both the internal buffer and our local copy
self.buffer = self.template
buffer = self._buffer
Copy link
Member Author

@jmthomas jmthomas Jul 12, 2024

Choose a reason for hiding this comment

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

This was the fix to packet.py ... everything else was formatting

@@ -459,15 +459,15 @@ def process_current_packet(self, parser, keyword, params):
case "TEMPLATE":
usage = f"{keyword} <Template string>"
parser.verify_num_parameters(1, 1, usage)
self.current_packet.template = params[0]
self.current_packet.template = bytearray(params[0], "ascii")
Copy link
Member Author

Choose a reason for hiding this comment

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

Template must be a bytearray

@jmthomas jmthomas merged commit c85245c into main Jul 13, 2024
26 checks passed
@jmthomas jmthomas deleted the py_accessor branch July 13, 2024 02:30
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.

JSON ACCESSOR 5.17.1 Python
2 participants