class_docstr: Test semantics.
class_docstr_tok: ["Test","semantics","."]
docstr: Test throwing GeneratorExit into a subgenerator that
  catches it and raises a different exception.
docstr_tok: ["Test","throwing","GeneratorExit","into","a","subgenerator","that","catches","it","and","raises","a","different","exception","."]
code: def test_throwing_GeneratorExit_into_subgen_that_raises(self):
      """
      Test throwing GeneratorExit into a subgenerator that
      catches it and raises a different exception.
      """
      trace = []
  
      def f():
          try:
              trace.append("Enter f")
              yield
              trace.append("Exit f")
          except GeneratorExit:
              raise ValueError("Vorpal bunny encountered")
  
      def g():
          trace.append("Enter g")
          yield from f()
          trace.append("Exit g")
  
      try:
          gi = g()
          next(gi)
          gi.throw(GeneratorExit)
      except ValueError as e:
          self.assertEqual(e.args[0], "Vorpal bunny encountered")
          self.assertIsInstance(e.__context__, GeneratorExit)
      else:
          self.fail("subgenerator failed to raise ValueError")
      self.assertEqual(
          trace,
          [
              "Enter g",
              "Enter f",
          ],
      )
  
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 27 for calling the TestPEP380Operation obj's underlying member method code with example usage: obj.test_throwing_GeneratorExit_into_subgen_that_raises() without return types