# 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,
            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


# Traceback (TimeoutError)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/qtconsole/base_frontend_mixin.py", line 138, in _dispatch
handler(msg)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 172, in _handle_execute_reply
self.refresh_namespacebrowser()
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 63, in refresh_namespacebrowser
callback=self.set_namespace_view
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder_kernels/comms/commbase.py", line 538, in __call__
call_dict, call_data, self._comm_id)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 130, in _get_call_return_value
with self.comm_channel_manager(comm_id, queue_message=not interrupt):
File "/home/nerohmot/my-envs/s4/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 87, in comm_channel_manager
timeout)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 168, in _wait
raise TimeoutError(timeout_msg)
TimeoutError: Timeout while waiting for comm port.
Traceback (most recent call last):
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/qtconsole/base_frontend_mixin.py", line 138, in _dispatch
handler(msg)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 172, in _handle_execute_reply
self.refresh_namespacebrowser()
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 63, in refresh_namespacebrowser
callback=self.set_namespace_view
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder_kernels/comms/commbase.py", line 538, in __call__
call_dict, call_data, self._comm_id)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 130, in _get_call_return_value
with self.comm_channel_manager(comm_id, queue_message=not interrupt):
File "/home/nerohmot/my-envs/s4/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 87, in comm_channel_manager
timeout)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 168, in _wait
raise TimeoutError(timeout_msg)
TimeoutError: Timeout while waiting for comm port.
Traceback (most recent call last):
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 554, in set_current_client_working_directory
shellwidget.set_cwd(directory)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/shell.py", line 178, in set_cwd
self.call_kernel(interrupt=True).set_cwd(dirname)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder_kernels/comms/commbase.py", line 538, in __call__
call_dict, call_data, self._comm_id)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 130, in _get_call_return_value
with self.comm_channel_manager(comm_id, queue_message=not interrupt):
File "/home/nerohmot/my-envs/s4/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 87, in comm_channel_manager
timeout)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 168, in _wait
raise TimeoutError(timeout_msg)
TimeoutError: Timeout while waiting for comm port.

# 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(
            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, CommError):
        return None