Author: Armin Rigo <ar...@tunes.org>
Branch: py3.5
Changeset: r88838:5eca897303d3
Date: 2016-12-03 09:04 +0100
http://bitbucket.org/pypy/pypy/changeset/5eca897303d3/

Log:    __annotations__ takes keys that are mangled parameter names

diff --git a/pypy/interpreter/astcompiler/codegen.py 
b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -345,7 +345,7 @@
     def _visit_arg_annotation(self, name, ann, names):
         if ann:
             ann.walkabout(self)
-            names.append(name)
+            names.append(self.scope.mangle(name))
 
     def _visit_arg_annotations(self, args, names):
         if args:
diff --git a/pypy/interpreter/test/test_function.py 
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -60,6 +60,13 @@
         f.__annotations__ = ann
         assert f.__annotations__ is ann
 
+    def test_annotations_mangle(self): """
+        class X:
+            def foo(self, __a:5, b:6):
+                pass
+        assert X.foo.__annotations__ == {'_X__a': 5, 'b': 6}
+        """
+
     def test_kwdefaults(self):
         """
         def f(*, kw=3): return kw
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to