From 110b2f4c761b9184cf7bad452203145105ffe71a Mon Sep 17 00:00:00 2001 From: highoncomputers Date: Mon, 22 Jun 2026 04:01:59 +0530 Subject: [PATCH] fix: subclass of Box does not unpickle correctly 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 --- box/box.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/box/box.py b/box/box.py index 8252643..f1d7840 100644 --- a/box/box.py +++ b/box/box.py @@ -233,7 +233,7 @@ def __new__( "box_recast": box_recast, "box_dots": box_dots, "box_dots_exclude": re.compile(box_dots_exclude) if box_dots_exclude else None, - "box_class": box_class if box_class is not None else Box, + "box_class": box_class if box_class is not None else cls, "box_namespace": box_namespace, } )