mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
gh-117459: Keep the traceback in _convert_future_exc (#117460)
This commit is contained in:
parent
b4fe02f595
commit
85843348c5
3 changed files with 22 additions and 4 deletions
|
@ -5,6 +5,7 @@ import gc
|
|||
import re
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from types import GenericAlias
|
||||
|
@ -416,6 +417,24 @@ class BaseFutureTests:
|
|||
_copy_future_state(f_cancelled, newf_cancelled)
|
||||
self.assertTrue(newf_cancelled.cancelled())
|
||||
|
||||
try:
|
||||
raise concurrent.futures.InvalidStateError
|
||||
except BaseException as e:
|
||||
f_exc = e
|
||||
|
||||
f_conexc = self._new_future(loop=self.loop)
|
||||
f_conexc.set_exception(f_exc)
|
||||
|
||||
newf_conexc = self._new_future(loop=self.loop)
|
||||
_copy_future_state(f_conexc, newf_conexc)
|
||||
self.assertTrue(newf_conexc.done())
|
||||
try:
|
||||
newf_conexc.result()
|
||||
except BaseException as e:
|
||||
newf_exc = e # assertRaises context manager drops the traceback
|
||||
newf_tb = ''.join(traceback.format_tb(newf_exc.__traceback__))
|
||||
self.assertEqual(newf_tb.count('raise concurrent.futures.InvalidStateError'), 1)
|
||||
|
||||
def test_iter(self):
|
||||
fut = self._new_future(loop=self.loop)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue