From b369eede415b7f10e48377ff018e940ec3c116f1 Mon Sep 17 00:00:00 2001 From: Ben Kiel Date: Tue, 5 Nov 2024 12:43:42 -0600 Subject: [PATCH 1/3] use deep copy, as per #758 in copyData --- Lib/fontParts/base/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/fontParts/base/base.py b/Lib/fontParts/base/base.py index dbcadb50..9a3445c0 100644 --- a/Lib/fontParts/base/base.py +++ b/Lib/fontParts/base/base.py @@ -335,6 +335,8 @@ def copyData(self: BaseObjectType, source: BaseObjectType) -> None: if isinstance(selfValue, BaseObject): selfValue.copyData(sourceValue) else: + if hasattr(sourceValue, "__deepcopy__"): + sourceValue = deepcopy(sourceValue) setattr(self, attr, sourceValue) # ---------- From ad93046772285c3f081ee52a369786c14894382b Mon Sep 17 00:00:00 2001 From: Ben Kiel Date: Tue, 5 Nov 2024 12:54:21 -0600 Subject: [PATCH 2/3] Add test --- Lib/fontParts/test/test_info.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/fontParts/test/test_info.py b/Lib/fontParts/test/test_info.py index 3e10eca7..928ed147 100644 --- a/Lib/fontParts/test/test_info.py +++ b/Lib/fontParts/test/test_info.py @@ -95,6 +95,18 @@ def test_update(self): self.assertEqual(info1.familyName, "test2") self.assertEqual(info1.unitsPerEm, 2000) + # ---- + # Copy + # ---- + def test_copy(self): + info1 = self.getInfo_generic() + info1.postscriptBlueValues = [-10, 0, 50, 60] + + info2 = info1.copy() + info2.postscriptBlueValues[0] = -2 + + self.assertNotEqual(info1.postscriptBlueValues, info2.postscriptBlueValues) + # ------------- # Interpolation # ------------- From 3432d114eef65197ccbf39ee7d3fc994e0ed00fd Mon Sep 17 00:00:00 2001 From: Ben Kiel Date: Tue, 5 Nov 2024 12:59:58 -0600 Subject: [PATCH 3/3] try first of Tal options --- Lib/fontParts/base/base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/fontParts/base/base.py b/Lib/fontParts/base/base.py index 9a3445c0..39bc35b4 100644 --- a/Lib/fontParts/base/base.py +++ b/Lib/fontParts/base/base.py @@ -335,9 +335,7 @@ def copyData(self: BaseObjectType, source: BaseObjectType) -> None: if isinstance(selfValue, BaseObject): selfValue.copyData(sourceValue) else: - if hasattr(sourceValue, "__deepcopy__"): - sourceValue = deepcopy(sourceValue) - setattr(self, attr, sourceValue) + setattr(self, attr, deepcopy(sourceValue)) # ---------- # Exceptions