[New-bugs-announce] [issue33588] Unicode function arguments aren't preserved

Mat Leonard report at bugs.python.org
Sun May 20 17:51:51 EDT 2018


New submission from Mat Leonard <leonard.mat at gmail.com>:

Unicode symbols used as function arguments aren't preserved in the variable names available from .__code__.co_varnames. Example shown below.

def func(ϵ, α, γ, ϕ):
    pass

varnames = func.__code__.co_varnames
print(varnames)
print('ϵ' == varnames[0])
print('α' == varnames[1])
print('γ' == varnames[2])
print('ϕ' == varnames[3])

>> ('ε', 'α', 'γ', 'φ')
>> False
>> True
>> True
>> False

I wrote some code dependent on using function arguments obtained from .__code__.co_varnames in a dictionary. Since the unicode arguments aren't preserved from defining the function and .__code__.co_varnames, the lookup in the dictionary fails.

Looks like same thing happens with the inspect module (maybe .__code__.co_varnames comes from inspect)

inspect.signature(func)
>> <Signature (ε, α, γ, φ)>

----------
components: Unicode
files: Screen Shot 2018-05-20 at 2.32.05 PM.png
messages: 317201
nosy: ezio.melotti, mcleonard, vstinner
priority: normal
severity: normal
status: open
title: Unicode function arguments aren't preserved
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file47608/Screen Shot 2018-05-20 at 2.32.05 PM.png

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33588>
_______________________________________


More information about the New-bugs-announce mailing list