use six.StringIO instead of StringIO