code: def test_close_and_throw_raise_generator_exit(self):
      yielded_first = object()
      yielded_second = object()
      returned = object()
  
      def inner():
          try:
              yield yielded_first
              yield yielded_second
              return returned
          finally:
              raise raised
  
      def outer():
          return (yield from inner())
  
      with self.subTest("close"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          raised = GeneratorExit()
          # GeneratorExit is suppressed. This is consistent with PEP 342:
          # https://peps.python.org/pep-0342/#new-generator-method-close
          g.close()
          self.assert_stop_iteration(g)
  
      with self.subTest("throw GeneratorExit"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          raised = GeneratorExit()
          thrown = GeneratorExit()
          with self.assertRaises(GeneratorExit) as caught:
              g.throw(thrown)
          # The raised GeneratorExit is suppressed, but the thrown one
          # propagates. This is consistent with PEP 380:
          # https://peps.python.org/pep-0380/#proposal
          self.assertIs(caught.exception, thrown)
          self.assertIsNone(caught.exception.__context__)
          self.assert_stop_iteration(g)
  
      with self.subTest("throw StopIteration"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          raised = GeneratorExit()
          thrown = StopIteration()
          with self.assertRaises(GeneratorExit) as caught:
              g.throw(thrown)
          self.assertIs(caught.exception, raised)
          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)
          raised = GeneratorExit()
          thrown = BaseException()
          with self.assertRaises(GeneratorExit) as caught:
              g.throw(thrown)
          self.assertIs(caught.exception, raised)
          self.assertIs(caught.exception.__context__, thrown)
          self.assertIsNone(caught.exception.__context__.__context__)
          self.assert_stop_iteration(g)
  
      with self.subTest("throw Exception"):
          g = outer()
          self.assertIs(next(g), yielded_first)
          raised = GeneratorExit()
          thrown = Exception()
          with self.assertRaises(GeneratorExit) as caught:
              g.throw(thrown)
          self.assertIs(caught.exception, raised)
          self.assertIs(caught.exception.__context__, thrown)
          self.assertIsNone(caught.exception.__context__.__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 5 for calling the TestInterestingEdgeCases obj's underlying member method code with example usage: obj.test_close_and_throw_raise_generator_exit() and returns: unknown, returned