# Buggy code
def load_data(self, filename, ext):
    """Load data from a file."""
    overwrite = False
    if self.namespacebrowser.editor.var_properties:
        message = _(
            "Do you want to overwrite old "
            "variables (if any) in the namespace "
            "when loading the data?"
        )
        buttons = QMessageBox.Yes | QMessageBox.No
        result = QMessageBox.question(self, _("Data loading"), message, buttons)
        overwrite = result == QMessageBox.Yes
    try:
        return self.call_kernel(
            interrupt=True, blocking=True, timeout=CALL_KERNEL_TIMEOUT
        ).load_data(filename, ext, overwrite=overwrite)
    except ImportError as msg:
        module = str(msg).split("'")[1]
        msg = _(
            "Spyder is unable to open the file "
            "you're trying to load because <tt>{module}</tt> is "
            "not installed. Please install "
            "this package in your working environment."
            "<br>"
        ).format(module=module)
        return msg
    except TimeoutError:
        msg = _("Data is too big to be loaded")
        return msg
    except (UnpicklingError, RuntimeError):
        return None


# Traceback (KeyError)
File "C:\Anaconda\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 372, in setModelData
self.get_value(index),
File "C:\Anaconda\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1373, in get_value
return self.parent().get_value(name)
File "C:\Anaconda\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1431, in get_value
value = self.shellwidget.get_value(name)
File "C:\Anaconda\lib\site-packages\spyder\plugins\ipythonconsole\widgets\namespacebrowser.py", line 97, in get_value
return self.call_kernel(
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 549, in __call__
return self._comms_wrapper._get_call_return_value(
File "C:\Anaconda\lib\site-packages\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 151, in _get_call_return_value
return super(KernelComm, self)._get_call_return_value(
File "C:\Anaconda\lib\contextlib.py", line 120, in __exit__
next(self.gen)
File "C:\Anaconda\lib\site-packages\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 99, in comm_channel_manager
self._comms[comm_id]['comm']._send_channel = (
KeyError: '0fb3ca1fe6a811eab88400a0c6000013'

# Fixed code
def load_data(self, filename, ext):
    """Load data from a file."""
    overwrite = False
    if self.namespacebrowser.editor.var_properties:
        message = _(
            "Do you want to overwrite old "
            "variables (if any) in the namespace "
            "when loading the data?"
        )
        buttons = QMessageBox.Yes | QMessageBox.No
        result = QMessageBox.question(self, _("Data loading"), message, buttons)
        overwrite = result == QMessageBox.Yes
    try:
        return self.call_kernel(
            interrupt=True,
            blocking=True,
            display_error=True,
            timeout=CALL_KERNEL_TIMEOUT,
        ).load_data(filename, ext, overwrite=overwrite)
    except ImportError as msg:
        module = str(msg).split("'")[1]
        msg = _(
            "Spyder is unable to open the file "
            "you're trying to load because <tt>{module}</tt> is "
            "not installed. Please install "
            "this package in your working environment."
            "<br>"
        ).format(module=module)
        return msg
    except TimeoutError:
        msg = _("Data is too big to be loaded")
        return msg
    except (UnpicklingError, RuntimeError):
        return None