# Buggy code
def configure_shellwidget(self, give_focus=True):
    """Configure shellwidget after kernel is started"""
    if give_focus:
        self.get_control().setFocus()

    # Set exit callback
    self.shellwidget.set_exit_callback()

    # To save history
    self.shellwidget.executing.connect(self.add_to_history)

    # For Mayavi to run correctly
    self.shellwidget.executing.connect(self.set_backend_for_mayavi)

    # To update history after execution
    self.shellwidget.executed.connect(self.update_history)

    # To update the Variable Explorer after execution
    self.shellwidget.executed.connect(self.shellwidget.refresh_namespacebrowser)

    # To enable the stop button when executing a process
    self.shellwidget.executing.connect(self.enable_stop_button)

    # To disable the stop button after execution stopped
    self.shellwidget.executed.connect(self.disable_stop_button)

    # To show kernel restarted/died messages
    self.shellwidget.sig_kernel_restarted.connect(self.kernel_restarted_message)


# Traceback (TypeError)
Traceback (most recent call last):
File "D:\code\thirdparty\spyder\spyder\widgets\ipythonconsole\namespacebrowser.py", line 49, in <lambda>
self.namespacebrowser.process_remote_view(data))
File "D:\code\thirdparty\spyder\spyder\widgets\variableexplorer\namespacebrowser.py", line 232, in process_remote_view
self.set_data(remote_view)
File "D:\code\thirdparty\spyder\spyder\widgets\variableexplorer\namespacebrowser.py", line 243, in set_data
self.editor.set_data(data)
File "D:\code\thirdparty\spyder\spyder\widgets\variableexplorer\collectionseditor.py", line 830, in set_data
self.model.set_data(data, self.dictfilter)
File "D:\code\thirdparty\spyder\spyder\widgets\variableexplorer\collectionseditor.py", line 170, in set_data
self.set_size_and_type()
File "D:\code\thirdparty\spyder\spyder\widgets\variableexplorer\collectionseditor.py", line 185, in set_size_and_type
for index in range(start, stop) ]
TypeError: 'int' object has no attribute '__getitem__'

# Fixed code
def configure_shellwidget(self, give_focus=True):
    """Configure shellwidget after kernel is started"""
    if give_focus:
        self.get_control().setFocus()

    # Set exit callback
    self.shellwidget.set_exit_callback()

    # To save history
    self.shellwidget.executing.connect(self.add_to_history)

    # For Mayavi to run correctly
    self.shellwidget.executing.connect(self.set_backend_for_mayavi)

    # To update history after execution
    self.shellwidget.executed.connect(self.update_history)

    # To update the Variable Explorer after execution
    self.shellwidget.executed.connect(self.shellwidget.refresh_namespacebrowser)

    # To enable the stop button when executing a process
    self.shellwidget.executing.connect(self.enable_stop_button)

    # To disable the stop button after execution stopped
    self.shellwidget.executed.connect(self.disable_stop_button)

    # To show kernel restarted/died messages
    self.shellwidget.sig_kernel_restarted.connect(self.kernel_restarted_message)

    # To restart the kernel when errors happened while debugging
    # See issue 4003
    self.shellwidget.sig_dbg_kernel_restart.connect(self.restart_kernel)