If a convict sentenced by a court of the commonwealth or of the United States to imprisonment in the state prison or by a court of the United States to a federal penitentiary for a felony holds an office under the constitution or laws of the commonwealth at the time of sentence, it shall be vacated from the time of sentence. If the judgment against him is reversed upon writ of error, he shall be restored to his office with all its rights and emoluments; but, if pardoned, he shall not by reason thereof be restored, unless it is so expressly ordered by the terms of the pardon.
Mass. Gen. Laws ch. 279, § 30