Skip to content

Prevent clear and in-place operators from mutating frozen BoxLists - #327

Closed
vitalivo wants to merge 1 commit into
cdgriffith:developfrom
vitalivo:fix/frozen-boxlist-mutations
Closed

Prevent clear and in-place operators from mutating frozen BoxLists#327
vitalivo wants to merge 1 commit into
cdgriffith:developfrom
vitalivo:fix/frozen-boxlist-mutations

Conversation

@vitalivo

Copy link
Copy Markdown

A BoxList([1, 2], frozen_box=True) can still be modified with clear(), += [3], or *= 2 (including *= 0). These operations bypass the frozen checks and can change the hash of an object already used as a dictionary key.

Block clear alongside the other frozen methods and check frozen_box in the two in-place special methods, which Python resolves on the class. Mutable lists retain their existing behavior. Four regression cases fail before the fix; they also check unchanged contents/hash after rejection and the corresponding mutable operations.

Validation: all 163 tests pass on Python 3.13 with the optional serialization dependencies, including toon-format. Includes changelog and contributor updates; targets develop as requested by CONTRIBUTING.rst.

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.

1 participant