fix a wrongly raise error in write_attr