Why not use contextlib.nested? This is ugly.