Skip to content

Copy protocol broken: deepcopy of any live descriptor raises; copy of any EasyList raises #271

@rozyczko

Description

@rozyczko

Findings V-H3, V-H2, G-M3 in DEEP_ANALYSIS.md (parent #261).

  1. DescriptorBase inherits SerializerComponent.__deepcopy__ (io/serializer_component.py:28-29), which does self.from_dict(self.as_dict()) without skipping unique_name; reconstruction collides in the global map (map.py:166-167 raises ValueError: Object name ... already exists). So copy.deepcopy(param) always fails while copy.copy(param) works (__copy__ correctly skips unique_name). NewBase patched this for itself; DescriptorBase did not.
  2. EasyList.to_dict() (easy_list.py:359) overrides NewBase.to_dict(skip=...) with an incompatible signature (Liskov violation); NewBase.__copy__ calls self.to_dict(skip=['unique_name']) -> TypeError for every EasyList.
  3. __deepcopy__ also ignores memo, so shared children are duplicated instead of shared (broken deepcopy semantics for diamond graphs).

Fix: implement __deepcopy__ at the hierarchy root with skip=['unique_name'] + memo support; align EasyList.to_dict signature. Add copy/deepcopy round-trip tests for every descriptor and collection type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [area] base classesChanges to or creation of new base classes[priority] highShould be prioritized soon[scope] bugBug report or fix (major.minor.PATCH)
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions