To do the right thing, this needs to be:

except (AttributeError, ValueError):