Skip to content

fix: preserve subclass identity when unpickling Box#312

Closed
highoncomputers wants to merge 1 commit into
cdgriffith:masterfrom
highoncomputers:fix/pickle-subclass-box
Closed

fix: preserve subclass identity when unpickling Box#312
highoncomputers wants to merge 1 commit into
cdgriffith:masterfrom
highoncomputers:fix/pickle-subclass-box

Conversation

@highoncomputers

Copy link
Copy Markdown

Description

When a subclass of Box is pickled and unpickled, nested Box objects within it were reconstructed as the base Box class instead of the subclass. The __new__ method hardcoded Box as the default box_class instead of using cls, which is the actual class being instantiated.

Changes

  • box/box.py: Changed Box to cls in __new__ method's box_class default assignment

Type of Change

  • Bug fix

Related Issue

Fixes #308

When a subclass of Box is pickled and unpickled, nested Box objects
within it were being reconstructed as the base Box class instead of
the subclass. Changed the __new__ method to use cls instead of the
hardcoded Box reference.

Fixes #308
@highoncomputers highoncomputers closed this by deleting the head repository Jun 22, 2026
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.

subclass of Box does not unpickle correctly

1 participant