Update breaks script


#1

I have been using various scripts to access anchors. Updating from 1219 to 1224 today something seems to be broken.

The most simple case is:

f = Glyphs.font
m = f.selectedFontMaster
ID = m.id

for g in range(len(f)):
	if len(f.glyphs[g].layers[ID].anchors) > 0:
         .... etcetera

Which stops with

Traceback (most recent call last):
File “List Anchors.py”, line 16, in
if len(f.glyphs[g].layers[ID].anchors) > 0:
AttributeError: ‘NoneType’ object has no attribute ‘layers’

As usual the traceback message is assuming e depth of knowledge I do not possess. If there is a bug in my script, I don’t think it would not have worked OK for several years. So I think some intentional or unintentional change in the app. I do not see anything about Python in the changelog, so it is probably unintentional?


#2

Thanks for reporting this. I found the problem.

For now, use a bit simpler iteration:

for g in f.glyphs:
 	if len(g.layers[ID].anchors) > 0:

this is even a tiny bit faster.


#3

The update 1225 mentions Python fixes. But it didn’t fix this one. I keep on using 1219 hoping hoping for a fix, as I don’t think any speed increase will be such as to justify time spend on updating a collection scripts.


#4

I fixed it.


#5

Yes, it is fixed in 1227.