Python: proper base class for TextIO