Skip to content

Commit

Permalink
v1: use deep copy, as per #758 in copyData (#764)
Browse files Browse the repository at this point in the history
* use deep copy, as per #758 in copyData

* Add test

* try first of Tal options
  • Loading branch information
benkiel authored Nov 8, 2024
1 parent 19f9ac6 commit 5632c1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/fontParts/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def copyData(self: BaseObjectType, source: BaseObjectType) -> None:
if isinstance(selfValue, BaseObject):
selfValue.copyData(sourceValue)
else:
setattr(self, attr, sourceValue)
setattr(self, attr, deepcopy(sourceValue))

# ----------
# Exceptions
Expand Down
12 changes: 12 additions & 0 deletions Lib/fontParts/test/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -------------
Expand Down

0 comments on commit 5632c1b

Please sign in to comment.