# python stdlib
import sys


if sys.version_info[0] < 3:
    basestring = basestring  # NOQA: F821
    unicode = unicode    # NOQA: F821

    def nativestr(x):
        return x if isinstance(x, str) else x.encode('utf-8', 'replace')
else:
    basestring = str  # NOQA: F821
    unicode = str  # NOQA: F821

    def nativestr(x):
        return x if isinstance(x, str) else x.decode('utf-8', 'replace')

# -*- coding: utf-8 -*-

# python stdlib
import sys


if sys.version_info[0] < 3:
    # Python 2.x.x series
    basestring = basestring  # NOQA: F821
    unicode = unicode    # NOQA: F821

    def u(x):
        return x.decode()

    def b(x):
        return x

    def nativestr(x):
        return x if isinstance(x, str) else x.encode('utf-8', 'replace')
else:
    # Python 3.x.x series
    basestring = str  # NOQA: F821
    unicode = str  # NOQA: F821

    def u(x):
        return x

    def b(x):
        return x.encode('latin-1') if not isinstance(x, bytes) else x

    def nativestr(x):
        return x if isinstance(x, str) else x.decode('utf-8', 'replace')

Add more methods to compat.py