# Buggy code
def get_doc(self, objtxt):
    """Get object documentation dictionary"""
    try:
        return self.call_kernel(interrupt=True, blocking=True).get_doc(objtxt)
    except (TimeoutError, 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 get_doc(self, objtxt):
    """Get object documentation dictionary"""
    try:
        return self.call_kernel(blocking=True).get_doc(objtxt)
    except (TimeoutError, UnpicklingError, RuntimeError, CommError):
        return None