Make "sys.stderr.buffer" check more general