def canonical_str(value):
    '\n        Returns the canonical string value of the given string.\n        In Python 2 this is the value unchanged if it is an str, otherwise\n        it is the unicode value encoded as UTF-8.\n        '
    try:
        return str(value)
    except UnicodeEncodeError:
        return str(value.encode('utf-8'))
Returns the canonical string value of the given string.
In Python 2 this is the value unchanged if it is an str, otherwise
it is the unicode value encoded as UTF-8.
def canonical_str(value):
    '\n        Returns the canonical string value of the given string.\n        In Python 2 this is the value unchanged if it is an str, otherwise\n        it is the unicode value encoded as UTF-8.\n        '
    try:
        return str(value)
    except UnicodeEncodeError:
        return str(value.encode('utf-8'))