change KeyError to AttributeError for pickle ok