gh-102799: use sys.exception() instead of sys.exc_info() in tests by iritkatriel · Pull Request #103293 · python/cpython
Why add the isinstance() call? The original test insists that you get exactly CancelledError. I think that's useful to test for, since not all cancellation code is resilient to subclasses of CancelledError.
(In other cases below I don't mind.)