gurudesh/pytracebugs huggingface dataset:
# Buggy code
def from_ietf_code(code, unknown="und"):
    """Converts an IETF code to a 3-letter opensubtitles code

    :param code: an IETF language code
    :type code: str
    :param unknown: the code to be returned for unknown language codes
    :type unknown: str
    :return: babelfish.Language
    """
    try:
        return Language.fromietf(code)
    except ValueError:
        return Language(unknown) if unknown else None


# Traceback (TypeError)
2016-04-05 12:05:53 FINDSUBTITLES :: [a90e41d] Traceback (most recent call last):
File "/home/dariox/.sickrage/sickbeard/subtitles.py", line 325, in download_best_subs
get_subtitle_description(subtitle)), logger.DEBUG)
File "/home/dariox/.sickrage/sickbeard/subtitles.py", line 489, in get_subtitle_description
return subtitle.id + '-' + desc if desc not in subtitle.id else desc
TypeError: argument of type 'int' is not iterable

# Fixed code
def from_ietf_code(code, unknown="und"):
    """Converts an IETF code to a proper babelfish.Language object

    :param code: an IETF language code
    :type code: str
    :param unknown: the code to be returned for unknown language codes
    :type unknown: str
    :return: a language object
    :rtype: babelfish.Language
    """
    try:
        return Language.fromietf(code)
    except ValueError:
        return Language(unknown) if unknown else None
# Buggy code
def get_subtitle_description(subtitle):
    """Returns a human readable name/description for the given subtitle (if possible)

    :param subtitle: the given subtitle
    :type subtitle: subliminal.Subtitle
    :return: name/description
    :rtype: str
    """
    desc = None
    if hasattr(subtitle, "filename") and subtitle.filename:
        desc = subtitle.filename.lower()
    elif hasattr(subtitle, "name") and subtitle.name:
        desc = subtitle.name.lower()
    if hasattr(subtitle, "release") and subtitle.release:
        desc = subtitle.release.lower()
    if hasattr(subtitle, "releases") and subtitle.releases:
        desc = str(subtitle.releases).lower()

    if not desc:
        desc = subtitle.id

    return subtitle.id + "-" + desc if desc not in subtitle.id else desc


# Traceback (TypeError)
2016-04-05 12:05:53 FINDSUBTITLES :: [a90e41d] Traceback (most recent call last):
File "/home/dariox/.sickrage/sickbeard/subtitles.py", line 325, in download_best_subs
get_subtitle_description(subtitle)), logger.DEBUG)
File "/home/dariox/.sickrage/sickbeard/subtitles.py", line 489, in get_subtitle_description
return subtitle.id + '-' + desc if desc not in subtitle.id else desc
TypeError: argument of type 'int' is not iterable

# Fixed code
def get_subtitle_description(subtitle):
    """Returns a human readable name/description for the given subtitle (if possible)

    :param subtitle: the given subtitle
    :type subtitle: subliminal.Subtitle
    :return: name/description
    :rtype: str
    """
    desc = None
    sub_id = str(subtitle.id)
    if hasattr(subtitle, "filename") and subtitle.filename:
        desc = subtitle.filename.lower()
    elif hasattr(subtitle, "name") and subtitle.name:
        desc = subtitle.name.lower()
    if hasattr(subtitle, "release") and subtitle.release:
        desc = subtitle.release.lower()
    if hasattr(subtitle, "releases") and subtitle.releases:
        desc = str(subtitle.releases).lower()

    if not desc:
        desc = sub_id

    return sub_id + "-" + desc if desc not in sub_id else desc
# Buggy code
def is_ctu_capable(context):
    """Detects if the current clang is CTU compatible."""
    check_supported_analyzers([ClangSA.ANALYZER_NAME], context)
    clangsa_cfg = ClangSA.construct_config_handler([], context)

    return clangsa_cfg.ctu_capability.is_ctu_capable


# Traceback (TypeError)
$ CodeChecker check -b "make" -o ./reports
No handlers could be found for logger "system"
Traceback (most recent call last):
File "/root/codechecker/build/CodeChecker/cc_bin/CodeChecker.py", line 111, in main
subcommands[subcommand])
File "/root/codechecker/build/CodeChecker/cc_bin/CodeChecker.py", line 47, in add_subcommand
command_module.add_arguments_to_parser(sc_parser)
File "/root/codechecker/build/CodeChecker/cc_bin/../lib/python2.7/codechecker_analyzer/cmd/check.py", line 321, in add_arguments_to_parser
clang_has_z3 = analyzer_types.is_z3_capable(context)
File "/root/codechecker/build/CodeChecker/lib/python2.7/codechecker_analyzer/analyzers/analyzer_types.py", line 70, in is_z3_capable
analyzer_env)
File "/root/codechecker/build/CodeChecker/lib/python2.7/codechecker_analyzer/host_check.py", line 83, in has_analyzer_option
LOG.debug('run: "%s"', ' '.join(cmd))
TypeError: sequence item 0: expected string, NoneType found

# Fixed code
def is_ctu_capable(context):
    """Detects if the current clang is CTU compatible."""
    enabled_analyzers, _ = check_supported_analyzers([ClangSA.ANALYZER_NAME], context)
    if not enabled_analyzers:
        return False

    clangsa_cfg = ClangSA.construct_config_handler([], context)

    return clangsa_cfg.ctu_capability.is_ctu_capable
# Buggy code
def is_statistics_capable(context):
    """Detects if the current clang is Statistics compatible."""
    # Resolve potentially missing binaries.
    check_supported_analyzers([ClangSA.ANALYZER_NAME], context)
    clangsa_cfg = ClangSA.construct_config_handler([], context)

    check_env = env.extend(context.path_env_extra, context.ld_lib_path_extra)

    checkers = ClangSA.get_analyzer_checkers(clangsa_cfg, check_env)

    stat_checkers_pattern = re.compile(r".+statisticscollector.+")

    for checker_name, _ in checkers:
        if stat_checkers_pattern.match(checker_name):
            return True

    return False


# Traceback (TypeError)
$ CodeChecker check -b "make" -o ./reports
No handlers could be found for logger "system"
Traceback (most recent call last):
File "/root/codechecker/build/CodeChecker/cc_bin/CodeChecker.py", line 111, in main
subcommands[subcommand])
File "/root/codechecker/build/CodeChecker/cc_bin/CodeChecker.py", line 47, in add_subcommand
command_module.add_arguments_to_parser(sc_parser)
File "/root/codechecker/build/CodeChecker/cc_bin/../lib/python2.7/codechecker_analyzer/cmd/check.py", line 321, in add_arguments_to_parser
clang_has_z3 = analyzer_types.is_z3_capable(context)
File "/root/codechecker/build/CodeChecker/lib/python2.7/codechecker_analyzer/analyzers/analyzer_types.py", line 70, in is_z3_capable
analyzer_env)
File "/root/codechecker/build/CodeChecker/lib/python2.7/codechecker_analyzer/host_check.py", line 83, in has_analyzer_option
LOG.debug('run: "%s"', ' '.join(cmd))
TypeError: sequence item 0: expected string, NoneType found

# Fixed code
def is_statistics_capable(context):
    """Detects if the current clang is Statistics compatible."""
    # Resolve potentially missing binaries.
    enabled_analyzers, _ = check_supported_analyzers([ClangSA.ANALYZER_NAME], context)
    if not enabled_analyzers:
        return False

    clangsa_cfg = ClangSA.construct_config_handler([], context)

    check_env = env.extend(context.path_env_extra, context.ld_lib_path_extra)

    checkers = ClangSA.get_analyzer_checkers(clangsa_cfg, check_env)

    stat_checkers_pattern = re.compile(r".+statisticscollector.+")

    for checker_name, _ in checkers:
        if stat_checkers_pattern.match(checker_name):
            return True

    return False
# Buggy code
def is_z3_capable(context):
    """Detects if the current clang is Z3 compatible."""
    check_supported_analyzers([ClangSA.ANALYZER_NAME], context)
    analyzer_binary = context.analyzer_binaries.get(ClangSA.ANALYZER_NAME)

    analyzer_env = env.extend(context.path_env_extra, context.ld_lib_path_extra)

    return host_check.has_analyzer_option(
        analyzer_binary, ["-Xclang", "-analyzer-constraints=z3"], analyzer_env
    )


# Traceback (TypeError)
$ CodeChecker check -b "make" -o ./reports
No handlers could be found for logger "system"
Traceback (most recent call last):
File "/root/codechecker/build/CodeChecker/cc_bin/CodeChecker.py", line 111, in main
subcommands[subcommand])
File "/root/codechecker/build/CodeChecker/cc_bin/CodeChecker.py", line 47, in add_subcommand
command_module.add_arguments_to_parser(sc_parser)
File "/root/codechecker/build/CodeChecker/cc_bin/../lib/python2.7/codechecker_analyzer/cmd/check.py", line 321, in add_arguments_to_parser
clang_has_z3 = analyzer_types.is_z3_capable(context)
File "/root/codechecker/build/CodeChecker/lib/python2.7/codechecker_analyzer/analyzers/analyzer_types.py", line 70, in is_z3_capable
analyzer_env)
File "/root/codechecker/build/CodeChecker/lib/python2.7/codechecker_analyzer/host_check.py", line 83, in has_analyzer_option
LOG.debug('run: "%s"', ' '.join(cmd))
TypeError: sequence item 0: expected string, NoneType found

# Fixed code
def is_z3_capable(context):
    """Detects if the current clang is Z3 compatible."""
    enabled_analyzers, _ = check_supported_analyzers([ClangSA.ANALYZER_NAME], context)
    if not enabled_analyzers:
        return False

    analyzer_binary = context.analyzer_binaries.get(ClangSA.ANALYZER_NAME)

    analyzer_env = env.extend(context.path_env_extra, context.ld_lib_path_extra)

    return host_check.has_analyzer_option(
        analyzer_binary, ["-Xclang", "-analyzer-constraints=z3"], analyzer_env
    )
# Buggy code
def text(self, text):
    self.__dict__["text"] = text
    text = text.replace("<i>", codes["ITAL_START"])
    text = text.replace("</i>", codes["ITAL_END"])
    text = text.replace("<b>", codes["BOLD_START"])
    text = text.replace("</b>", codes["BOLD_END"])
    self._layoutText = text
    self._visibleText = None
    self._layout()


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def text(self, text):
    text = text.replace("<i>", codes["ITAL_START"])
    text = text.replace("</i>", codes["ITAL_END"])
    text = text.replace("<b>", codes["BOLD_START"])
    text = text.replace("</b>", codes["BOLD_END"])
    visible_text = "".join([c for c in text if c not in codes.values()])
    self._styles = [
        0,
    ] * len(visible_text)
    self._text = visible_text

    current_style = 0
    ci = 0
    for c in text:
        if c == codes["ITAL_START"]:
            current_style += ITALIC
        elif c == codes["BOLD_START"]:
            current_style += BOLD
        elif c == codes["BOLD_END"]:
            current_style -= BOLD
        elif c == codes["ITAL_END"]:
            current_style -= ITALIC
        else:
            self._styles[ci] = current_style
            ci += 1

    self._layout()
# Buggy code
def _onText(self, chr):
    """Called by the window when characters are received"""
    if chr == "\t":
        self.win.nextEditable()
        return
    if chr == "\r":  # make it newline not Carriage Return
        chr = "\n"
    txt = self.text
    self.text = txt[: self.caret.index] + chr + txt[self.caret.index :]
    self.caret.index += 1
    if self.onTextCallback:
        self.onTextCallback()


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def _onText(self, chr):
    """Called by the window when characters are received"""
    if chr == "\t":
        self.win.nextEditable()
        return
    if chr == "\r":  # make it newline not Carriage Return
        chr = "\n"
    self.addCharAtCaret(chr)
    if self.onTextCallback:
        self.onTextCallback()
# Buggy code
def _onCursorKeys(self, key):
    """Called by the window when cursor/del/backspace... are received"""
    if key == "MOTION_UP":
        self.caret.row -= 1
    elif key == "MOTION_DOWN":
        self.caret.row += 1
    elif key == "MOTION_RIGHT":
        self.caret.char += 1
    elif key == "MOTION_LEFT":
        self.caret.char -= 1
    elif key == "MOTION_BACKSPACE":
        self.text = self.text[: self.caret.index - 1] + self.text[self.caret.index :]
        self.caret.index -= 1
    elif key == "MOTION_DELETE":
        self.text = self.text[: self.caret.index] + self.text[self.caret.index + 1 :]
    elif key == "MOTION_NEXT_WORD":
        pass
    elif key == "MOTION_PREVIOUS_WORD":
        pass
    elif key == "MOTION_BEGINNING_OF_LINE":
        self.caret.char = 0
    elif key == "MOTION_END_OF_LINE":
        self.caret.char = END_OF_THIS_LINE
    elif key == "MOTION_NEXT_PAGE":
        pass
    elif key == "MOTION_PREVIOUS_PAGE":
        pass
    elif key == "MOTION_BEGINNING_OF_FILE":
        pass
    elif key == "MOTION_END_OF_FILE":
        pass
    else:
        print("Received unhandled cursor motion type: ", key)


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def _onCursorKeys(self, key):
    """Called by the window when cursor/del/backspace... are received"""
    if key == "MOTION_UP":
        self.caret.row -= 1
    elif key == "MOTION_DOWN":
        self.caret.row += 1
    elif key == "MOTION_RIGHT":
        self.caret.char += 1
    elif key == "MOTION_LEFT":
        self.caret.char -= 1
    elif key == "MOTION_BACKSPACE":
        self.deleteCaretLeft()
    elif key == "MOTION_DELETE":
        self.deleteCaretRight()
    elif key == "MOTION_NEXT_WORD":
        pass
    elif key == "MOTION_PREVIOUS_WORD":
        pass
    elif key == "MOTION_BEGINNING_OF_LINE":
        self.caret.char = 0
    elif key == "MOTION_END_OF_LINE":
        self.caret.char = END_OF_THIS_LINE
    elif key == "MOTION_NEXT_PAGE":
        pass
    elif key == "MOTION_PREVIOUS_PAGE":
        pass
    elif key == "MOTION_BEGINNING_OF_FILE":
        pass
    elif key == "MOTION_END_OF_FILE":
        pass
    else:
        print("Received unhandled cursor motion type: ", key)
# Buggy code
def getText(self):
    """Returns the current text in the box"""
    return self.text


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def getText(self):
    """Returns the current text in the box, including formating tokens."""
    return self.text
# Buggy code
def visibleText(self):
    if self._visibleText is None:
        self._visibleText = "".join(
            [c for c in self._layoutText if c not in codes.values()]
        )
    return self._visibleText


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def visibleText(self):
    """Returns the current visible text in the box"""
    return self._text
# Buggy code
def __init__(self, textbox, color, width, colorSpace="rgb"):
    self.textbox = textbox
    self.index = len(textbox.visibleText)  # start off at the end
    self.autoLog = False
    self.width = width
    self.units = textbox.units
    self.colorSpace = colorSpace
    self.color = color


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def __init__(self, textbox, color, width, colorSpace="rgb"):
    self.textbox = textbox
    self.index = len(textbox._text)  # start off at the end
    self.autoLog = False
    self.width = width
    self.units = textbox.units
    self.colorSpace = colorSpace
    self.color = color
# Buggy code
def text(self, text):
    self.__dict__["text"] = text
    self._layout()


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def text(self, text):
    self.__dict__["text"] = text
    text = text.replace("<i>", codes["ITAL_START"])
    text = text.replace("</i>", codes["ITAL_END"])
    text = text.replace("<b>", codes["BOLD_START"])
    text = text.replace("</b>", codes["BOLD_END"])
    self._layoutText = text
    self._layout()
# Buggy code
def __init__(self, textbox, color, width, colorSpace="rgb"):
    self.textbox = textbox
    self.index = len(textbox.text)  # start off at the end
    self.autoLog = False
    self.width = width
    self.units = textbox.units
    self.colorSpace = colorSpace
    self.color = color


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def __init__(self, textbox, color, width, colorSpace="rgb"):
    self.textbox = textbox
    self.index = len(textbox._layoutText)  # start off at the end
    self.autoLog = False
    self.width = width
    self.units = textbox.units
    self.colorSpace = colorSpace
    self.color = color
# Buggy code
def fontMGR(self, mgr):
    if isinstance(mgr, FontManager):
        allFonts = mgr
    else:
        raise TypeError(
            f"Could not set font manager for TextBox2 object `{self.name}`, must be supplied with a FontManager object"
        )


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def fontMGR(self, mgr):
    global allFonts
    if isinstance(mgr, FontManager):
        allFonts = mgr
    else:
        raise TypeError(
            f"Could not set font manager for TextBox2 object `{self.name}`, must be supplied with a FontManager object"
        )
# Buggy code
def text(self, text):
    self.__dict__["text"] = text
    text = text.replace("<i>", codes["ITAL_START"])
    text = text.replace("</i>", codes["ITAL_END"])
    text = text.replace("<b>", codes["BOLD_START"])
    text = text.replace("</b>", codes["BOLD_END"])
    self._layoutText = text
    self._layout()


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def text(self, text):
    self.__dict__["text"] = text
    text = text.replace("<i>", codes["ITAL_START"])
    text = text.replace("</i>", codes["ITAL_END"])
    text = text.replace("<b>", codes["BOLD_START"])
    text = text.replace("</b>", codes["BOLD_END"])
    self._layoutText = text
    self._visibleText = None
    self._layout()
# Buggy code
def __init__(self, textbox, color, width, colorSpace="rgb"):
    self.textbox = textbox
    self.index = len(textbox._layoutText)  # start off at the end
    self.autoLog = False
    self.width = width
    self.units = textbox.units
    self.colorSpace = colorSpace
    self.color = color


# Traceback (IndexError)
Traceback (most recent call last):
File "textbox_editable.py", line 67, in <module>
win.flip()
File "psychopy\psychopy\visual\window.py", line 1026, in flip
thisStim.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 551, in draw
self.caret.draw()
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 848, in draw
gl.glVertex2f(self.vertices[0, 0], self.vertices[0, 1])
File "psychopy\psychopy\visual\textbox2\textbox2.py", line 946, in vertices
chrVerts = textbox.vertices[range((ii-1) * 4, (ii-1) * 4 + 4)]
IndexError: index 1212 is out of bounds for axis 0 with size 1176

# Fixed code
def __init__(self, textbox, color, width, colorSpace="rgb"):
    self.textbox = textbox
    self.index = len(textbox.visibleText)  # start off at the end
    self.autoLog = False
    self.width = width
    self.units = textbox.units
    self.colorSpace = colorSpace
    self.color = color
# Buggy code
def __init__(self, frame, id=-1):
    self.frame = frame
    self.app = frame.app
    self.routineMaxSize = 2
    self.appData = self.app.prefs.appData
    aui.AuiNotebook.__init__(self, frame, id)
    self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onClosePane)

    # double buffered better rendering except if retina
    self.SetDoubleBuffered(self.frame.IsDoubleBuffered())

    self._applyAppTheme()
    if not hasattr(self.frame, "exp"):
        return  # we haven't yet added an exp


# Traceback (AttributeError)
Traceback (most recent call last):
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\monitors\MonitorCenter.py", line 1028, in plotGamma
if lumsPre.any() != None:
AttributeError: 'NoneType' object has no attribute 'any'

# Fixed code
def __init__(self, frame, id=-1):
    self.frame = frame
    self.app = frame.app
    self.routineMaxSize = 2
    self.appData = self.app.prefs.appData
    aui.AuiNotebook.__init__(self, frame, id)
    self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onClosePane)

    # double buffered better rendering except if retina

    self.SetDoubleBuffered(not self.frame.isRetina)

    self._applyAppTheme()
    if not hasattr(self.frame, "exp"):
        return  # we haven't yet added an exp
# Buggy code
def _applyAppTheme(self, target=None):
    self.SetArtProvider(PsychopyTabArt())
    self.GetAuiManager().SetArtProvider(PsychopyDockArt())
    for index in range(self.GetPageCount()):
        page = self.GetPage(index)
        # double buffered better rendering except if retina
        self.SetDoubleBuffered(self.frame.IsDoubleBuffered())
        page._applyAppTheme()
    self.Refresh()


# Traceback (AttributeError)
Traceback (most recent call last):
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\monitors\MonitorCenter.py", line 1028, in plotGamma
if lumsPre.any() != None:
AttributeError: 'NoneType' object has no attribute 'any'

# Fixed code
def _applyAppTheme(self, target=None):
    self.SetArtProvider(PsychopyTabArt())
    self.GetAuiManager().SetArtProvider(PsychopyDockArt())
    for index in range(self.GetPageCount()):
        page = self.GetPage(index)
        # double buffered better rendering except if retina
        self.SetDoubleBuffered(not self.frame.isRetina)
        page._applyAppTheme()
    self.Refresh()
# Buggy code
def __del__(self):
    # remove textures from graphics card to prevent crash
    self.clearTextures()


# Traceback (ImportError)
Exception ignored in: <bound method ImageStim.__del__ of <psychopy.visual.image.ImageStim object at 0x00000276E3372358>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\image.py", line 238, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <bound method TextStim.__del__ of <psychopy.visual.text.TextStim object at 0x00000276E3372978>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\text.py", line 177, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
[...]

# Fixed code
def __del__(self):
    # remove textures from graphics card to prevent OpenGl memory leak
    try:
        self.clearTextures()
    except ModuleNotFoundError:
        pass  # has probably been garbage-collected already
# Buggy code
def __del__(self):
    """Remove textures from graphics card to prevent crash"""
    if hasattr(self, "_listID"):
        GL.glDeleteLists(self._listID, 1)
    self.clearTextures()


# Traceback (ImportError)
Exception ignored in: <bound method ImageStim.__del__ of <psychopy.visual.image.ImageStim object at 0x00000276E3372358>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\image.py", line 238, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <bound method TextStim.__del__ of <psychopy.visual.text.TextStim object at 0x00000276E3372978>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\text.py", line 177, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
[...]

# Fixed code
def __del__(self):
    """Remove textures from graphics card to prevent crash"""
    try:
        if hasattr(self, "_listID"):
            GL.glDeleteLists(self._listID, 1)
        self.clearTextures()
    except ModuleNotFoundError:
        pass  # has probably been garbage-collected already
# Buggy code
def __del__(self):
    self._unload()


# Traceback (ImportError)
Exception ignored in: <bound method ImageStim.__del__ of <psychopy.visual.image.ImageStim object at 0x00000276E3372358>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\image.py", line 238, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <bound method TextStim.__del__ of <psychopy.visual.text.TextStim object at 0x00000276E3372978>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\text.py", line 177, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
[...]

# Fixed code
def __del__(self):
    try:
        self._unload()
    except ModuleNotFoundError:
        pass  # has probably been garbage-collected already
# Buggy code
def __del__(self):
    """Remove textures from graphics card to prevent crash"""
    if not self.useShaders:
        GL.glDeleteLists(self._listID, 1)
    self.clearTextures()


# Traceback (ImportError)
Exception ignored in: <bound method ImageStim.__del__ of <psychopy.visual.image.ImageStim object at 0x00000276E3372358>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\image.py", line 238, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <bound method TextStim.__del__ of <psychopy.visual.text.TextStim object at 0x00000276E3372978>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\text.py", line 177, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
[...]

# Fixed code
def __del__(self):
    """Remove textures from graphics card to prevent crash"""
    try:
        if not self.useShaders:
            GL.glDeleteLists(self._listID, 1)
        self.clearTextures()
    except ModuleNotFoundError:
        pass  # has probably been garbage-collected already
# Buggy code
def __del__(self):
    if GL:  # because of pytest fail otherwise
        GL.glDeleteLists(self._listID, 1)


# Traceback (ImportError)
Exception ignored in: <bound method ImageStim.__del__ of <psychopy.visual.image.ImageStim object at 0x00000276E3372358>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\image.py", line 238, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <bound method TextStim.__del__ of <psychopy.visual.text.TextStim object at 0x00000276E3372978>>
Traceback (most recent call last):
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\psychopy\visual\text.py", line 177, in __del__
File "C:\Users\stbo\.virtualenvs\PsychoPy2-v3RNEhUT\lib\site-packages\pyglet\gl\lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
[...]

# Fixed code
def __del__(self):
    if GL:  # because of pytest fail otherwise
        try:
            GL.glDeleteLists(self._listID, 1)
        except ModuleNotFoundError:
            pass  # if pyglet no longer exists
# Buggy code
def copyObject(self, event):
    if wx.TheClipboard.Open():
        # Get color rounded
        col = getattr(self.color, self.ctrls.GetCurrentPage().space)
        if isinstance(col, tuple):
            col = tuple(round(c, 2) for c in col)
        # Copy to clipboard
        wx.TheClipboard.SetData(
            wx.TextDataObject(
                "Color(" + str(col) + ", " + self.ctrls.GetCurrentPage().space + ")"
            )
        )
        wx.TheClipboard.Close()


# Traceback (AttributeError)
Traceback (most recent call last):
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\_psychopyApp.py", line 647, in colorPicker
PsychoColorPicker(self.coder)
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\colorpicker\__init__.py", line 38, in __init__
self.ctrls.AddPage(ColorPage(self.ctrls, self, 'hexa'), 'Hex')
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\colorpicker\__init__.py", line 219, in __init__
self.valCtrl = ColorValue(self)
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\colorpicker\__init__.py", line 261, in __init__
wx.TextCtrl.__init__(self, parent=self.parent, value=str(getattr(self.color, self.space)), style=wx.TE_RICH, size=(250, -1))
AttributeError: 'Color' object has no attribute 'hexa'

# Fixed code
def copyObject(self, event):
    if wx.TheClipboard.Open():
        # Get color rounded
        col = getattr(self.color, self.ctrls.GetCurrentPage().space)
        if isinstance(col, tuple):
            col = tuple(round(c, 2) for c in col)
        # Copy to clipboard
        wx.TheClipboard.SetData(
            wx.TextDataObject(
                "Color(" + str(col) + ", '" + self.ctrls.GetCurrentPage().space + "')"
            )
        )
        wx.TheClipboard.Close()
# Buggy code
def validate(self, color, against=None, enforce=None):
    # If not checking against anything, check against everything
    if not against:
        against = list(colorSpaces)
    # If looking for a string, convert from other forms it could be in
    if enforce == str:
        color = str(color).lower()
    # If looking for a tuple, convert from other forms it could be in
    if enforce == tuple or enforce == (tuple, int):
        if isinstance(color, str):
            color = [float(n) for n in color.strip("[]()").split(",")]
        if isinstance(color, list):
            color = tuple(color)

    # If enforcing multiple
    if enforce == (tuple, int):
        color = tuple(int(round(c)) for c in color)
    # Get possible colour spaces
    possible = Color.getSpace(color)
    if isinstance(possible, str):
        possible = [possible]
    # Return if any matches
    for space in possible:
        if space in against:
            return color
    # If no matches...
    self.named = None
    return None


# Traceback (AttributeError)
Traceback (most recent call last):
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\_psychopyApp.py", line 647, in colorPicker
PsychoColorPicker(self.coder)
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\colorpicker\__init__.py", line 38, in __init__
self.ctrls.AddPage(ColorPage(self.ctrls, self, 'hexa'), 'Hex')
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\colorpicker\__init__.py", line 219, in __init__
self.valCtrl = ColorValue(self)
File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\colorpicker\__init__.py", line 261, in __init__
wx.TextCtrl.__init__(self, parent=self.parent, value=str(getattr(self.color, self.space)), style=wx.TE_RICH, size=(250, -1))
AttributeError: 'Color' object has no attribute 'hexa'

# Fixed code
def validate(self, color, against=None, enforce=None):
    # If not checking against anything, check against everything
    if not against:
        against = list(colorSpaces)
    # If looking for a string, convert from other forms it could be in
    if enforce == str:
        color = str(color).lower()
    # If looking for a tuple, convert from other forms it could be in
    if enforce == tuple or enforce == (tuple, int):
        if isinstance(color, str):
            color = [float(n) for n in color.strip("[]()").split(",")]
        if isinstance(color, list):
            color = tuple(color)

    # If enforcing multiple
    if enforce == (tuple, int):
        alpha = (color[-1],) if len(color) == 4 else ()
        color = tuple(int(round(c)) for c in color[:3]) + alpha
    # Get possible colour spaces
    possible = Color.getSpace(color)
    if isinstance(possible, str):
        possible = [possible]
    # Return if any matches
    for space in possible:
        if space in against:
            return color
    # If no matches...
    self.named = None
    return None
# Buggy code
def _onPygletText(text, emulated=False):
    """handler for on_text pyglet events, or call directly to emulate a text
    event.

    S Mathot 2012: This function only acts when the key that is pressed
    corresponds to a non-ASCII text character (Greek, Arabic, Hebrew, etc.).
    In that case the symbol that is passed to _onPygletKey() is translated
    into a useless 'user_key()' string. If this happens, _onPygletText takes
    over the role of capturing the key. Unfortunately, _onPygletText()
    cannot solely handle all input, because it does not respond to spacebar
    presses, etc.
    """

    global useText
    if not useText:  # _onPygletKey has handled the input
        return
    # capture when the key was pressed:
    keyTime = psychopy.core.getTime()
    if emulated:
        keySource = "EmulatedKey"
    else:
        keySource = "KeyPress"
    _keyBuffer.append((text, keyTime))
    logging.data("%s: %s" % (keySource, text))


# Traceback (TypeError)
Traceback (most recent call last):
File "D:/Programmierung/PyCharm/psychopy-key-test/app.py", line 6, in <module>
event.getKeys(modifiers=True)
File "D:\Programmierung\PyCharm\psychopy-key-test\venv\lib\site-packages\psychopy\event.py", line 435, in getKeys
keyNames = [(k[0], modifiers_dict(k[1])) for k in targets]
File "D:\Programmierung\PyCharm\psychopy-key-test\venv\lib\site-packages\psychopy\event.py", line 435, in <listcomp>
keyNames = [(k[0], modifiers_dict(k[1])) for k in targets]
File "D:\Programmierung\PyCharm\psychopy-key-test\venv\lib\site-packages\psychopy\event.py", line 353, in modifiers_dict
'MOD_SCROLLLOCK'
File "D:\Programmierung\PyCharm\psychopy-key-test\venv\lib\site-packages\psychopy\event.py", line 344, in <dictcomp>
return {(mod[4:].lower()): modifiers &amp; getattr(sys.modules[__name__], mod) > 0 for mod in [
TypeError: unsupported operand type(s) for &amp;: 'float' and 'int'

# Fixed code
def _onPygletText(text, emulated=False):
    """handler for on_text pyglet events, or call directly to emulate a text
    event.

    S Mathot 2012: This function only acts when the key that is pressed
    corresponds to a non-ASCII text character (Greek, Arabic, Hebrew, etc.).
    In that case the symbol that is passed to _onPygletKey() is translated
    into a useless 'user_key()' string. If this happens, _onPygletText takes
    over the role of capturing the key. Unfortunately, _onPygletText()
    cannot solely handle all input, because it does not respond to spacebar
    presses, etc.
    """

    global useText
    if not useText:  # _onPygletKey has handled the input
        return
    # This is needed because sometimes the execution
    # sequence is messed up (somehow)
    useText = False
    # capture when the key was pressed:
    keyTime = psychopy.core.getTime()
    if emulated:
        keySource = "EmulatedKey"
    else:
        keySource = "KeyPress"
    _keyBuffer.append((text.lower(), lastModifiers, keyTime))
    logging.data("%s: %s" % (keySource, text))
# Buggy code
def __init__(self, port, password, sync_request_timeout=300):
    channel = rpyc.Channel(rpyc.SocketStream.connect("127.0.0.1", port))
    channel.send(password.encode("utf-8"))
    response = channel.recv()
    if response == AUTH_ERROR:
        # TODO: What to raise here. I guess we create a custom error
        raise ValueError("Invalid password for daemon")
    self.conn = rpyc.utils.factory.connect_channel(
        channel,
        service=ClientService,
        config={"sync_request_timeout": sync_request_timeout},
    )


# Traceback (rpyc.lib.compat.TimeoutError)
Traceback (most recent call last):
File "/usr/local/bin/flexget", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/flexget/__init__.py", line 42, in main
manager.start()
File "/usr/local/lib/python2.7/dist-packages/flexget/manager.py", line 344, in start
client.handle_cli(self.args)
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/netref.py", line 199, in __call__
return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/netref.py", line 75, in syncreq
return conn.sync_request(handler, proxy, *args)
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/protocol.py", line 471, in sync_request
return self.async_request(handler, *args, timeout=timeout).value
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/async_.py", line 95, in value
self.wait()
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/async_.py", line 47, in wait
raise AsyncResultTimeout("result expired")
rpyc.lib.compat.TimeoutError: result expired

# Fixed code
def __init__(self, port, password):
    channel = rpyc.Channel(rpyc.SocketStream.connect("127.0.0.1", port))
    channel.send(password.encode("utf-8"))
    response = channel.recv()
    if response == AUTH_ERROR:
        # TODO: What to raise here. I guess we create a custom error
        raise ValueError("Invalid password for daemon")
    self.conn = rpyc.utils.factory.connect_channel(
        channel, service=ClientService, config={"sync_request_timeout": None}
    )
# Buggy code
def __eq__(self, other):
    return self.get("title") == other.get("title") and self.get(
        "original_url"
    ) == other.get("original_url")


# Traceback (KeyError)
2016-02-02 23:41 CRITICAL task_queue                    BUG: Unhandled exception during task queue run loop.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flexget/task_queue.py", line 47, in run
self.current_task.execute()
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 69, in wrapper
return func(self, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 578, in execute
self._execute()
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 557, in _execute
entry.complete()
File "/usr/local/lib/python2.7/dist-packages/flexget/entry.py", line 163, in complete
self.run_hooks('complete', **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/entry.py", line 78, in run_hooks
func(self, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/plugins/input/discover.py", line 178, in entry_complete
search_results.remove(entry)
KeyError: <Entry(title=Sarah.&amp;.Duck.S01E03.Lach.mal.Esel.GERMAN.HDTV.x264-pbw,state=rejected)>

# Fixed code
def __eq__(self, other):
    return self.get("original_title") == other.get("original_title") and self.get(
        "original_url"
    ) == other.get("original_url")
# Buggy code
def __hash__(self):
    return hash(self.get("title", "") + self.get("original_url", ""))


# Traceback (KeyError)
2016-02-02 23:41 CRITICAL task_queue                    BUG: Unhandled exception during task queue run loop.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flexget/task_queue.py", line 47, in run
self.current_task.execute()
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 69, in wrapper
return func(self, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 578, in execute
self._execute()
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 557, in _execute
entry.complete()
File "/usr/local/lib/python2.7/dist-packages/flexget/entry.py", line 163, in complete
self.run_hooks('complete', **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/entry.py", line 78, in run_hooks
func(self, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/plugins/input/discover.py", line 178, in entry_complete
search_results.remove(entry)
KeyError: <Entry(title=Sarah.&amp;.Duck.S01E03.Lach.mal.Esel.GERMAN.HDTV.x264-pbw,state=rejected)>

# Fixed code
def __hash__(self):
    return hash(self.get("original_title", "") + self.get("original_url", ""))
# Buggy code
def __setitem__(self, key, value):
    log.debug("setting key %s value %s" % (key, repr(value)))
    self.store[key] = value


# Traceback (AttributeError)
2016-05-14 17:45 INFO     manager                       Database upgrade is required. Attempting now.
2016-05-14 17:45 ERROR    schema                        Failed to upgrade database for plugin simple_persistence: value
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/flexget/db_schema.py", line 150, in upgrade_wrapper
new_ver = upgrade_func(current_ver, session)
File "/usr/lib/python2.7/site-packages/flexget/utils/simple_persistence.py", line 42, in upgrade
for row in session.execute(select([table.c.id, table.c.plugin, table.c.key, table.c.value])):
File "/usr/lib/python2.7/site-packages/sqlalchemy/util/_collections.py", line 211, in __getattr__
raise AttributeError(key)
AttributeError: value
Traceback (most recent call last):
File "/usr/bin/flexget", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/flexget/__init__.py", line 42, in main
manager.start()
File "/usr/lib/python2.7/site-packages/flexget/manager.py", line 309, in start
self.initialize()
File "/usr/lib/python2.7/site-packages/flexget/manager.py", line 206, in initialize
fire_event('manager.upgrade', self)
File "/usr/lib/python2.7/site-packages/flexget/event.py", line 106, in fire_event
result = event(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/flexget/event.py", line 23, in __call__
return self.func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/flexget/db_schema.py", line 158, in upgrade_wrapper
manager.shutdown(finish_queue=False)
File "/usr/lib/python2.7/site-packages/flexget/manager.py", line 858, in shutdown
raise RuntimeError('Cannot shutdown manager that was never initialized.')
RuntimeError: Cannot shutdown manager that was never initialized.

# Fixed code
def __setitem__(self, key, value):
    log.debug("setting key %s value %s", key, repr(value))
    self.store[key] = value