mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Issue #28076: Variable annotations should be mangled for private names.
By Ivan Levkivskyi.
This commit is contained in:
parent
a6d75fdc37
commit
015d874626
3 changed files with 13 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue