[New-bugs-announce] [issue28076] Variable annotations should be mangled for private names

Ivan Levkivskyi report at bugs.python.org
Sun Sep 11 06:50:58 EDT 2016

New submission from Ivan Levkivskyi:

Variable annotations for private names are stored in __annotations__ without name mangling. This is inconsistent with how function annotations behave:

class C:
   def meth(__x: int): ...

assert C.meth.__annotations__ == {'_C__x': int}

The attached patch fixes variable annotations to behave in the same way:

class C:
    __foo: int = 1

assert C.__dict__['_C_foo'] == 1
assert C.__annotations__['_C__foo'] == int

components: Interpreter Core
files: mangle-ann.diff
keywords: patch
messages: 275772
nosy: gvanrossum, levkivskyi
priority: normal
severity: normal
status: open
title: Variable annotations should be mangled for private names
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file44552/mangle-ann.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list