Skip to content

Fix JSON serialization in PNG compression and fixed tests #1044

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

Open
wants to merge 1 commit into
base: ros2
Choose a base branch
from

Conversation

electronicofive
Copy link

Fix JSON serialization in PNG compression #856

Problem

  • pngcompression.encode() returns bytes object
  • bytes objects are not JSON serializable
  • Causes TypeError: Object of type bytes is not JSON serializable when requesting robot maps via rosbridge

Solution

Minimal one-line change in encode() function:

return encoded.decode()  # Convert bytes to string

Test Updates

  • Fixed inconsistency between str(bytes()) and str(bytearray())
  • Added assertIsInstance(encoded, str) to prevent future regressions

@sea-bass sea-bass requested a review from bjsowa June 12, 2025 20:58
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.

2 participants