code: def test_close_and_throw_yield(self):
      yielded_first = object()
      yielded_second = object()
      returned = object()
  
      def inner():
          try:
              yield yielded_first
          finally:
              yield yielded_second
          return returned
  
      def outer():
          return (yield from inner())
  
      with self.subTest("close"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          # No chaining happens. This is consistent with PEP 342:
          # https://peps.python.org/pep-0342/#new-generator-method-close
          with self.assert_generator_ignored_generator_exit() as caught:
              g.close()
          self.assertIsNone(caught.exception.__context__)
          self.assert_stop_iteration(g)
  
      with self.subTest("throw GeneratorExit"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          thrown = GeneratorExit()
          # No chaining happens. This is consistent with PEP 342:
          # https://peps.python.org/pep-0342/#new-generator-method-close
          with self.assert_generator_ignored_generator_exit() as caught:
              g.throw(thrown)
          self.assertIsNone(caught.exception.__context__)
          self.assert_stop_iteration(g)
  
      with self.subTest("throw StopIteration"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          thrown = StopIteration()
          self.assertEqual(g.throw(thrown), yielded_second)
          # PEP 479:
          with self.assert_generator_raised_stop_iteration() as caught:
              next(g)
          self.assertIs(caught.exception.__context__, thrown)
          self.assertIsNone(caught.exception.__context__.__context__)
          self.assert_stop_iteration(g)
  
      with self.subTest("throw BaseException"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          thrown = BaseException()
          self.assertEqual(g.throw(thrown), yielded_second)
          with self.assertRaises(BaseException) as caught:
              next(g)
          self.assertIs(caught.exception, thrown)
          self.assertIsNone(caught.exception.__context__)
          self.assert_stop_iteration(g)
  
      with self.subTest("throw Exception"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          thrown = Exception()
          self.assertEqual(g.throw(thrown), yielded_second)
          with self.assertRaises(Exception) as caught:
              next(g)
          self.assertIs(caught.exception, thrown)
          self.assertIsNone(caught.exception.__context__)
          self.assert_stop_iteration(g)
  
imports: import unittest
  import inspect
  from test.support import captured_stderr, disable_gc, gc_collect
  from test import support
label_desc: Use image node_id 9 for calling the TestInterestingEdgeCases obj's underlying member method code with example usage: obj.test_close_and_throw_yield() and returns: returned, unknown