Correcting KeyError to AttributeError in __getattr__