Returns:

    * a `str` instance (bytes) in Python 2.x, or
    * a `str` instance (Unicode) in Python 3.x.

def safe_str(value):
    """ Returns:

    * a `str` instance (bytes) in Python 2.x, or
    * a `str` instance (Unicode) in Python 3.x.

    """
    if sys.version_info < (3,0) and isinstance(value, unicode):
        return value.encode('utf-8')
    else:
        return str(value)