Adam Olsen wrote: > That'd rely on prompt deletion for correct behaviour. Why not an > explicit detach method? > > buf = sys.stdout.buffer > sys.stdout.detach() > sys.stdout = io.TextIOWrapper(buf, "utf-8") Or keep an explicit count of the number of unclosed wrappers that are referencing a buffer. -- Greg