Skip to content

Commit

Permalink
Fix copyData based on #758 (#765)
Browse files Browse the repository at this point in the history
* add test based on #758

* use deepcopy in copyData
  • Loading branch information
benkiel authored Nov 8, 2024
1 parent 2bfa558 commit f67a570
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Lib/fontParts/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ def copyData(self, source):
if isinstance(selfValue, BaseObject):
selfValue.copyData(sourceValue)
else:
setattr(self, attr, sourceValue)

setattr(self, attr, deepcopy(sourceValue))
# ----------
# Exceptions
# ----------
Expand Down Expand Up @@ -832,10 +831,10 @@ def _setIdentifier(self, value):
def reference(obj):
"""
This code returns a simple function that returns the given object.
This is a backwards compatibility function that is under review.
See #749. We used to use weak references, but they proved
problematic (see issue #71), so this function was put in place to
make sure existing code continued to function. The need for it is
This is a backwards compatibility function that is under review.
See #749. We used to use weak references, but they proved
problematic (see issue #71), so this function was put in place to
make sure existing code continued to function. The need for it is
questionable, so it may be deleted soon.
"""
def wrapper():
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 @@ -122,6 +122,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 f67a570

Please sign in to comment.