never retain a generator's caller's exception state on the generator after a yield/return

This requires some trickery to properly save the exception state if the
generator creates its own exception state.
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index ad9a19e..46ddc82 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -581,6 +581,18 @@
             pass
         self.assertEqual(sys.exc_info(), (None, None, None))
 
+    def test_generator_doesnt_retain_old_exc(self):
+        def g():
+            self.assertIsInstance(sys.exc_info()[1], RuntimeError)
+            yield
+            self.assertEqual(sys.exc_info(), (None, None, None))
+        it = g()
+        try:
+            raise RuntimeError
+        except RuntimeError:
+            next(it)
+        self.assertRaises(StopIteration, next, it)
+
     def test_generator_finalizing_and_exc_info(self):
         # See #7173
         def simple_gen():