# Buggy code
def get_expected_titles(show_list):
    """Return expected titles to be used by guessit.

    It iterates over user's show list and only returns a regex for titles that contains numbers
    (since they can confuse guessit).

    :param show_list:
    :type show_list: list of sickbeard.tv.TVShow
    :return:
    :rtype: list of str
    """
    expected_titles = list(fixed_expected_titles)
    for show in show_list:
        names = [show.name] + show.exceptions
        for name in names:
            match = series_re.match(name)
            if not match:
                continue

            series, year, _ = match.groups()
            if year and not valid_year(int(year)):
                series = name

            if not any([char.isdigit() for char in series]):
                continue

            if not any([char.isalpha() for char in series]):
                # if no alpha chars then add series name 'as-is'
                expected_titles.append(series)

            # (?<![^/\\]) means -> it matches nothing but path separators and dot (negative lookbehind)
            fmt = (
                r"re:(?<=[\W_]){name}(?=[\W_]|$)"
                if show.is_anime
                else r"re:(?<![^/\\\.]){name}(?=[\W_]|$)"
            )
            expected_titles.append(fmt.format(name=prepare(series)))

    return normalize(expected_titles)


# Traceback (UnicodeEncodeError)
PASTE LOGS HERE

2016-09-20 20:58:51 ERROR    SEARCHQUEUE-MANUAL-296065 :: [Torrentz2] :: [161bce5] Unknown exception while searching Torrentz2. Error: u'charmap : title: \xd0\u0161\xd0\xbe\xd0\xbd\xd0\xb5\xd1\u2020 \xd0\xb4\xd0\xb5\xd1\u201a\xd1\ufffd\xd1\u201a\xd0\xb2\xd0\xb0, season: 1, format: WEB-DL, screen_size: 1080p, release_group: NewStudio, type: episode, absolute_episode: [], quality: Unknown, episode: [] : error 7 : error 12 : character maps to '
Traceback (most recent call last):
File "C:\SickRageMedusa\**********\search\core.py", line 553, in searchProviders
downCurQuality, manual_search, manual_search_type)
File "C:\SickRageMedusa\**********\providers\GenericProvider.py", line 212, in find_search_results
parse_result = NameParser(parse_method=('normal', 'anime')[show.is_anime]).parse(title)
File "C:\SickRageMedusa\**********\name_parser\parser.py", line 234, in parse
self.assert_supported(result)
File "C:\SickRageMedusa\**********\name_parser\parser.py", line 251, in assert_supported
'Parser result: {result}'.format(result=result))
File "C:\SickRageMedusa\**********\name_parser\parser.py", line 360, in __str__
return helpers.canonical_name(obj, fmt='{key}: {value}', separator=', ')
File "C:\SickRageMedusa\**********\helpers.py", line 1634, in canonical_name
return str(separator.join([fmt.format(key=k, value=v) for k, v in guess.items() if k not in ignore_list]))
File "C:\Python27\lib\encodings\cp1252.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 7-11: character maps to

# Fixed code
def get_expected_titles(show_list):
    """Return expected titles to be used by guessit.

    It iterates over user's show list and only returns a regex for titles that contains numbers
    (since they can confuse guessit).

    :param show_list:
    :type show_list: list of sickbeard.tv.TVShow
    :return:
    :rtype: list of str
    """
    expected_titles = list(fixed_expected_titles)
    for show in show_list:
        names = [show.name] + show.exceptions
        for name in names:
            if name.isdigit():
                # do not add numbers to expected titles.
                continue

            match = series_re.match(name)
            if not match:
                continue

            series, year, _ = match.groups()
            if year and not valid_year(int(year)):
                series = name

            if not any([char.isdigit() for char in series]):
                continue

            if not any([char.isalpha() for char in series]):
                # if no alpha chars then add series name 'as-is'
                expected_titles.append(series)

            # (?<![^/\\]) means -> it matches nothing but path separators and dot (negative lookbehind)
            fmt = (
                r"re:(?<=[\W_]){name}(?=[\W_]|$)"
                if show.is_anime
                else r"re:(?<![^/\\\.]){name}(?=[\W_]|$)"
            )
            expected_titles.append(fmt.format(name=prepare(series)))

    return normalize(expected_titles)