If we fail to import doctest.UnexpectedException during postmortem, fail quietly and continue

This commit is contained in:
Brian Maissy 2018-01-25 22:28:27 +02:00
parent ff90c9e237
commit 2a1b1107c5
2 changed files with 12 additions and 7 deletions

View File

@ -95,12 +95,16 @@ def _enter_pdb(node, excinfo, rep):
def _postmortem_traceback(excinfo): def _postmortem_traceback(excinfo):
# A doctest.UnexpectedException is not useful for post_mortem. try:
# Use the underlying exception instead:
from doctest import UnexpectedException from doctest import UnexpectedException
if isinstance(excinfo.value, UnexpectedException): if isinstance(excinfo.value, UnexpectedException):
# A doctest.UnexpectedException is not useful for post_mortem.
# Use the underlying exception instead:
return excinfo.value.exc_info[2] return excinfo.value.exc_info[2]
else: except ImportError:
# If we fail to import, continue quietly (if we ran out of file descriptors, for example: #1810)
pass
return excinfo._excinfo[2] return excinfo._excinfo[2]

1
changelog/1810.bugfix Normal file
View File

@ -0,0 +1 @@
If we fail to import doctest.UnexpectedException during postmortem, fail quietly and continue.