This is harder to understand than `contextlib`.