import sys


def stringio(content=None, is_unicode=True):
    if sys.version_info.major >= 3:
        # Python 3 code in this block
        if is_unicode:
            from io import StringIO
            if content is None:
                content = ''
            return StringIO(content)
        else:
            from io import BytesIO
            if content is None:
                content = b''
            return BytesIO(content)
    else:
        # Python 2 code in this block
        from StringIO import StringIO
        if content is None:
            content = ''
        return StringIO(content)
