Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit60903f0

Browse files
committed
FIX: account for changes to cpython with copy/deepcopy to super()
Seepython/cpython#126817 for upstream discussion.This works around the change by using (private) methods from the copy module tore-implement the path though copy/deepcopy that we would like to use but avoidthe special-casing for `super()` objects that is breaking us.We could vendor the current versions of `_keep_alive` (weakref work to managelifecycles) and `_reconstruct` (where the recursion happens) to superficiallyavoid using private functions from CPython. However, if these functions dochange significantly I worry that our copies would not inter-operate anyway.Closes#29157
1 parentc9c90c4 commit60903f0

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

‎lib/matplotlib/path.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
importcopy
1313
fromfunctoolsimportlru_cache
14+
importsys
1415
fromweakrefimportWeakValueDictionary
1516

1617
importnumpyasnp
@@ -282,7 +283,17 @@ def __deepcopy__(self, memo=None):
282283
readonly, even if the source `Path` is.
283284
"""
284285
# Deepcopying arrays (vertices, codes) strips the writeable=False flag.
285-
p=copy.deepcopy(super(),memo)
286+
ifsys.version_info>= (3,14):
287+
fromcopyimport_reconstruct,_keep_alive
288+
rv=super().__reduce_ex__(4)
289+
assertmemoisnotNone
290+
p=_reconstruct(self,memo,*rv)
291+
ifmemoisnotNone:
292+
memo[id(self)]=p
293+
_keep_alive(self,memo)
294+
295+
else:
296+
p=copy.deepcopy(super(),memo)
286297
p._readonly=False
287298
returnp
288299

‎lib/matplotlib/transforms.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
importcopy
3939
importfunctools
4040
importitertools
41+
importsys
4142
importtextwrap
4243
importweakref
4344
importmath
@@ -141,7 +142,12 @@ def __setstate__(self, data_dict):
141142
fork,vinself._parents.items()ifvisnotNone}
142143

143144
def__copy__(self):
144-
other=copy.copy(super())
145+
ifsys.version_info>= (3,14):
146+
fromcopyimport_reconstruct
147+
rv=super().__reduce_ex__(4)
148+
other=_reconstruct(self,None,*rv)
149+
else:
150+
other=copy.copy(super())
145151
# If `c = a + b; a1 = copy(a)`, then modifications to `a1` do not
146152
# propagate back to `c`, i.e. we need to clear the parents of `a1`.
147153
other._parents= {}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp