Repository: spyder-ide/spyder

Issue:
"Warning, no such comm" shown when restarting the kernel
Restarting the kernel results in error messages 
"[SpyderKernelApp] WARNING | Parent appears to have exited, shutting down."
and 
"[SpyderKernelApp] WARNING | No such comm: 1ef79d32aca311eb8ca968f7286a1381"

Screencast trying to restart the kernel:

https://youtu.be/kypFTA0xnCU





Discussion:
Hi @BjornFJohansson,

Can you please let me know what version of Spyder 5 are you using?

@impact27 do you know why the `[SpyderKernelApp] WARNING | Parent appears to have exited, shutting down` message is appearing?
This problem should be fixed in our next version (5.0.2), to be released shortly.
@steff456 and @ccordoba12 

I listed all installed packages in the environment with the Spyder installation in
case it would be helpful. Thanks for the response!
/bjorn

<details>

    (base) bjorn@bjorn-ThinkPad-T450s:~$ mamba list
    
                      __    __    __    __
                     /  \  /  \  /  \  /  \
                    /    \/    \/    \/    \
    ███████████████/  /██/  /██/  /██/  /████████████████████████
                  /  / \   / \   / \   / \  \____
                 /  /   \_/   \_/   \_/   \    o \__,
                / _/                       \_____/  `
                |/
            ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
            ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
            ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
            ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
            ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
            ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝
    
            mamba (0.8.0) supported by @QuantStack
    
            GitHub:  https://github.com/mamba-org/mamba
            Twitter: https://twitter.com/QuantStack
    
    █████████████████████████████████████████████████████████████
    
    # packages in environment at /home/bjorn/anaconda3:
    #
    # Name                    Version                   Build  Channel
    _ipyw_jlab_nb_ext_conf    0.1.0                    py38_0    defaults
    _libgcc_mutex             0.1                 conda_forge    conda-forge
    _openmp_mutex             4.5                       1_gnu    conda-forge
    alabaster                 0.7.12                     py_0    conda-forge
    anaconda-client           1.7.2                      py_0    conda-forge
    anaconda-navigator        2.0.1                    py38_0    defaults
    anyio                     2.2.0            py38h578d9bd_0    conda-forge
    appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
    argcomplete               1.12.1             pyh9f0ad1d_0    conda-forge
    argh                      0.26.2          pyh9f0ad1d_1002    conda-forge
    argon2-cffi               20.1.0           py38h497a2fe_2    conda-forge
    arrow                     1.0.3            py38h578d9bd_0    conda-forge
    astroid                   2.5.3            py38h578d9bd_0    conda-forge
    async_generator           1.10                       py_0    conda-forge
    atomicwrites              1.4.0              pyh9f0ad1d_0    conda-forge
    attrs                     20.3.0             pyhd3deb0d_0    conda-forge
    autopep8                  1.5.6              pyhd8ed1ab_0    conda-forge
    babel                     2.9.0              pyhd3deb0d_0    conda-forge
    backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
    backports                 1.0                        py_2    conda-forge
    backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
    backports.tempfile        1.0                        py_0    conda-forge
    backports.weakref         1.0.post1       py38h32f6830_1002    conda-forge
    bash-completion           2.11                          0    conda-forge
    beautifulsoup4            4.9.3              pyhb0f4dca_0    conda-forge
    binaryornot               0.4.4                      py_1    conda-forge
    black                     20.8b1                     py_1    conda-forge
    bleach                    3.3.0              pyh44b312d_0    conda-forge
    brotlipy                  0.7.0           py38h497a2fe_1001    conda-forge
    bzip2                     1.0.8                h7f98852_4    conda-forge
    c-ares                    1.17.1               h7f98852_1    conda-forge
    ca-certificates           2021.4.13            h06a4308_1    defaults
    certifi                   2020.12.5        py38h578d9bd_1    conda-forge
    cffi                      1.14.5           py38ha65f79e_0    conda-forge
    chardet                   4.0.0            py38h578d9bd_1    conda-forge
    click                     7.1.2              pyh9f0ad1d_0    conda-forge
    cloudpickle               1.6.0                      py_0    conda-forge
    clyent                    1.2.2                      py_1    conda-forge
    colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
    conda                     4.10.1           py38h578d9bd_0    conda-forge
    conda-bash-completion     1.5                           1    conda-forge
    conda-build               3.21.4           py38h578d9bd_0    conda-forge
    conda-env                 2.6.0                         1    defaults
    conda-package-handling    1.7.3            py38h497a2fe_0    conda-forge
    conda-repo-cli            1.0.3              pyhd3eb1b0_0    defaults
    conda-token               0.2.0              pyhd3eb1b0_0    defaults
    conda-verify              3.4.2                      py_1    defaults
    cookiecutter              1.7.2              pyh9f0ad1d_0    conda-forge
    cryptography              3.4.7            py38ha5dfef3_0    conda-forge
    dataclasses               0.8                pyhc8e2a94_1    conda-forge
    dbus                      1.13.6               h48d8840_2    conda-forge
    decorator                 5.0.7              pyhd8ed1ab_0    conda-forge
    defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
    diff-match-patch          20200713           pyh9f0ad1d_0    conda-forge
    docutils                  0.17             py38h578d9bd_0    conda-forge
    entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
    expat                     2.3.0                h9c3ff4c_0    conda-forge
    filelock                  3.0.12             pyh9f0ad1d_0    conda-forge
    flake8                    3.8.4                      py_0    conda-forge
    fontconfig                2.13.1            hba837de_1005    conda-forge
    freetype                  2.10.4               h0708190_1    conda-forge
    future                    0.18.2           py38h578d9bd_3    conda-forge
    gettext                   0.19.8.1          h0b5b191_1005    conda-forge
    glib                      2.68.1               h9c3ff4c_0    conda-forge
    glib-tools                2.68.1               h9c3ff4c_0    conda-forge
    glob2                     0.7                        py_0    conda-forge
    gst-plugins-base          1.18.4               h29181c9_0    conda-forge
    gstreamer                 1.18.4               h76c114f_0    conda-forge
    icu                       68.1                 h58526e2_0    conda-forge
    idna                      2.10               pyh9f0ad1d_0    conda-forge
    imagesize                 1.2.0                      py_0    conda-forge
    importlib-metadata        3.10.1           py38h578d9bd_0    conda-forge
    importlib_metadata        1.5.0                    py38_0    conda-forge
    inflection                0.5.1              pyh9f0ad1d_0    conda-forge
    intervaltree              3.0.2                      py_0    conda-forge
    ipykernel                 5.5.3            py38hd0cf306_0    conda-forge
    ipython                   7.22.0           py38hd0cf306_0    conda-forge
    ipython_genutils          0.2.0                      py_1    conda-forge
    ipywidgets                7.6.3              pyhd3deb0d_0    conda-forge
    isort                     5.8.0              pyhd8ed1ab_0    conda-forge
    jedi                      0.17.2           py38h578d9bd_1    conda-forge
    jeepney                   0.6.0              pyhd8ed1ab_0    conda-forge
    jinja2                    2.11.3             pyh44b312d_0    conda-forge
    jinja2-time               0.2.0                      py_2    conda-forge
    jpeg                      9d                   h36c2ea0_0    conda-forge
    json5                     0.9.5              pyh9f0ad1d_0    conda-forge
    jsonschema                3.2.0              pyhd8ed1ab_3    conda-forge
    jupyter-packaging         0.7.12             pyhd8ed1ab_0    conda-forge
    jupyter_client            6.1.12             pyhd8ed1ab_0    conda-forge
    jupyter_core              4.7.1            py38h578d9bd_0    conda-forge
    jupyter_server            1.5.0            py38h578d9bd_0    conda-forge
    jupyterlab                3.0.14             pyhd8ed1ab_0    conda-forge
    jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
    jupyterlab_server         2.4.0              pyhd8ed1ab_0    conda-forge
    jupyterlab_templates      0.3.0              pyhd8ed1ab_0    conda-forge
    jupyterlab_widgets        1.0.0              pyhd8ed1ab_1    conda-forge
    keyring                   22.3.0           py38h578d9bd_0    conda-forge
    krb5                      1.17.2               h926e7f8_0    conda-forge
    lazy-object-proxy         1.6.0            py38h497a2fe_0    conda-forge
    lcms2                     2.12                 hddcbb42_0    conda-forge
    ld_impl_linux-64          2.35.1               hea4e1c9_2    conda-forge
    libarchive                3.5.1                h3f442fb_1    conda-forge
    libclang                  11.1.0          default_ha53f305_0    conda-forge
    libcurl                   7.76.1               hc4aaa36_0    conda-forge
    libedit                   3.1.20191231         he28a2e2_2    conda-forge
    libev                     4.33                 h516909a_1    conda-forge
    libevent                  2.1.10               hcdb4288_3    conda-forge
    libffi                    3.3                  h58526e2_2    conda-forge
    libgcc-ng                 9.3.0               h2828fa1_19    conda-forge
    libglib                   2.68.1               h3e27bee_0    conda-forge
    libgomp                   9.3.0               h2828fa1_19    conda-forge
    libiconv                  1.16                 h516909a_0    conda-forge
    liblief                   0.10.1               he1b5a44_2    conda-forge
    libllvm11                 11.1.0               hf817b99_2    conda-forge
    libnghttp2                1.43.0               h812cca2_0    conda-forge
    libpng                    1.6.37               h21135ba_2    conda-forge
    libpq                     13.1                 hfd2b0eb_2    conda-forge
    libsodium                 1.0.18               h36c2ea0_1    conda-forge
    libsolv                   0.7.18               h780b84a_0    conda-forge
    libspatialindex           1.9.3                h9c3ff4c_3    conda-forge
    libssh2                   1.9.0                ha56f1ee_6    conda-forge
    libstdcxx-ng              9.3.0               h6de172a_19    conda-forge
    libtiff                   4.2.0                hdc55705_0    conda-forge
    libuuid                   2.32.1            h7f98852_1000    conda-forge
    libwebp-base              1.2.0                h7f98852_2    conda-forge
    libxcb                    1.13              h7f98852_1003    conda-forge
    libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
    libxml2                   2.9.10               h72842e0_4    conda-forge
    lz4-c                     1.9.3                h9c3ff4c_0    conda-forge
    lzo                       2.10              h516909a_1000    conda-forge
    mamba                     0.8.0            py38h2aa5da1_0    conda-forge
    markupsafe                1.1.1            py38h497a2fe_3    conda-forge
    mccabe                    0.6.1                      py_1    conda-forge
    mistune                   0.8.4           py38h497a2fe_1003    conda-forge
    mypy_extensions           0.4.3            py38h578d9bd_3    conda-forge
    mysql-common              8.0.23               ha770c72_1    conda-forge
    mysql-libs                8.0.23               h935591d_1    conda-forge
    navigator-updater         0.2.1                    py38_0    defaults
    nb_conda_kernels          2.3.1            py38h578d9bd_0    conda-forge
    nbclassic                 0.2.7              pyhd8ed1ab_0    conda-forge
    nbclient                  0.5.3              pyhd8ed1ab_0    conda-forge
    nbconvert                 6.0.7            py38h578d9bd_3    conda-forge
    nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
    ncurses                   6.2                  h58526e2_4    conda-forge
    nest-asyncio              1.5.1              pyhd8ed1ab_0    conda-forge
    nodejs                    12.4.0               he1b5a44_0    conda-forge
    notebook                  6.3.0            py38h578d9bd_0    conda-forge
    nspr                      4.30                 h9c3ff4c_0    conda-forge
    nss                       3.64                 hb5efdd6_0    conda-forge
    numpydoc                  1.1.0                      py_1    conda-forge
    olefile                   0.46               pyh9f0ad1d_1    conda-forge
    openjpeg                  2.4.0                hf7af979_0    conda-forge
    openssl                   1.1.1k               h7f98852_0    conda-forge
    packaging                 20.9               pyh44b312d_0    conda-forge
    pandoc                    2.12                 h7f98852_0    conda-forge
    pandocfilters             1.4.2                      py_1    conda-forge
    parso                     0.7.0              pyh9f0ad1d_0    conda-forge
    patchelf                  0.11                 he1b5a44_0    conda-forge
    pathspec                  0.8.1              pyhd3deb0d_0    conda-forge
    pcre                      8.44                 he1b5a44_0    conda-forge
    pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
    pickleshare               0.7.5                   py_1003    conda-forge
    pillow                    8.1.2            py38ha0e1e83_1    conda-forge
    pip                       21.0.1             pyhd8ed1ab_0    conda-forge
    pkginfo                   1.7.0              pyhd8ed1ab_0    conda-forge
    pluggy                    0.13.1           py38h578d9bd_4    conda-forge
    poyo                      0.5.0                      py_0    conda-forge
    prometheus_client         0.10.1             pyhd8ed1ab_0    conda-forge
    prompt-toolkit            3.0.18             pyha770c72_0    conda-forge
    psutil                    5.8.0            py38h497a2fe_1    conda-forge
    pthread-stubs             0.4               h36c2ea0_1001    conda-forge
    ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
    py-lief                   0.10.1           py38h348cfbe_2    conda-forge
    pycodestyle               2.6.0              pyh9f0ad1d_0    conda-forge
    pycosat                   0.6.3           py38h497a2fe_1006    conda-forge
    pycparser                 2.20               pyh9f0ad1d_2    conda-forge
    pydocstyle                6.0.0              pyhd8ed1ab_0    conda-forge
    pyflakes                  2.2.0              pyh9f0ad1d_0    conda-forge
    pygments                  2.8.1              pyhd8ed1ab_0    conda-forge
    pylint                    2.7.2            py38h578d9bd_0    conda-forge
    pyls-black                0.4.6              pyh9f0ad1d_0    conda-forge
    pyls-spyder               0.3.2              pyhd8ed1ab_0    conda-forge
    pyopenssl                 20.0.1             pyhd8ed1ab_0    conda-forge
    pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
    pyqt                      5.12.3           py38h578d9bd_7    conda-forge
    pyqt-impl                 5.12.3           py38h7400c14_7    conda-forge
    pyqt5-sip                 4.19.18          py38h709712a_7    conda-forge
    pyqtchart                 5.12             py38h7400c14_7    conda-forge
    pyqtwebengine             5.12.1           py38h7400c14_7    conda-forge
    pyrsistent                0.17.3           py38h497a2fe_2    conda-forge
    pysocks                   1.7.1            py38h578d9bd_3    conda-forge
    python                    3.8.3                hcff3b4d_2    defaults
    python-dateutil           2.8.1                      py_0    conda-forge
    python-jsonrpc-server     0.4.0              pyh9f0ad1d_0    conda-forge
    python-language-server    0.36.2             pyhd8ed1ab_0    conda-forge
    python-libarchive-c       2.9              py38h578d9bd_2    conda-forge
    python-slugify            4.0.1              pyh9f0ad1d_0    conda-forge
    python_abi                3.8                      1_cp38    conda-forge
    pytz                      2021.1             pyhd8ed1ab_0    conda-forge
    pyxdg                     0.26                       py_0    conda-forge
    pyyaml                    5.4.1            py38h497a2fe_0    conda-forge
    pyzmq                     22.0.3           py38h2035c66_1    conda-forge
    qdarkstyle                3.0.2              pyhd8ed1ab_0    conda-forge
    qstylizer                 0.1.10             pyhd8ed1ab_0    conda-forge
    qt                        5.12.9               hda022c4_4    conda-forge
    qtawesome                 1.0.2              pyhd8ed1ab_0    conda-forge
    qtconsole                 5.0.3              pyhd8ed1ab_0    conda-forge
    qtpy                      1.9.0                      py_0    conda-forge
    readline                  8.0                  he28a2e2_2    conda-forge
    regex                     2021.4.4         py38h497a2fe_0    conda-forge
    reproc                    14.2.1               h36c2ea0_0    conda-forge
    reproc-cpp                14.2.1               h58526e2_0    conda-forge
    requests                  2.25.1             pyhd3deb0d_0    conda-forge
    ripgrep                   12.1.1               h516909a_1    conda-forge
    rope                      0.18.0             pyh9f0ad1d_0    conda-forge
    rtree                     0.9.7            py38h02d302b_1    conda-forge
    ruamel_yaml               0.15.80         py38h497a2fe_1004    conda-forge
    secretstorage             3.3.1            py38h578d9bd_0    conda-forge
    send2trash                1.5.0                      py_0    conda-forge
    setuptools                49.6.0           py38h578d9bd_3    conda-forge
    six                       1.15.0             pyh9f0ad1d_0    conda-forge
    sniffio                   1.2.0            py38h578d9bd_1    conda-forge
    snowballstemmer           2.1.0              pyhd8ed1ab_0    conda-forge
    sortedcontainers          2.3.0              pyhd8ed1ab_0    conda-forge
    soupsieve                 2.0.1                      py_1    conda-forge
    sphinx                    3.5.3              pyhd8ed1ab_0    conda-forge
    sphinxcontrib-applehelp   1.0.2                      py_0    conda-forge
    sphinxcontrib-devhelp     1.0.2                      py_0    conda-forge
    sphinxcontrib-htmlhelp    1.0.3                      py_0    conda-forge
    sphinxcontrib-jsmath      1.0.1                      py_0    conda-forge
    sphinxcontrib-qthelp      1.0.3                      py_0    conda-forge
    sphinxcontrib-serializinghtml 1.1.4                      py_0    conda-forge
    spyder                    5.0.1            py38h578d9bd_0    conda-forge
    spyder-kernels            2.0.1            py38h578d9bd_0    conda-forge
    spyder-notebook           0.1.4                      py_0    conda-forge
    sqlite                    3.35.4               h74cdb3f_0    conda-forge
    terminado                 0.9.4            py38h578d9bd_0    conda-forge
    testpath                  0.4.4                      py_0    conda-forge
    text-unidecode            1.3                        py_0    conda-forge
    textdistance              4.2.1              pyhd8ed1ab_0    conda-forge
    three-merge               0.1.1              pyh9f0ad1d_0    conda-forge
    tinycss                   0.4             pyhd8ed1ab_1002    conda-forge
    tk                        8.6.10               h21135ba_1    conda-forge
    toml                      0.10.2             pyhd8ed1ab_0    conda-forge
    tornado                   6.1              py38h497a2fe_1    conda-forge
    tqdm                      4.60.0             pyhd8ed1ab_0    conda-forge
    traitlets                 5.0.5                      py_0    conda-forge
    typed-ast                 1.4.3            py38h497a2fe_0    conda-forge
    typing_extensions         3.7.4.3                    py_0    conda-forge
    ujson                     4.0.2            py38h709712a_0    conda-forge
    unidecode                 1.2.0              pyhd8ed1ab_0    conda-forge
    urllib3                   1.26.4             pyhd8ed1ab_0    conda-forge
    watchdog                  1.0.2            py38h578d9bd_1    conda-forge
    wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
    webencodings              0.5.1                      py_1    conda-forge
    wheel                     0.36.2             pyhd3deb0d_0    conda-forge
    whichcraft                0.6.1                      py_0    conda-forge
    widgetsnbextension        3.5.1            py38h578d9bd_4    conda-forge
    wrapt                     1.12.1           py38h497a2fe_3    conda-forge
    wurlitzer                 2.1.0            py38h578d9bd_0    conda-forge
    xmltodict                 0.12.0                     py_0    conda-forge
    xorg-libxau               1.0.9                h7f98852_0    conda-forge
    xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
    xz                        5.2.5                h516909a_1    conda-forge
    yaml                      0.2.5                h516909a_0    conda-forge
    yapf                      0.30.0             pyh9f0ad1d_0    conda-forge
    zeromq                    4.3.4                h9c3ff4c_0    conda-forge
    zipp                      3.4.1              pyhd8ed1ab_0    conda-forge
    zlib                      1.2.11            h516909a_1010    conda-forge
    zstd                      1.4.9                ha95c52a_0    conda-forge
    (base) bjorn@bjorn-ThinkPad-T450s:~$ 

</details>
Hi @BjornFJohansson,

Can you please update to 5.0.2 and let us know if the error persists?
I updated and I can now restart the kernel. I do however get an error message:

Python 3.9.0 | packaged by conda-forge | (default, Nov 26 2020, 07:57:39)
Type "copyright", "credits" or "license" for more information.

IPython 7.18.1 -- An enhanced Interactive Python.

Restarting kernel... 


 
[SpyderKernelApp] WARNING | No such comm: 74f069acb30c11eb8d1368f7286a1381
[SpyderKernelApp] WARNING | No such comm: 74f069acb30c11eb8d1368f7286a1381
[SpyderKernelApp] WARNING | No such comm: 74f069acb30c11eb8d1368f7286a1381
[SpyderKernelApp] WARNING | No such comm: 74f069acb30c11eb8d1368f7286a1381

Does the message repeats constantly or only appears some times? 
It just repeats four times:

![image](https://user-images.githubusercontent.com/9726401/118080145-819c0080-b3b1-11eb-9919-539c39947137.png)

Ok, thanks for the update.

@impact27, do you have any ideas about this? I thought we were not displaying that warning anymore.
Just to confirm, when restarting the kernel I sometimes also get:

`[SpyderKernelApp] WARNING | No such comm`

Sometimes I don't get this print out, sometimes I get it print out once, and sometimes it's four identical print outs (as @BjornFJohansson reports). 

Spyder version: 5.0.3
@impact27, is there any way to avoid printing those warnings?
This happens on 5.0.3. It is only a minor annoyance and does not affect usability for me.
![image](https://user-images.githubusercontent.com/9726401/119468484-69779a00-bd3e-11eb-84d6-470adcc990e0.png)

> @impact27, is there any way to avoid printing those warnings?

Either remove https://github.com/ipython/ipykernel/blob/fda115626dd434f49a4d8f8e55080d5fd2c2e2b9/ipykernel/comm/manager.py#L68

or find the reason why the old comm is called.


@impact27, I followed your first suggestion in https://github.com/spyder-ide/spyder-kernels/pull/296

Resolving patch:
diff --git a/external-deps/spyder-kernels/spyder_kernels/console/kernel.py b/external-deps/spyder-kernels/spyder_kernels/console/kernel.py
--- a/external-deps/spyder-kernels/spyder_kernels/console/kernel.py
+++ b/external-deps/spyder-kernels/spyder_kernels/console/kernel.py
@@ -64,6 +64,7 @@ class SpyderKernel(IPythonKernel):
     def __init__(self, *args, **kwargs):
         super(SpyderKernel, self).__init__(*args, **kwargs)
 
+        self.comm_manager.get_comm = self._get_comm
         self.frontend_comm = FrontendComm(self)
 
         # All functions that can be called through the comm
@@ -839,3 +840,16 @@ def _load_wurlitzer(self):
                 get_ipython().run_line_magic('reload_ext', 'wurlitzer')
             except Exception:
                 pass
+
+    def _get_comm(self, comm_id):
+        """
+        We need to redefine this method from ipykernel.comm_manager to
+        avoid showing a warning when the comm corresponding to comm_id
+        is not present.
+
+        Fixes spyder-ide/spyder#15498
+        """
+        try:
+            return self.comm_manager.comms[comm_id]
+        except KeyError:
+            pass
diff --git a/external-deps/spyder-kernels/spyder_kernels/customize/spyderpdb.py b/external-deps/spyder-kernels/spyder_kernels/customize/spyderpdb.py
--- a/external-deps/spyder-kernels/spyder_kernels/customize/spyderpdb.py
+++ b/external-deps/spyder-kernels/spyder_kernels/customize/spyderpdb.py
@@ -511,7 +511,19 @@ def do_debug(self, arg):
         argument (which is an arbitrary expression or statement to be
         executed in the current environment).
         """
-        super(SpyderPdb, self).do_debug(arg)
+        try:
+            super(SpyderPdb, self).do_debug(arg)
+        except Exception:
+            if PY2:
+                t, v = sys.exc_info()[:2]
+                if type(t) == type(''):
+                    exc_type_name = t
+                else: exc_type_name = t.__name__
+                print >>self.stdout, '***', exc_type_name + ':', v
+            else:
+                exc_info = sys.exc_info()[:2]
+                self.error(
+                    traceback.format_exception_only(*exc_info)[-1].strip())
         kernel = get_ipython().kernel
         kernel._register_pdb_session(self)
 


Test patch: