def toUnicode(obj, encoding='utf-8'):
    if not isinstance(obj, str):
        obj = str(obj, encoding)
    return obj

def toUnicode(obj):
    if not isinstance(obj, str):
        obj = str(obj)
    return obj

Update tounicode method