Skip to content

Convert strings to unicode before passing to pymavlink#1703

Open
peterbarker wants to merge 2 commits into
ArduPilot:masterfrom
peterbarker:pr/fix-string-encoding
Open

Convert strings to unicode before passing to pymavlink#1703
peterbarker wants to merge 2 commits into
ArduPilot:masterfrom
peterbarker:pr/fix-string-encoding

Conversation

@peterbarker

Copy link
Copy Markdown
Contributor

Avoid the need to specify the encoding of a string when using the message command by simply converting any passed-in-string to bytes before passing to pymavlink

This fixes the same problem as in ArduPilot/pymavlink#1225

This is basically, "give pymavlink what it wants", which is unicode.

peterbarker and others added 2 commits July 13, 2026 11:39
pymavlink's generated *_send methods require bytes for char[] fields
since the typed Python3 generator was adopted (pymavlink 2.4.38), so
e.g.
  message LOG_STREAM_NAMED_VALUE 1 1 "'XKF4'" "'SS'"
died with "TypeError: must be str or None, not bytes".

Look up the message class's fieldtypes and encode any str supplied
for a char field; bytes arguments are passed through unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pymavlink's generated statustext_send requires bytes for the text
field since the typed Python3 generator was adopted (pymavlink
2.4.38), so the example module's boredom statustext died with
"TypeError: must be str or None, not bytes".

This is the crash reported in pymavlink issue ArduPilot#1225.

Co-Authored-By: j3kestrel <17890332+j3kestrel@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant