# Buggy code
def parse(self, name, cache_result=True):
    """Parse the name into a ParseResult.

    :param name:
    :type name: str
    :param cache_result:
    :type cache_result: bool
    :return:
    :rtype: ParseResult
    """
    name = helpers.unicodify(name)

    if self.naming_pattern:
        cache_result = False

    cached = name_parser_cache.get(name)
    if cached:
        return cached

    result = self._parse_string(name)
    self.assert_supported(result)

    if cache_result:
        name_parser_cache.add(name, result)

    logger.debug(
        "Parsed {name} into {result}",
        name=name,
        result=str(result).decode("utf-8", "xmlcharrefreplace"),
    )
    return result


# Traceback (TypeError)
Thread-15 :: [9eeb3b5] Failed doing web ui callback: Traceback (most recent call last):
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\server\web\core\base.py", line 270, in async_call
result = function(**kwargs)
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\server\web\home\post_process.py", line 50, in processEpisode
is_priority=argToBool(is_priority), delete_on=argToBool(delete_on), failed=argToBool(failed), proc_type=type, ignore_subs=argToBool(ignore_subs)
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\processTV.py", line 263, in processDir
for curDir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed, result)]:
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\processTV.py", line 411, in validateDir
NameParser().parse(video, cache_result=False)
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\name_parser\parser.py", line 241, in parse
logger.debug('Parsed {name} into {result}', name=name, result=str(result).decode('utf-8', 'xmlcharrefreplace'))
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
TypeError: don't know how to handle UnicodeDecodeError in error callback
Traceback (most recent call last):
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\server\web\core\base.py", line 270, in async_call
result = function(**kwargs)
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\server\web\home\post_process.py", line 50, in processEpisode
is_priority=argToBool(is_priority), delete_on=argToBool(delete_on), failed=argToBool(failed), proc_type=type, ignore_subs=argToBool(ignore_subs)
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\processTV.py", line 263, in processDir
for curDir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed, result)]:
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\processTV.py", line 411, in validateDir
NameParser().parse(video, cache_result=False)
File "C:\Users\Kevin van Deursen\Desktop\SickRage-develop\sickbeard\name_parser\parser.py", line 241, in parse
logger.debug('Parsed {name} into {result}', name=name, result=str(result).decode('utf-8', 'xmlcharrefreplace'))
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
TypeError: don't know how to handle UnicodeDecodeError in error callback

# Fixed code
def parse(self, name, cache_result=True):
    """Parse the name into a ParseResult.

    :param name:
    :type name: str
    :param cache_result:
    :type cache_result: bool
    :return:
    :rtype: ParseResult
    """
    name = helpers.unicodify(name)

    if self.naming_pattern:
        cache_result = False

    cached = name_parser_cache.get(name)
    if cached:
        return cached

    result = self._parse_string(name)
    self.assert_supported(result)

    if cache_result:
        name_parser_cache.add(name, result)

    logger.debug("Parsed {name} into {result}", name=name, result=str(result))
    return result