[issue33705] Unicode is normalised after keywords are checked for
Steven D'Aprano
report at bugs.python.org
Thu May 31 00:53:09 EDT 2018
New submission from Steven D'Aprano <steve+python at pearwood.info>:
There is a loophole in the Unicode normalisation which allows the creation of names matching keywords.
class Spam:
locals()['if'] = 1
Spam.𝐢𝐟 # U+1D422 U+1D41F
# returns 1
Those two characters are 'MATHEMATICAL BOLD SMALL I' and 'MATHEMATICAL BOLD SMALL F'. They ought to be normalised to "if", which is a keyword.
Of course Spam.if is a syntax error, and I believe Spam.𝐢𝐟 ought to be as well.
Another example:
py> globals()['for'] = 2
py> 𝐟or
2
I also asked about this here:
https://mail.python.org/pipermail/python-dev/2018-May/153619.html
----------
components: Interpreter Core, Unicode
messages: 318250
nosy: ezio.melotti, steven.daprano, vstinner
priority: normal
severity: normal
status: open
title: Unicode is normalised after keywords are checked for
type: behavior
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33705>
_______________________________________
More information about the Python-bugs-list
mailing list