[4000] Delete nodes via Python

This used to work in G3:

path = Layer.paths[0]
del path.nodes[0]

But now I get:

Traceback (most recent call last):
  File "Macro 1.py", line 2
  File "__init__.py", line 776, in __delitem__
    self.removeByIndex(idx)
    ~~~~~~~~~~~~~~~~~~^^^^^
TypeError: PathNodesProxy.removeByIndex() takes 1 positional argument but 2 were given

This is highlighted in blue and underlined, but clicking it just gives an error sound effect.

Confirmed, this is a bug in the Glyphs 4 Python wrapper. PathNodesProxy.removeByIndex() currently has the wrong signature, which causes:

del path.nodes[0]

to raise that TypeError.

As a workaround, this works:

path = Layer.paths[0]
path.nodes.remove(path.nodes[0])

Calling the underlying method directly also works:

path.removeNode_(path.nodes[0])
1 Like

Fixed it. Thanks.

1 Like