The petitioner is registrar of voters of the city and county of San Francisco. His duties as such are in all material respects the same as those imposed by law upon county clerks in the other counties of the state. (Act of March 18, 1878; Stats. 1878, p. 299, sec. 4; Pol. Code, new sec. 1216, added by act of March 20, 1891; Stats. 1891, p. 165, sec. 32.) It appears from his petition and the return to the writ issued herein that the Hon. C. W. Slack, one of the judges of the superior court of San Francisco, acting in the capacity of a committing magistrate, caused the arrest of one Naphtaly upon a charge of felony, alleged to have been committed *85by him as inspector of one of the election precincts of said city and county at the recent general election. While conducting the examination of said charge in his capacity of committing magistrate, said judge made and caused to be duly served upon the petitioner an order requiring him to produce and open the sealed package of ballots returned from the precinct at which said ETaphtaly acted as such inspector. The petitioner refused to produce the package of ballots for the purpose of opening them, and for such refusal was adjudged guilty of contempt, and committed to the county jail, whereupon he sued out this writ for the purpose of testing the legality of his imprisonment. It is the settled law . of this state that no court or judge has power to punish as a contempt the violation or disregard of an unlawful order. To attempt to do so by means of imprisonment is an excess of jurisdiction, remediable by the writ of habeas corpus. The question for decision, therefore, and the only question discussed by counsel, is the legality of the order made by the committing magistrate requiring petitioner to produce in court and open the sealed package of ballots. I say committing magistrate, because a judge of the superior court acting in that capacity has no authority over the registrar of voters or the county clerk which is not fully shared by every police judge and justice of the peace in the state. If he can order a sealed package of ballots to be opened for the purpose of obtaining evidence supposed to be material in the preliminary investigation of a criminal charge, so may any one of them. There is indeed no middle course between holding that the ballots must be kept as the law, in terms, directs them to be kept, i. e., sealed^ and in the exclusive possession of the registrar or county-clerk, or that any judicial officer of any grade may, in any judicial proceeding, civil or criminal, take them out of the possession and control of the officer charged with their custody, open them, and keep them during such time and subject to such precautions as he may deem necessary for the purposes of his investigation and the *86preservation of their integrity. The statutory provisions in regard to the preservation and custody of the ballots are contained in sections 1259 to 1266 of the Political Code. It is thereby made the duty of the precinct election officers to securely seal up the ballots as soon as they have been counted, and to deliver them to the county clerk (or registrar, in San Francisco) by the hands of one of their own members, or by the nearest postmaster or a sworn express agent. The duty of the clerk or registrar is prescribed by sections 1265 and 1266 of the Political Code, which read as follows:—
“ Sec. 1265. Upon the receipt of the package the clerk must file the one containing ballots, and must keep it unopened and unaltered for twelve months, after which time, if there is not a contest commenced in some tribunal having jurisdiction about such election, he must burn the package, without opening or examining its contents.
“ Sec. 1266. If within twelve months there is such a contest commenced, he must keep the package unopened and unaltered until it is finally determined, when he must, as provided in the preceding section, destroy it, unless such package is, by virtue of an order of the tribunal in which the contest is pending, brought and opened before it, to the end that evidence may be had of its contents, in which event the package and contents are in custody of such tribunal.”
It is manifest that the duty thus imposed upon the clerk or registrar is not performed according to the terms of the statute if he parts with the custody of the ballots, or opens the packages, or permits them to be opened, or fails to destroy them at the expiration of a year without examination, except in the single case of a contest before a competent tribunal, when, and when only, he may, upon a proper order of such tribunal, deliver the ballots into its custody to be opened and used as evidence.
It is not pretended that the proceeding pending before Judge Slack is a “ contest,” within the meaning of the statute; on the contrary, it is admitted that a contest *87means a proceeding by a candidate apparently defeated according to the face of the returns, in which he seeks to impeach the returns by evidence of a higher character, as, for example, by a recount of the ballots.
Nevertheless, it is contended that the magistrate had the power in this proceeding to compel the registrar, under penalty of fine and imprisonment, to do that which the law has forbidden him to do under the same penalties. If this is so, it must be because the law is unconstitutional, or that it does not mean what its terms import, or that the power of the courts is in this matter superior to that of the legislature.
As to the first proposition, I need only say that the constitutionality of the law has not been assailed. As to the last, it is not denied that with respect to rules of evidence generally, the courts are strictly bound by the laws enacted by tbe legislature. The only question, therefore, is as to the proper construction of the statute, considered in relation to other statutes and rules of law in pari materia. As to this point, the contention of counsel is, in substance, that the literal terms of the statute must give way to the general legal principle that all courts have the power to compel the production of the best evidence within the reach of their process, and material to the issue to be tried, and that the parties to the litigation have a right to the production of such evidence for the enforcement or the defense of their rights.
The correctness and the importance of this principle are conceded, but at the same time it cannot be denied that it is within the power of the legislature to set it aside, in pursuance of a policy which it deems of paramount importance.
A familiar instance of such a law and such a policy is the privilege accorded to communications made to a priest, a physician, or an attorney, by penitent, patient, or client. Such communications would, in many instances, conclusively establish the truth of criminal charges, or the invalidity of property claims, and yet the law prohibits their disclosure, because by protecting *88such confidential communications a greater mischief is prevented than results from the loss of a particular kind of evidence. And so with regard to these ballots, if the legislature, in pursuance of a paramount object, has determined that they shall not be inspected after they have left the hands of the precinct officers, except for one specific purpose, the courts can no more lay hands upon them, as a means of proof, than they can compel a lawyer, doctor, or priest to disclose communications made to him in his professional character, and under the seal of professional confidence.
What, then, is and has been the policy of the legislaure with respect to election ballots ?
Ever since the system of voting by ballot came into' use, it has, of course, been possible for election officers to commit frauds in counting, the best evidence of which would be furnished by an inspection of the ballots themselves. But in spite of this fact, the election laws of many of the states provided that the ballots should be destroyed as soon as counted. Such was the law of this state from 1850 to 1863. (Stats. 1850, p. 104, sec. 35; Stats. 1863, p. 354, sec. 6.) How, whatever may have been the object of this provision, whether the preservation of the secrecy of the ballot, or something else, it was .plainly inconsistent with any use of the ballots for the purpose of proving fraud, and when it was amended by the act of 1863 so as to require the ballots to be returned under seal to the county clerk, to be kept by him for at least six months, it was provided by the same amendment that any person denying the correctness of the returns could demand a recount of the ballots,—a clear indication that the object of the amendment was to furnish a new ground of contest to candidates apparently defeated. There is nothing, however, in the terms of this first amendment inconsistent with the use of the ballots as evidence for other purposes than a contest; and if the law had remained as then enacted, I should have entertained no doubt that they could be used as evidence to sustain a criminal accusation. But the law was *89not allowed to remain as then enacted. On the contrary, it was substantially changed by the adoption of the Political Code, and the note of the code commissioners to section 1266 shows the motive of the change, viz., to preserve the evidence (of the actual vote), and protect it by all the safeguards that can be conveniently thrown around it, until it can be examined in a tribunal authorized to try contested election cases. This, then, was the object of the law, evident not only from the language and all the provisions of the statute, but expressly set forth by the commissioners who framed it. It was to preserve the best evidence of the actual vote for the trial of contested elections, and to protect it by all the safeguards that could be conveniently thrown around it. This being done, the same amendment provided, ex industria, that the ballots, being no longer needed for a contest, should be destroyed without examination. It is therefore not only inconsistent with the terms of the law, but destructive of its policy, to hold that the ballots, for the security and integrity of which such careful provision is made, are subject to be removed from the custody of the registrar, opened, handled, and exposed to the danger of all sorts of changes and mutilations as often as any judicial officer may conclude that they contain evidence material to an issue depending before him. For when once the terms of the statute are set aside, not only judges of the highest character and position can order the sealed ballots to be produced and opened, but every judicial officer in the state may do the like, and it will depend wholly upon his individual judgment and discretion what precautions shall be taken to prevent them from being tampered with.
The object of the law being to afford the means of impeaching the returns of the election officers, not only all candidates, but the entire public, is interested in preserving the integrity of the sealed packages of ballots, for they cannot be produced in evidence without satisfactory preliminary proof that they remain in the same *90condition in which they were taken from the ballot-box. (McCrary on Elections, 2d ed., sec. 277, and cases cited; Coglan v. Beard, 67 Cal. 303.) When they have been kept by the clerk or registrar, such proof is an extremely simple matter. When they have been beyond his control, it becomes extremely difficult, and in many cases impossible.
We are asked by counsel how the declared intention of the legislature to punish frauds by election officers can be reconciled with an intention to prevent the use of the best means of proving such frauds. It might as well "be asked how the plain injunction of the statute that the ballots must be destroyed at the end of one year can be reconciled with the law which authorizes a prosecution to be commenced at any time within three years. Both these questions may be answered in the same way. The different provisions are in neither case absolutely inconsistent, and if it is true that the preservation of the ballots as the law directs is an obstacle to the enforcement of the newly provided penalties for frauds of election officers, this result flows from the fact that the legislature, in this instance, as in so many others, has failed in revising the old law to co-ordinate its different parts so as to bring them into perfect harmony with its new policy. This failure of provision, however, if indeed there was such failure, cannot be remedied by the ’courts, but must be left to the legislature itself for amendment. If it is thought necessary to make the ballots available as evidence in criminal proceedings, the legislature can do so under such limitations and restrictions as may be deemed essential to their integrity. The courts cannot open them for inspection without destroying all safeguards, except such as each particular judge who may order them into court shall see proper to apply, nor without impairing in all cases, and possibly destroying in many, their value as evidence for the only purpose for which the law has directed their preservation.
The prisoner is discharged.
*91Paterson, J., McFarland, J., Garoutte, J., De Haven, J., and Harrison, J., concurred.
Mr. Justice Sharpstein, not having heard the argument, did not participate in the foregoing decision.