CHARLESTON, S.C. — A hearing on suppressing evidence in the Charleston church shooting trial will be closed because an open hearing could compromise Dylann Roof’s right to a fair trial, a federal judge ruled Wednesday.

“The court finds a compelling governmental interest in closing this proceeding that outweighs the strong public interest in open pretrial proceedings,” U.S. District Judge Richard Gergel wrote in an order issued after hearing the objections from media attorneys.

Roof, 22, goes on trial in November for hate crimes and other federal charges arising from the June 2015 shooting deaths of nine black parishioners at Emanuel AME Church. His attorneys want to keep some evidence out of the death-penalty trial and Gergel had set a Thursday hearing on the matter.

He told attorneys earlier Wednesday that he doesn’t want potential jurors to hear about evidence that might be excluded from the trial.

“There are some circumstances where you can’t un-ring the bell,” the judge said. He said the hearing would not be secret and that a transcript would eventually be released.

Attorney Jay Bender, representing The Post and Courier, argued that any lack of impartiality among potential jurors could be avoided by asking questions during jury screening, which is expected to take three weeks.

Gergel said there will be extensive screening and the first of about 3,000 potential jurors will be called to the courthouse beginning next month to fill out questionnaires about what that they know about the case.

Attorney Carl Muller, representing WCBD-TV, said knowledge of the case is already widespread. Muller noted that a Google search for Dylann Roof returned more than 10 million hits in .35 seconds.

But the judge said “the evidence the defense seeks to suppress has not been publicly disclosed.”

“I start with the presumption that this is an open proceeding,” the judge said, but as he weighs constitutional guarantees of a free press against Roof’s right to a fair trial, he may have to close it, in what he called “a rare exceptional circumstance.”

Thursday’s hearing will be limited to only the attorneys and court officials. Gergel said that neither the families of the victims nor state prosecutors would be admitted.

Roof also faces the death penalty in a state murder trial set to begin in January.