In the trial of any contested election under this subchapter, the Court may make an examination of the ballots given in such election, except that wherever the ballot boxes, ballots, poll lists, tally sheets or other books or records pertaining to any election, excepting the certificate of election of the officer against whom the contest may be made, duly signed by the Court constituting the board of canvass and under the seal of court, and delivered according to law, shall have come in any way, legally or illegally, into the possession, care or custody of any person, officially or otherwise, who shall have been a candidate and voted for upon the same official ballot as a candidate of the same political party as the contestant, no such ballot boxes, poll lists, tally sheets or other books or records pertaining to the said election, excepting the certificate of election, shall be offered in evidence in any contest begun or prosecuted under the provisions hereof, and the Court may make and enforce by attachment all necessary orders to obtain possession of the same.