Conversation
When copying dict subclasses (defaultdict, OrderedDict, Counter), the function was returning a plain dict instead of preserving the type. A defaultdict would lose its default_factory, and an OrderedDict would become a regular dict. The fix checks if the dict is a plain dict (type is dict) and uses the fast path. For subclasses, it creates a shallow copy, clears it, and repopulates with deep-copied values, preserving the subclass type.
|
@Jah-yee is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
|
|
Hi @Jah-yee, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
Summary
When copying dict subclasses (defaultdict, OrderedDict, Counter), the
_deepcopy_with_exceptionsfunction was returning a plaindictinstead of preserving the type.Bug
defaultdictloses itsdefault_factoryOrderedDictbecomes a regulardictCounterbecomes a regulardictFix
The fix checks if the dict is a plain
dict(type isdict) and uses the fast path. For subclasses, it creates a shallow copy, clears it, and repopulates with deep-copied values, preserving the subclass type.