googlefonts / ufomerge

ufomerge
Apache License 2.0
11 stars 3 forks source link

New version of ufomerge exceeds recursion depth #26

Open aaronbell opened 1 month ago

aaronbell commented 1 month ago

I'm working on a non-public CJK project that has a significant number of OT features (4000 line feature.fea) and makes use of ufomerge to combine UFO files. Unfortunately, the new version of ufomerge is causing a failure in my existing build system.

  File "/Users/aaronbell/Documents/LocalProjects/CJK/sources/scripts/merge.py", line 100, in <module>
    merge_ufos(
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/ufomerge/__init__.py", line 433, in merge_ufos
    ).merge()
      ^^^^^^^
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/ufomerge/__init__.py", line 146, in merge
    ).visit(self.ufo2_features)
      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/fontTools/misc/visitor.py", line 97, in visitAttr
    self.visit(value, *args, **kwargs)
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/fontTools/misc/visitor.py", line 138, in visit
    self.visitList(obj, *args, **kwargs)
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/fontTools/misc/visitor.py", line 102, in visitList
    self.visit(value, *args, **kwargs)
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/fontTools/misc/visitor.py", line 136, in visit
    self.visitObject(obj, *args, **kwargs)
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/fontTools/misc/visitor.py", line 82, in visitObject
    _visitors = self._visitorsFor(obj)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aaronbell/Documents/LocalProjects/CJK/venv/lib/python3.11/site-packages/fontTools/misc/visitor.py", line 59, in _visitorsFor
    for celf in celf.mro():
                ^^^^^^^^^^
RecursionError: maximum recursion depth exceeded while calling a Python object

(I removed a significant amount of bits between these two code samples since it was just repetition.

The build script worked fine in version 1.6.2. Not sure what the change is between the older version and the new one, but it is causing problems. Using sys.setrecursionlimit appears to have no affect.

aaronbell commented 1 month ago

As a follow-up, it appears that my fix #18 was never pushed as a release prior to implementation of the new visitor pattern.

Rather than hope for a fix (which I know may be long in coming), I'm going to just add my copy of the library to the repository project and remove the dependency from requirements.txt.

simoncozens commented 1 month ago

Any change you could email me just the fea file? I have my suspicions about what might be happening but will need to replicate.

aaronbell commented 1 month ago

Sure! Sent over.

simoncozens commented 1 month ago

Hrm, not received, I'm afraid; firstname at firstname minus lastname dot org.