get_attribute should never raise KeyError

backporting to 2.4.x support branches