Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,21 @@ def __deepcopy__(self, memo=None):
readonly, even if the source `Path` is.
"""
# Deepcopying arrays (vertices, codes) strips the writeable=False flag.
p = copy.deepcopy(super(), memo)
p._readonly = False
return p
cls = self.__class__
new_instance = cls.__new__(cls)

# Add the new instance to the memo dictionary to handle circular references
if memo is None:
memo = {}
memo[id(self)] = new_instance

# Deepcopy the attributes explicitly
new_instance.vertices = copy.deepcopy(self.vertices, memo)
new_instance.codes = copy.deepcopy(self.codes, memo)
new_instance._readonly = False

return new_instance


deepcopy = __deepcopy__

Expand Down