[issue20625] Argument names in __annotations__ are not mangled for functions defined inside class scope

Jonas Wielicki report at bugs.python.org
Fri Feb 14 12:57:28 CET 2014


New submission from Jonas Wielicki:

Assume I have this code:

class Spam:
    def eggs(__some_kwarg:int=None):
        print(__some_kwarg)

I can call Spam.bar with keyword arguments as expected from mangling:

>>> Spam.eggs(10)
10
>>> Spam.eggs(_Spam__some_kwarg=10)
10

However, in the __annotations__ field, the argument name is not mangled:

>>> Spam.eggs.__annotations__
{'__some_kwarg': <class 'int'>}

This is an inconsistency which makes it difficult to work with function annotations in this case.

----------
components: Interpreter Core
messages: 211215
nosy: jonasw
priority: normal
severity: normal
status: open
title: Argument names in __annotations__ are not mangled for functions defined inside class scope
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20625>
_______________________________________


More information about the Python-bugs-list mailing list