Skip to content

Commit 5e7f10b

Browse files
committed
Fix test case and add explanation in comment
1 parent a879a9f commit 5e7f10b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Lib/test/test_sys.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,16 @@ def outer():
244244
self.assertIsInstance(sys.exception(), ValueError)
245245
self.assertIsInstance(sys.exception().__context__, TypeError)
246246
yield next(g)
247+
# at this point the TypeError from the caller has been handled
248+
# by the caller's except block. Even still, it should still by
249+
# referenced as the __context__ of the current exception.
247250
self.assertIsInstance(sys.exception(), ValueError)
248-
self.assertIsInstance(sys.exception(), TypeError)
251+
self.assertIsInstance(sys.exception().__context__, TypeError)
252+
# not handling an exception, caller isn't anymore either
253+
self.assertIsNone(sys.exception())
254+
with self.assertRaises(StopIteration):
255+
next(g)
256+
self.assertIsNone(sys.exception())
249257

250258
g = outer()
251259
next(g)

0 commit comments

Comments
 (0)