Python fdopen bug

June 8, 2015, 11:09 p.m.

A cute bug in the Python REPL that somebody posted in #python the other day:

import os
os.fdopen(0); 0

Typing this inside the REPL exits it. A file wrapper object is constructed for fd 0 (stdin), but the reference is not saved. The interpreter then frees the object, which probably accidentally closes the actual stdin as well.