If, according to the law as provided afterwards, such act is no more an offence, the person doing such act shall be relieved from being an offender; and, if there is a final judgment inflicting the punishment, such person shall be deemed as not having ever been convicted by the judgment for committing such offence.