In trials of contested nominations and elections, and in all proceedings for the investigation of primaries and elections, no person shall be permitted to withhold his testimony upon the ground that he may incriminate himself, or subject himself to public infamy, but such testimony shall not afterwards be used against him in any judicial proceedings, except for perjury in giving such testimony.
25 P.S. § 3467