If a foreigner is sentenced for a felony to a penalty restricting his freedom, he must be deported from the country. If a foreigner is sentenced to a penalty restricting his freedom, the court may rule to deport him from the country or to deport him instead of sentencing him to a penalty restricting his freedom, all of this unless the law provides otherwise.