use %R format code; fixes invalid dereferencing #10391
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index b5295ef..75af646 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -197,6 +197,13 @@
                     ast2 = mod.loads(mod.dumps(ast, protocol))
                     self.assertEquals(to_tuple(ast2), to_tuple(ast))
 
+    def test_invalid_sum(self):
+        pos = dict(lineno=2, col_offset=3)
+        m = ast.Module([ast.Expr(ast.expr(**pos), **pos)])
+        with self.assertRaises(TypeError) as cm:
+            compile(m, "<test>", "exec")
+        self.assertIn("but got <_ast.expr", str(cm.exception))
+
 
 class ASTHelpers_Test(unittest.TestCase):