Skip to content

Commit bbf0086

Browse files
committed
gh-135736: Fix test_taskgroup_20f to use KeyboardInterrupt, not a custom BaseException
TaskGroup._is_base_error() only recognizes SystemExit and KeyboardInterrupt (GeneratorExit is handled separately); an arbitrary BaseException subclass like MyBaseExc never sets self._base_error, so it takes the BaseExceptionGroup-wrapping path instead of the direct-raise path this test meant to exercise, causing CI failures across all platforms. Use KeyboardInterrupt (matching the existing test_taskgroup_20) instead.
1 parent f878aeb commit bbf0086

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Lib/test/test_asyncio/test_taskgroups.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,12 @@ async def runner():
690690
self.assertEqual(get_error_types(cm.exception), {GeneratorExit})
691691

692692
async def test_taskgroup_20f(self):
693-
# See gh-135736: a *non*-GeneratorExit base error (here MyBaseExc,
694-
# standing in for SystemExit/KeyboardInterrupt) must also report a
695-
# sibling task's suppressed exception via the loop's exception
696-
# handler, the same as the GeneratorExit case in
697-
# test_taskgroup_20c, instead of discarding it silently.
693+
# Same setup as test_taskgroup_20 (a KeyboardInterrupt from the
694+
# "async with" body itself, alongside a sibling task's exception),
695+
# but confirms the gh-135736 fix also applies to non-GeneratorExit
696+
# base errors: the sibling's exception must be reported via the
697+
# loop's exception handler, the same as test_taskgroup_20c, instead
698+
# of being discarded silently.
698699
async def crash_soon():
699700
await asyncio.sleep(0.1)
700701
1 / 0
@@ -703,7 +704,7 @@ async def nested():
703704
try:
704705
await asyncio.sleep(10)
705706
finally:
706-
raise MyBaseExc
707+
raise KeyboardInterrupt
707708

708709
async def runner():
709710
async with taskgroups.TaskGroup() as g:
@@ -714,7 +715,7 @@ async def runner():
714715
loop = asyncio.get_running_loop()
715716
loop.set_exception_handler(lambda loop, context: contexts.append(context))
716717

717-
with self.assertRaises(MyBaseExc):
718+
with self.assertRaises(KeyboardInterrupt):
718719
await runner()
719720

720721
self.assertEqual(len(contexts), 1)

0 commit comments

Comments
 (0)