Issue #28076: Variable annotations should be mangled for private names.

By Ivan Levkivskyi.
This commit is contained in:
Guido van Rossum 2016-09-11 09:45:24 -07:00
parent a6d75fdc37
commit 015d874626
3 changed files with 13 additions and 6 deletions

View file

@ -328,12 +328,12 @@ class GrammarTests(unittest.TestCase):
# class semantics
class C:
x: int
__foo: int
s: str = "attr"
z = 2
def __init__(self, x):
self.x: int = x
self.assertEqual(C.__annotations__, {'x': int, 's': str})
self.assertEqual(C.__annotations__, {'_C__foo': int, 's': str})
with self.assertRaises(NameError):
class CBad:
no_such_name_defined.attr: int = 0