Adds conversion to bytearray within Segment#54
Merged
eerimoq merged 1 commit intoeerimoq:masterfrom Feb 24, 2026
Merged
Conversation
Previously, depending on how a Segment was created, the internal data may have been stored as an immutable bytes object. This caused issues with modifying operations.
Owner
|
I like it. |
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.
Fix for #53
Previously, depending on how a Segment was created, the internal data may have been stored as an immutable bytes object. This caused issues with modifying operations.
Now, the best I've found to come up with an as small as possible fix was a simple conversion to bytearray within
Segment.__init__().I've also checked out python type-hints, but these do not enforce a type during runtime.
I can not guarantee that
self.datawill never be internally assigned a bytes object in some obscure way. (And I unfortunately don't have enough time to do a full analysis to catch every edge-case). For a sanity check I modified the Segment equal operator and executed all testsBefore change: I got a mix of True and False, newly added unit test was failed
After change: I only saw True, newly added unit test succeeded
On my end all unit tests are successful.
Hope it helps, and let me know if you need anything else for this PR.