# Buggy code
def __init__(
    self,
    parent,
    history_filename,
    profile=False,
    initial_message=None,
    default_foreground_color=None,
    error_foreground_color=None,
    traceback_foreground_color=None,
    prompt_foreground_color=None,
    background_color=None,
):
    """
    parent : specifies the parent widget
    """
    ConsoleBaseWidget.__init__(self, parent)
    SaveHistoryMixin.__init__(self, history_filename)
    BrowseHistoryMixin.__init__(self)

    # Prompt position: tuple (line, index)
    self.current_prompt_pos = None
    self.new_input_line = True

    # History
    assert is_text_string(history_filename)
    self.history = self.load_history()

    # Session
    self.historylog_filename = CONF.get(
        "main", "historylog_filename", get_conf_path("history.log")
    )

    # Context menu
    self.menu = None
    self.setup_context_menu()

    # Simple profiling test
    self.profile = profile

    # Buffer to increase performance of write/flush operations
    self.__buffer = []
    if initial_message:
        self.__buffer.append(initial_message)

    self.__timestamp = 0.0
    self.__flushtimer = QTimer(self)
    self.__flushtimer.setSingleShot(True)
    self.__flushtimer.timeout.connect(self.flush)

    # Give focus to widget
    self.setFocus()

    # Cursor width
    self.setCursorWidth(CONF.get("main", "cursor/width"))


# Traceback (TypeError)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\console\widgets\internalshell.py", line 353, in keyPressEvent
self.postprocess_keyevent(event)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\console\widgets\shell.py", line 713, in postprocess_keyevent
ShellBaseWidget.postprocess_keyevent(self, event)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\console\widgets\shell.py", line 362, in postprocess_keyevent
self._key_tab()
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\console\widgets\shell.py", line 745, in _key_tab
self.show_code_completion(automatic=False)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\console\widgets\shell.py", line 893, in show_code_completion
automatic=automatic)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\widgets\base.py", line 1131, in show_completion_list
self.show_completion_widget(completions, automatic=automatic)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\widgets\base.py", line 1107, in show_completion_widget
self.completion_widget.show_list(textlist, automatic=automatic)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\widgets\base.py", line 112, in show_list
icon = icons_map.get(completion['kind'], 'no_match')
TypeError: tuple indices must be integers or slices, not str

# Fixed code
def __init__(
    self,
    parent,
    history_filename,
    profile=False,
    initial_message=None,
    default_foreground_color=None,
    error_foreground_color=None,
    traceback_foreground_color=None,
    prompt_foreground_color=None,
    background_color=None,
):
    """
    parent : specifies the parent widget
    """
    ConsoleBaseWidget.__init__(self, parent)
    SaveHistoryMixin.__init__(self, history_filename)
    BrowseHistoryMixin.__init__(self)

    # Prompt position: tuple (line, index)
    self.current_prompt_pos = None
    self.new_input_line = True

    # History
    assert is_text_string(history_filename)
    self.history = self.load_history()

    # Session
    self.historylog_filename = CONF.get(
        "main", "historylog_filename", get_conf_path("history.log")
    )

    # Context menu
    self.menu = None
    self.setup_context_menu()

    # Simple profiling test
    self.profile = profile

    # Buffer to increase performance of write/flush operations
    self.__buffer = []
    if initial_message:
        self.__buffer.append(initial_message)

    self.__timestamp = 0.0
    self.__flushtimer = QTimer(self)
    self.__flushtimer.setSingleShot(True)
    self.__flushtimer.timeout.connect(self.flush)

    # Give focus to widget
    self.setFocus()

    # Cursor width
    self.setCursorWidth(CONF.get("main", "cursor/width"))

    # Adjustments to completion_widget to use it here
    self.completion_widget.currentRowChanged.disconnect()