fix log.restore bug triggered in PyPlot __exit__