This is only the case if the bonds get issued in the country‘s currency. Argentina doesn’t have that luxury[0].
In the long run, if a government devalues its currency too much, investors lose trust, and the country cannot borrow money in its currency. Not necessarily a problem for current politicians since they will be out of office by the time the trust is lost.