Convert strings to unicode before passing to pymavlink#1703
Open
peterbarker wants to merge 2 commits into
Open
Convert strings to unicode before passing to pymavlink#1703peterbarker wants to merge 2 commits into
peterbarker wants to merge 2 commits into
Conversation
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>
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.
Avoid the need to specify the encoding of a string when using the
messagecommand by simply converting any passed-in-string to bytes before passing to pymavlinkThis fixes the same problem as in ArduPilot/pymavlink#1225
This is basically, "give pymavlink what it wants", which is unicode.