KeyError bug; nonexistent attributes giving error instead of `None` object