code: def test_robust_error_on_ast_corruption(self):
      # A child class should not be able to be so broken that it causes the error
      # handling in `transformer.Base` to raise an exception.  Why not?  Because
      # then the original error location is dropped, and an error handler higher
      # up in the call stack gives misleading information.
  
      # Here we test that the error handling in `visit` completes, and blames the
      # correct original exception, even if the AST gets corrupted.
  
      class NotANode(object):
          pass
  
      class BrokenTransformer(transformer.Base):
          def visit_If(self, node):
              node.body = NotANode()
              raise ValueError("I blew up")
  
      def test_function(x):
          if x > 0:
              return x
  
      tr = BrokenTransformer(self._simple_context())
  
      node, _ = parser.parse_entity(test_function, future_features=())
      with self.assertRaises(ValueError) as cm:
          node = tr.visit(node)
      obtained_message = str(cm.exception)
      # The message should reference the exception actually raised, not anything
      # from the exception handler.
      expected_substring = "I blew up"
      self.assertIn(expected_substring, obtained_message)
  
imports: import re
  import gast
  from tensorflow.python.autograph.pyct import anno
  from tensorflow.python.autograph.pyct import origin_info
  from tensorflow.python.autograph.pyct import parser
  from tensorflow.python.autograph.pyct import transformer
  from tensorflow.python.platform import test
label_desc: Use image node_id 8 for calling the TransformerTest obj's underlying member method code with example usage: obj.test_robust_error_on_ast_corruption() and returns: x