Fix BitStream pos not reset to 0 when content replaced via dtype setter#366
Open
gaoflow wants to merge 2 commits into
Open
Fix BitStream pos not reset to 0 when content replaced via dtype setter#366gaoflow wants to merge 2 commits into
gaoflow wants to merge 2 commits into
Conversation
When a dtype property setter (e.g. a.u8 = 14) replaces the internal bitstore of a BitStream, the bit position was silently left unchanged (issue scott-griffiths#266). All other mutating operations (prepend, __setitem__, __delitem__, insert) already reset pos to 0 after a length change. Add BitStream.__setattr__ to detect when a dtype setter replaced _bitstore (detected by id change) and reset _pos to 0 accordingly. Remove the @pytest.mark.skip("Bug scott-griffiths#266") marker from the regression test.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 6 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Author
|
I pushed a small follow-up for the Codacy documentation warning: the new Verification run locally: The ignored FP8/MXFP files require |
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.
Summary
Fixes issue #266: when a dtype property setter (e.g.
a.u8 = 14) replaces the internal content of aBitStream, the bit positionposwas silently left unchanged instead of being reset to 0.All other mutating operations (
prepend,__setitem__,__delitem__,insert) already resetposto 0 after changing the content. This makes the dtype-setter path consistent with the rest of the API.Fix
Added
BitStream.__setattr__that compares the identity of_bitstorebefore and after delegating tosuper().__setattr__. When a dtype setter replaces the bitstore,_posis reset to 0. Removed the@pytest.mark.skip("Bug #266")marker from the pre-existing regression test, which now passes.Test
769 tests pass, no regressions introduced.
This pull request was prepared with the assistance of AI, under my direction and review.