Skip to content

FUTURE BUG: reconsider how we deep-copy path objects #29157 #29161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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,11 +282,23 @@
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)

Check failure on line 287 in lib/matplotlib/path.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 W293 blank line contains whitespace Raw Output: ./lib/matplotlib/path.py:287:1: W293 blank line contains whitespace
# Add the new instance to the memo dictionary to handle circular references
if memo is None:
memo = {}

Check warning on line 290 in lib/matplotlib/path.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/path.py#L290

Added line #L290 was not covered by tests
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

Check warning on line 296 in lib/matplotlib/path.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/path.py#L295-L296

Added lines #L295 - L296 were not covered by tests

return new_instance

Check warning on line 298 in lib/matplotlib/path.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/path.py#L298

Added line #L298 was not covered by tests


deepcopy = __deepcopy__

Check failure on line 301 in lib/matplotlib/path.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 E303 too many blank lines (2) Raw Output: ./lib/matplotlib/path.py:301:5: E303 too many blank lines (2)

@classmethod
def make_compound_path_from_polys(cls, XY):
Expand Down
Loading