def string_io(data=None):
 try:
  return cStringIO(bytes(data))
 except (UnicodeEncodeError, TypeError):
  return StringIO(data)

def string_io ( data = None ) : try : return cStringIO ( bytes ( data ) ) except ( UnicodeEncodeError , TypeError ) : return StringIO ( data )
pass data through to stringio module and return result .