Repository: spyder-ide/spyder

Issue:
Issue reporter raises AttributeError upon dismissing
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

1. Open internal console
2. Manually raise exception, e.g. `raise Exception()`
3. Click "Close" button of resulting Issue reporter dialogue

### Traceback
```python-traceback
Traceback (most recent call last):
  File "/Users/rclary/Documents/Repos/Spyder-IDE/spyder/spyder/plugins/console/widgets/main_widget.py", line 461, in close_error_dlg
    if self.error_dlg.dismiss_box.isChecked():
AttributeError: 'NoneType' object has no attribute 'dismiss_box'
```

## Versions

* Spyder version: 5.4.0.dev0 49f209d50 (conda)
* Python version: 3.10.5 64-bit
* Qt version: 5.15.4
* PyQt5 version: 5.15.7
* Operating System: Darwin 20.6.0

### Dependencies

```
# Mandatory:
applaunchservices >=0.3.0     :  0.3.0 (OK)
atomicwrites >=1.2.0          :  1.4.1 (OK)
chardet >=2.0.0               :  5.0.0 (OK)
cloudpickle >=0.5.0           :  2.1.0 (OK)
cookiecutter >=1.6.0          :  2.1.1 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.0.2 (OK)
IPython >=7.31.1;<8.0.0       :  7.33.0 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jellyfish >=0.7               :  0.9.0 (OK)
jsonschema >=3.2.0            :  4.6.2 (OK)
keyring >=17.0.0              :  23.6.0 (OK)
nbconvert >=4.0               :  6.5.0 (OK)
numpydoc >=0.6.0              :  1.4.0 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.9.1 (OK)
pygments >=2.0                :  2.12.0 (OK)
pylint >=2.5.0;<3.0           :  2.14.4 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.4.1;<1.5.0          :  1.4.1 (OK)
pylsp_black >=1.2.0           :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0     :  3.0.3 (OK)
qstylizer >=0.1.10            :  0.2.1 (OK)
qtawesome >=1.0.2             :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0      :  5.4.0.dev0 (OK)
qtpy >=2.1.0                  :  2.1.0 (OK)
rtree >=0.9.7                 :  1.0.0 (OK)
setuptools >=49.6.0           :  63.1.0 (OK)
sphinx >=0.6.6                :  5.0.2 (OK)
spyder_kernels >=2.3.1;<2.4.0 :  2.4.0.dev0 (OK)
textdistance >=4.2.0          :  4.3.0 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.9 (OK)
zmq >=22.1.0                  :  23.2.0 (OK)

# Optional:
cython >=0.21                 :  0.29.30 (OK)
matplotlib >=3.0.0            :  3.5.2 (OK)
numpy >=1.7                   :  1.23.0 (OK)
pandas >=1.1.1                :  1.4.3 (OK)
scipy >=0.17.0                :  1.8.1 (OK)
sympy >=0.7.3                 :  1.10.1 (OK)
```

### Environment

<details><summary>Environment</summary>

```
# packages in environment at /Users/rclary/opt/mambaforge/envs/spy-dev:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                     py_0    conda-forge
applaunchservices         0.3.0              pyhd8ed1ab_2    conda-forge
appnope                   0.1.3              pyhd8ed1ab_0    conda-forge
arrow                     1.2.2              pyhd8ed1ab_0    conda-forge
astroid                   2.11.6          py310h2ec42d9_0    conda-forge
atomicwrites              1.4.1              pyhd8ed1ab_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
autopep8                  1.6.0              pyhd8ed1ab_1    conda-forge
babel                     2.10.3             pyhd8ed1ab_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
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
binaryornot               0.4.4                      py_1    conda-forge
black                     22.6.0             pyhd8ed1ab_0    conda-forge
bleach                    5.0.1              pyhd8ed1ab_0    conda-forge
brotli                    1.0.9                h5eb16cf_7    conda-forge
brotli-bin                1.0.9                h5eb16cf_7    conda-forge
brotlipy                  0.7.0           py310h1961e1f_1004    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
ca-certificates           2022.6.15            h033912b_0    conda-forge
certifi                   2022.6.15       py310h2ec42d9_0    conda-forge
cffi                      1.15.1          py310h96bbf6e_0    conda-forge
chardet                   5.0.0           py310h2ec42d9_0    conda-forge
charset-normalizer        2.1.0              pyhd8ed1ab_0    conda-forge
click                     8.1.3           py310h2ec42d9_0    conda-forge
cloudpickle               2.1.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.5              pyhd8ed1ab_0    conda-forge
cookiecutter              2.1.1              pyh6c4a22f_0    conda-forge
coverage                  6.4.1           py310h6c45266_0    conda-forge
cryptography              37.0.4          py310h52c3658_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
cython                    0.29.30         py310hd4537e4_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
debugpy                   1.6.0           py310h9d931ec_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
diff-match-patch          20200713           pyh9f0ad1d_0    conda-forge
dill                      0.3.5.1            pyhd8ed1ab_0    conda-forge
docutils                  0.18.1          py310h2ec42d9_1    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
flake8                    4.0.1              pyhd8ed1ab_2    conda-forge
flaky                     3.7.0              pyh9f0ad1d_0    conda-forge
fonttools                 4.34.4          py310h6c45266_0    conda-forge
freetype                  2.10.4               h4cff582_1    conda-forge
gettext                   0.19.8.1          hd1a6beb_1008    conda-forge
giflib                    5.2.1                hbcb3906_2    conda-forge
glib                      2.70.2               hcf210ce_4    conda-forge
glib-tools                2.70.2               hcf210ce_4    conda-forge
gmp                       6.2.1                h2e338ed_0    conda-forge
gmpy2                     2.1.2           py310hf5ec7bd_0    conda-forge
gst-plugins-base          1.20.3               hda0ba4b_0    conda-forge
gstreamer                 1.20.3               hdc08c3f_0    conda-forge
icu                       70.1                 h96cf925_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
imagesize                 1.4.1              pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.4          py310h2ec42d9_0    conda-forge
importlib_resources       5.8.0              pyhd8ed1ab_0    conda-forge
inflection                0.5.1              pyh9f0ad1d_0    conda-forge
iniconfig                 1.1.1              pyh9f0ad1d_0    conda-forge
intervaltree              3.0.2                      py_0    conda-forge
ipykernel                 6.15.1             pyh736e0ef_0    conda-forge
ipython                   7.33.0          py310h2ec42d9_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
isort                     5.10.1             pyhd8ed1ab_0    conda-forge
jedi                      0.18.1          py310h2ec42d9_1    conda-forge
jellyfish                 0.9.0           py310h1961e1f_1    conda-forge
jinja2                    3.0.3              pyhd8ed1ab_0    conda-forge
jinja2-time               0.2.0              pyhd8ed1ab_3    conda-forge
jpeg                      9e                   hac89ed1_2    conda-forge
jsonschema                4.6.2              pyhd8ed1ab_0    conda-forge
jupyter_client            7.3.4              pyhd8ed1ab_0    conda-forge
jupyter_core              4.10.0          py310h2ec42d9_0    conda-forge
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
keyring                   23.6.0          py310h2ec42d9_0    conda-forge
kiwisolver                1.4.3           py310habb735a_0    conda-forge
krb5                      1.19.3               hb49756b_0    conda-forge
lazy-object-proxy         1.7.1           py310h1961e1f_1    conda-forge
lcms2                     2.12                 h577c468_0    conda-forge
lerc                      3.0                  he49afe7_0    conda-forge
libblas                   3.9.0           15_osx64_openblas    conda-forge
libbrotlicommon           1.0.9                h5eb16cf_7    conda-forge
libbrotlidec              1.0.9                h5eb16cf_7    conda-forge
libbrotlienc              1.0.9                h5eb16cf_7    conda-forge
libcblas                  3.9.0           15_osx64_openblas    conda-forge
libclang                  14.0.6          default_h55ffa42_0    conda-forge
libclang13                14.0.6          default_hb5731bd_0    conda-forge
libcxx                    14.0.6               hce7ea42_0    conda-forge
libdeflate                1.12                 hac89ed1_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libgfortran               5.0.0           9_3_0_h6c81a4c_23    conda-forge
libgfortran5              9.3.0               h6c81a4c_23    conda-forge
libglib                   2.70.2               hf1fb8c0_4    conda-forge
libiconv                  1.16                 haf1e3a3_0    conda-forge
liblapack                 3.9.0           15_osx64_openblas    conda-forge
libllvm14                 14.0.6               h41df66c_0    conda-forge
libogg                    1.3.4                h35c211d_1    conda-forge
libopenblas               0.3.20          openmp_hb3cd9ec_0    conda-forge
libopus                   1.3.1                hc929b4f_1    conda-forge
libpng                    1.6.37               h5a3d3bf_3    conda-forge
libpq                     14.4                 hf6bb32a_0    conda-forge
libsodium                 1.0.18               hbcb3906_1    conda-forge
libspatialindex           1.9.3                he49afe7_4    conda-forge
libtiff                   4.4.0                h9847915_1    conda-forge
libvorbis                 1.3.7                h046ec9c_0    conda-forge
libwebp                   1.2.2                h28dabe5_0    conda-forge
libwebp-base              1.2.2                h0d85af4_1    conda-forge
libxcb                    1.13              h0d85af4_1004    conda-forge
libzlib                   1.2.12               hfe4f2af_1    conda-forge
llvm-openmp               14.0.4               ha654fa7_0    conda-forge
lz4-c                     1.9.3                he49afe7_1    conda-forge
markupsafe                2.1.1           py310h1961e1f_1    conda-forge
matplotlib                3.5.2           py310h2ec42d9_0    conda-forge
matplotlib-base           3.5.2           py310h4510841_0    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mccabe                    0.6.1                      py_1    conda-forge
mistune                   0.8.4           py310he24745e_1005    conda-forge
mpc                       1.2.1                hbb51d92_0    conda-forge
mpfr                      4.1.0                h0f52abe_1    conda-forge
mpmath                    1.2.1              pyhd8ed1ab_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
mypy_extensions           0.4.3           py310h2ec42d9_5    conda-forge
mysql-common              8.0.29               h924029e_1    conda-forge
mysql-libs                8.0.29               h3cab752_1    conda-forge
nbclient                  0.6.6              pyhd8ed1ab_0    conda-forge
nbconvert                 6.5.0              pyhd8ed1ab_0    conda-forge
nbconvert-core            6.5.0              pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          6.5.0              pyhd8ed1ab_0    conda-forge
nbformat                  5.4.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h96cf925_1    conda-forge
nest-asyncio              1.5.5              pyhd8ed1ab_0    conda-forge
nspr                      4.32                 hcd9eead_1    conda-forge
nss                       3.78                 ha8197d3_0    conda-forge
numpy                     1.23.0          py310ha3f357c_0    conda-forge
numpydoc                  1.4.0              pyhd8ed1ab_0    conda-forge
openjpeg                  2.4.0                h6e7aa92_1    conda-forge
openssl                   1.1.1q               hfe4f2af_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.4.3           py310h3099161_0    conda-forge
pandoc                    2.18                 h694c41f_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pathspec                  0.9.0              pyhd8ed1ab_0    conda-forge
pcre                      8.45                 he49afe7_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    9.2.0           py310hb3240ae_0    conda-forge
pip                       22.1.2             pyhd8ed1ab_0    conda-forge
platformdirs              2.5.1              pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0           py310h2ec42d9_3    conda-forge
ply                       3.11                       py_1    conda-forge
prompt-toolkit            3.0.30             pyha770c72_0    conda-forge
psutil                    5.9.1           py310h6c45266_0    conda-forge
pthread-stubs             0.4               hc929b4f_1001    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
py                        1.11.0             pyh6c4a22f_0    conda-forge
pycodestyle               2.8.0              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pydocstyle                6.1.1              pyhd8ed1ab_0    conda-forge
pyflakes                  2.4.0              pyhd8ed1ab_0    conda-forge
pygments                  2.12.0             pyhd8ed1ab_0    conda-forge
pylint                    2.14.4             pyhd8ed1ab_0    conda-forge
pyls-spyder               0.4.0              pyhd8ed1ab_0    conda-forge
pyobjc-core               8.5             py310h209c1a4_0    conda-forge
pyobjc-framework-cocoa    8.5             py310h209c1a4_0    conda-forge
pyobjc-framework-coreservices 8.5             py310h6c45266_1    conda-forge
pyobjc-framework-fsevents 8.5             py310h2ec42d9_1    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyqt                      5.15.7          py310h57cebac_0    conda-forge
pyqt5-sip                 12.11.0                  pypi_0    pypi
pyqtwebengine             5.15.7          py310h57cebac_0    conda-forge
pyrsistent                0.18.1          py310h1961e1f_1    conda-forge
pysocks                   1.7.1           py310h2ec42d9_5    conda-forge
pytest                    6.2.5           py310h2ec42d9_2    conda-forge
pytest-cov                3.0.0              pyhd8ed1ab_0    conda-forge
pytest-lazy-fixture       0.6.3                      py_0    conda-forge
pytest-mock               3.8.2              pyhd8ed1ab_0    conda-forge
pytest-order              1.0.1              pyhd8ed1ab_0    conda-forge
pytest-qt                 4.1.0              pyhd8ed1ab_0    conda-forge
pytest-timeout            2.1.0              pyhd8ed1ab_0    conda-forge
python                    3.10.5          hdaaf3db_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.15.3             pyhd8ed1ab_0    conda-forge
python-lsp-black          1.2.1              pyhd8ed1ab_0    conda-forge
python-lsp-jsonrpc        1.0.0              pyhd8ed1ab_0    conda-forge
python-lsp-server         1.4.1                     dev_0    <develop>
python-slugify            6.1.2              pyhd8ed1ab_0    conda-forge
python.app                1.4             py310he24745e_0    conda-forge
python_abi                3.10                    2_cp310    conda-forge
pytoolconfig              1.2.1              pyhd8ed1ab_0    conda-forge
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py310h1961e1f_4    conda-forge
pyzmq                     23.2.0          py310h85fb675_0    conda-forge
qdarkstyle                3.0.3                     dev_0    <develop>
qstylizer                 0.2.1              pyhd8ed1ab_0    conda-forge
qt-main                   5.15.4               h938c29d_2    conda-forge
qt-webengine              5.15.4               h72ca1e5_3    conda-forge
qtawesome                 1.1.1              pyhd8ed1ab_0    conda-forge
qtconsole                 5.4.0.dev0                dev_0    <develop>
qtpy                      2.1.0              pyhd8ed1ab_0    conda-forge
readline                  8.1.2                h3899abd_0    conda-forge
requests                  2.28.1             pyhd8ed1ab_0    conda-forge
rope                      1.2.0              pyhd8ed1ab_0    conda-forge
rtree                     1.0.0           py310had9ce37_1    conda-forge
scipy                     1.8.1           py310h1f9c157_0    conda-forge
setuptools                63.1.0          py310h2ec42d9_0    conda-forge
sip                       6.6.2           py310hd4537e4_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snowballstemmer           2.2.0              pyhd8ed1ab_0    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sphinx                    5.0.2              pyh6c4a22f_0    conda-forge
sphinxcontrib-applehelp   1.0.2                      py_0    conda-forge
sphinxcontrib-devhelp     1.0.2                      py_0    conda-forge
sphinxcontrib-htmlhelp    2.0.0              pyhd8ed1ab_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.5              pyhd8ed1ab_2    conda-forge
spyder                    5.4.0.dev0                dev_0    <develop>
spyder-kernels            2.4.0.dev0                dev_0    <develop>
sqlite                    3.39.0               hd9f0692_0    conda-forge
sympy                     1.10.1          py310h2ec42d9_0    conda-forge
text-unidecode            1.3                        py_0    conda-forge
textdistance              4.3.0              pyhd8ed1ab_0    conda-forge
three-merge               0.1.1              pyh9f0ad1d_0    conda-forge
tinycss2                  1.1.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h5dbffcc_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tomlkit                   0.11.1             pyha770c72_0    conda-forge
tornado                   6.2             py310h6c45266_0    conda-forge
traitlets                 5.3.0              pyhd8ed1ab_0    conda-forge
typed-ast                 1.5.4           py310h6c45266_0    conda-forge
typing                    3.10.0.0           pyhd8ed1ab_0    conda-forge
typing-extensions         4.3.0                hd8ed1ab_0    conda-forge
typing_extensions         4.3.0              pyha770c72_0    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
ujson                     5.3.0           py310hd4537e4_0    conda-forge
unicodedata2              14.0.0          py310h1961e1f_1    conda-forge
unidecode                 1.3.4              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.10            pyhd8ed1ab_0    conda-forge
watchdog                  2.1.9           py310h5027ba8_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
wrapt                     1.14.1          py310h6c45266_0    conda-forge
wurlitzer                 3.0.2              pyhd8ed1ab_2    conda-forge
xorg-libxau               1.0.9                h35c211d_0    conda-forge
xorg-libxdmcp             1.1.3                h35c211d_0    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
yaml                      0.2.5                h0d85af4_2    conda-forge
yapf                      0.32.0             pyhd8ed1ab_0    conda-forge
zeromq                    4.3.4                he49afe7_1    conda-forge
zipp                      3.8.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.12               hfe4f2af_1    conda-forge
zstd                      1.5.2                ha9df2e0_2    conda-forge

```
</details>



Discussion:
I can reproduce this error @mrclary and will take care of it for 5.3.2

Resolving patch:
diff --git a/spyder/plugins/console/widgets/main_widget.py b/spyder/plugins/console/widgets/main_widget.py
--- a/spyder/plugins/console/widgets/main_widget.py
+++ b/spyder/plugins/console/widgets/main_widget.py
@@ -429,7 +429,6 @@ def handle_exception(self, error_data, sender=None):
                 self.error_dlg = SpyderErrorDialog(self)
                 self.error_dlg.set_color_scheme(
                     self.get_conf('selected', section='appearance'))
-                self.error_dlg.close_btn.clicked.connect(self.close_error_dlg)
                 self.error_dlg.rejected.connect(self.remove_error_dlg)
                 self.error_dlg.details.sig_go_to_error_requested.connect(
                     self.go_to_error)
@@ -458,15 +457,16 @@ def close_error_dlg(self):
         """
         Close error dialog.
         """
-        if self.error_dlg.dismiss_box.isChecked():
-            self.dismiss_error = True
-
-        self.error_dlg.reject()
+        if self.error_dlg:
+            self.error_dlg.reject()
 
     def remove_error_dlg(self):
         """
         Remove error dialog.
         """
+        if self.error_dlg.dismiss_box.isChecked():
+            self.dismiss_error = True
+
         self.error_dlg.disconnect()
         self.error_dlg = None
 


Test patch: