Skip to content

Commit 59ef993

Browse files
committed
Fix test case and add explanation in comment
1 parent bbc212b commit 59ef993

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎Lib/test/test_sys.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,16 @@ def outer():
263263
self.assertIsInstance(sys.exception(), ValueError)
264264
self.assertIsInstance(sys.exception().__context__, TypeError)
265265
yield next(g)
266+
# at this point the TypeError from the caller has been handled
267+
# by the caller's except block. Even still, it should still be
268+
# referenced as the __context__ of the current exception.
266269
self.assertIsInstance(sys.exception(), ValueError)
267-
self.assertIsInstance(sys.exception(), TypeError)
270+
self.assertIsInstance(sys.exception().__context__, TypeError)
271+
# not handling an exception, caller isn't handling one either
272+
self.assertIsNone(sys.exception())
273+
with self.assertRaises(StopIteration):
274+
next(g)
275+
self.assertIsNone(sys.exception())
268276

269277
g = outer()
270278
next(g)

0 commit comments

Comments
 (0)