Skip to content

Correctly handle object name in bytearray data #234

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

Merged
merged 1 commit into from
Apr 27, 2025

Conversation

hramrach
Copy link
Contributor

The STL data may come as text or bytearray depending on the source.

The STL output is using string formatting to output numbers, and later converts the formatted numbers to bytearray to write out.

This does not work for the object name when it comes as byte array. Wehn formatted as string the extra b'' is added around it.

Change the p() functio so that it can accept a byte array, and pass in the name as byte array. Convert the name to byte array before passing it to p() in the case it's text.

This avoids the superfluous conversion.

Fixes: #233

The STL data may come as text or bytearray depending on the source.

The STL output is using string formatting to output numbers, and later
converts the formatted numbers to bytearray to write out.

This does not work for the object name when it comes as byte array. Wehn
formatted as string the extra b'' is added around it.

Change the p() functio so that it can accept a byte array, and pass in
the name as byte array. Convert the name to byte array before passing it
to p() in the case it's text.

This avoids the superfluous conversion.

Fixes: wolph#233
@wolph
Copy link
Owner

wolph commented Apr 27, 2025

Thanks for the fix! I suppose the code could be simplified anyhow, it's largely a remainder of the Python 2 compatibility but this fixes it nicely!

@wolph wolph merged commit 8ad2b16 into wolph:develop Apr 27, 2025
9 checks passed
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.

garbage added to solid name
2 participants