use StringIO in a way that is compatible with Python 2.7