catch unicode encode error in getattr()

getattr() does not support unicode values.