BISMARCK, N.D. — The new year will bring North Dakota a new law forbidding political candidates from making personal use of campaign funds.

The legislation closes a loophole that could have allowed politicians to pocket campaign cash, a prospect that worried many newly elected lawmakers and was even mocked by HBO comedian John Oliver, who in 2015 took aim at North Dakota’s oil industry, its allegedly lax regulations and its political system.

Under the new law, candidates will be required to report all expenditures and maintain dedicated campaign accounts.

A violation of the law is a misdemeanor, punishable by up to a year in prison and a $3,000 fine.

Republicans and Democrats in the Legislature have long maintained they don’t know of anyone pocketing campaign funds. Tax Commissioner Ryan Rauschenberger said he could not discuss individual tax returns but knew of no legislative candidate who claimed campaign funds as income.

“There is no indication of any campaign money being used for personal use,” Rauschenberger said. “This legislation makes it much more clear campaign money can’t be used for personal purposes.”

Democrats had pushed bipartisan legislation to close the loophole in three previous sessions, but the legislation got nowhere in the Republican-led legislature.

This year a Republican-sponsored proposal was introduced in the Senate, and Democratic-sponsored legislation was introduced in the House.

The bill introduced by Fargo GOP Sen. Jonathan Casper ultimately prevailed and passed by a wide margin in both chambers.

Casper, a lawyer, called the legislation sweeping campaign finance reform, and said it was inspired mostly by young legislators from both parties who believed lack of oversight previously was a perception problem for lawmakers.

“Campaign funds for any personal use is unacceptable,” Casper said.

Democratic House Minority Leader Corey Mock of Grand Forks agreed that young lawmakers from both parties pushed hard for the legislation. But he said Oliver, the HBO comedian, probably had something to do with it.

A video clip of the bow tie-wearing Mock describing how it was possible for lawmakers to pocket campaign cash was highlighted on Oliver’s show in 2015.

“I know his flannel bow tie is extremely distracting,” Oliver said. “But what he’s saying is horrifying.”

“It really exposed how bad we looked and that we were not being transparent with our campaign money,” said Mock. “I think it rattled some cages.”