Skip to content

Fix pickling of frozen BoxList instances (#344) - #345

Open
Fire162 wants to merge 1 commit into
cdgriffith:developfrom
Fire162:fix/boxlist-frozen-pickle
Open

Fire162 wants to merge 1 commit into
cdgriffith:developfrom
Fire162:fix/boxlist-frozen-pickle

Conversation

@Fire162

@Fire162 Fire162 commented Oct 29, 2026

Copy link
Copy Markdown

Summary

A frozen BoxList (frozen_box=True) raised an AttributeError / PicklingError on pickle.dumps because the mutation guard was defined as a local function inside BoxList.__init__. Pickle serializes instance attributes but cannot serialize <locals>.frozen.

This moves the mutation guard function to module scope as _frozen_box_list_method. Frozen BoxList instances now round-trip cleanly through pickle across all pickle protocols while maintaining their frozen protection after deserialization.

Changes

  • Defined module-level _frozen_box_list_method in box/box_list.py and referenced it in BoxList.__init__.
  • Added test_frozen_list_pickle and test_box_list_pickle in test/test_box_list.py to verify pickling and mutation guards across all pickle protocols (for both populated and empty lists).
  • Updated CHANGES.rst and AUTHORS.rst.

Fixes #344

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