# Buggy code
def patch(self, series_slug, path_param=None):
    """Patch series."""
    if not series_slug:
        return self._method_not_allowed("Patching multiple series is not allowed")

    identifier = SeriesIdentifier.from_slug(series_slug)
    if not identifier:
        return self._bad_request("Invalid series identifier")

    series = Series.find_by_identifier(identifier)
    if not series:
        return self._not_found("Series not found")

    data = json_decode(self.request.body)
    indexer_id = data.get("id", {}).get(identifier.indexer.slug)
    if indexer_id is not None and indexer_id != identifier.id:
        return self._bad_request("Conflicting series identifier")

    accepted = {}
    ignored = {}
    patches = {
        "config.aliases": ListField(series, "aliases"),
        "config.dvdOrder": BooleanField(series, "dvd_order"),
        "config.flattenFolders": BooleanField(series, "flatten_folders"),
        "config.anime": BooleanField(series, "anime"),
        "config.scene": BooleanField(series, "scene"),
        "config.sports": BooleanField(series, "sports"),
        "config.paused": BooleanField(series, "paused"),
        "config.location": StringField(series, "_location"),
        "config.airByDate": BooleanField(series, "air_by_date"),
        "config.subtitlesEnabled": BooleanField(series, "subtitles"),
        "config.release.requiredWords": ListField(series, "release_required_words"),
        "config.release.ignoredWords": ListField(series, "release_ignore_words"),
        "config.release.blacklist": ListField(series, "blacklist"),
        "config.release.whitelist": ListField(series, "whitelist"),
        "language": StringField(series, "lang"),
        "config.qualities.allowed": ListField(series, "qualities_allowed"),
        "config.qualities.preferred": ListField(series, "qualities_preferred"),
        "config.qualities.combined": IntegerField(series, "quality"),
    }
    for key, value in iter_nested_items(data):
        patch_field = patches.get(key)
        if patch_field and patch_field.patch(series, value):
            set_nested_value(accepted, key, value)
        else:
            set_nested_value(ignored, key, value)

    # Save patched attributes in db.
    series.save_to_db()

    if ignored:
        log.warning("Series patch ignored %r", ignored)

    self._ok(data=accepted)


# Traceback (AttributeError)
2018-04-22 19:13:13 DEBUG    FINDPROPERS :: [6d54662] Starting new thread: FINDPROPERS
2018-04-22 19:13:13 INFO     FINDPROPERS :: [6d54662] Beginning the search for new propers
2018-04-22 19:13:13 INFO     FINDPROPERS :: [6d54662] Using proper search days: 2
2018-04-22 19:13:13 INFO     FINDPROPERS :: [Rarbg] :: [6d54662] Searching for any new PROPER releases from Rarbg
2018-04-22 19:13:13 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] 295647: Setter sets location to E:\TV\Blindspot\Season 3\Blindspot.S03E18.PROPER.720p.HDTV.x264-KILLERS.mkv
2018-04-22 19:13:13 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] Checking if E:\TV\Blindspot\Season 3\Blindspot.S03E18.PROPER.720p.HDTV.x264-KILLERS.nfo exists: True
2018-04-22 19:13:13 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] Checking if E:\TV\Blindspot\Season 3\Blindspot.S03E18.PROPER.720p.HDTV.x264-KILLERS-thumb.jpg exists: True
2018-04-22 19:13:14 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] GET URL: http://torrentapi.org/pubapi_v2.php?get_token=get_token&amp;app_id=medusa&amp;format=json [Status: 200]
2018-04-22 19:13:14 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] User-Agent: Medusa/0.2.2 (Windows; 7; 83ab66f0-4626-11e8-99e3-001fd0d1e3a5)
2018-04-22 19:13:14 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] Search mode: Episode
2018-04-22 19:13:14 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] Search string: Blindspot S03E18 {{PROPER|REPACK|REAL|RERIP}}
2018-04-22 19:13:14 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] Searching only ranked torrents
2018-04-22 19:13:19 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] GET URL: http://torrentapi.org/pubapi_v2.php?sort=seeders&amp;min_leechers=0&amp;min_seeders=1&amp;search_tvdb=295647&amp;app_id=medusa&amp;search_string=Blindspot+S03E18+%7B%7BPROPER%7CREPACK%7CREAL%7CRERIP%7D%7D&amp;ranked=1&amp;category=tv&amp;format=json_extended&amp;token=l7huma64or&amp;limit=100&amp;mode=search [Status: 200]
2018-04-22 19:13:19 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] User-Agent: Medusa/0.2.2 (Windows; 7; 83ab66f0-4626-11e8-99e3-001fd0d1e3a5)
2018-04-22 19:13:19 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] Found result: Blindspot.S03E18.PROPER.HDTV.x264-KILLERS[rartv] with 1049 seeders and 271 leechers
2018-04-22 19:13:19 DEBUG    FINDPROPERS :: [Rarbg] :: [6d54662] Found result: Blindspot.S03E18.PROPER.720p.HDTV.x264-KILLERS[rartv] with 695 seeders and 99 leechers
2018-04-22 19:13:19 ERROR    FINDPROPERS :: [Rarbg] :: [6d54662] Exception generated: 'unicode' object has no attribute 'series_name'
Traceback (most recent call last):
File "C:\Medusa\medusa\scheduler.py", line 93, in run
self.action.run(self.force)
File "C:\Medusa\medusa\search\proper.py", line 67, in run
propers = self._get_proper_results()
File "C:\Medusa\medusa\search\proper.py", line 126, in _get_proper_results
cur_propers = cur_provider.find_propers(recently_aired)
File "C:\Medusa\medusa\providers\generic_provider.py", line 203, in find_propers
search_strings = self._get_episode_search_strings(episode_obj, add_string=term)
File "C:\Medusa\medusa\providers\generic_provider.py", line 621, in _get_episode_search_strings
all_possible_show_names = episode.series.get_all_possible_names()
File "C:\Medusa\medusa\tv\series.py", line 2139, in get_all_possible_names
show_names = {exception.series_name for exception in get_scene_exceptions(self, season)}
File "C:\Medusa\medusa\tv\series.py", line 2139, in <setcomp>
show_names = {exception.series_name for exception in get_scene_exceptions(self, season)}
AttributeError: 'unicode' object has no attribute 'series_name'

# Fixed code
def patch(self, series_slug, path_param=None):
    """Patch series."""
    if not series_slug:
        return self._method_not_allowed("Patching multiple series is not allowed")

    identifier = SeriesIdentifier.from_slug(series_slug)
    if not identifier:
        return self._bad_request("Invalid series identifier")

    series = Series.find_by_identifier(identifier)
    if not series:
        return self._not_found("Series not found")

    data = json_decode(self.request.body)
    indexer_id = data.get("id", {}).get(identifier.indexer.slug)
    if indexer_id is not None and indexer_id != identifier.id:
        return self._bad_request("Conflicting series identifier")

    accepted = {}
    ignored = {}
    patches = {
        "config.aliases": ListField(series, "aliases"),
        "config.defaultEpisodeStatus": StringField(series, "default_ep_status_name"),
        "config.dvdOrder": BooleanField(series, "dvd_order"),
        "config.flattenFolders": BooleanField(series, "flatten_folders"),
        "config.anime": BooleanField(series, "anime"),
        "config.scene": BooleanField(series, "scene"),
        "config.sports": BooleanField(series, "sports"),
        "config.paused": BooleanField(series, "paused"),
        "config.location": StringField(series, "_location"),
        "config.airByDate": BooleanField(series, "air_by_date"),
        "config.subtitlesEnabled": BooleanField(series, "subtitles"),
        "config.release.requiredWords": ListField(series, "release_required_words"),
        "config.release.ignoredWords": ListField(series, "release_ignore_words"),
        "config.release.blacklist": ListField(series, "blacklist"),
        "config.release.whitelist": ListField(series, "whitelist"),
        "language": StringField(series, "lang"),
        "config.qualities.allowed": ListField(series, "qualities_allowed"),
        "config.qualities.preferred": ListField(series, "qualities_preferred"),
        "config.qualities.combined": IntegerField(series, "quality"),
    }
    for key, value in iter_nested_items(data):
        patch_field = patches.get(key)
        if patch_field and patch_field.patch(series, value):
            set_nested_value(accepted, key, value)
        else:
            set_nested_value(ignored, key, value)

    # Save patched attributes in db.
    series.save_to_db()

    if ignored:
        log.warning("Series patch ignored %r", ignored)

    self._ok(data=accepted)