This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect evaluation of variables with names containing supplementary characters
Type: Stage:
Components: Interpreter Core, Unicode Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Drekin, benjamin.peterson, ezio.melotti, vstinner
Priority: normal Keywords:

Created on 2014-10-18 19:26 by Drekin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg229653 - (view) Author: Adam Bartoš (Drekin) * Date: 2014-10-18 19:26
>>> eval("\N{mathematical double-struck capital a}")
NameError: name 'A' is not defined
>>> A = 2
>>> eval("\N{mathematical double-struck capital a}")
2
>>> "\N{mathematical double-struck capital a}" == "A"
False
msg229656 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-10-18 19:41
Identifier names are normalized.

>>> unicodedata.normalize("NFKC", "\N{mathematical double-struck capital a}") == "A"
True
msg229812 - (view) Author: Adam Bartoš (Drekin) * Date: 2014-10-22 11:42
I understand. I have found https://mail.python.org/pipermail/python-3000/2007-May/007995.html as a reason for using NFKC rather than NFC. On the other hand I think one may want these double-struct mathematical letters to be different from the ordinary ones if used as variable names. So I wonder if there are some other reasons for choosing NFKC over NFC.
msg229814 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-10-22 12:13
> So I wonder if there are some other reasons for choosing NFKC over NFC.

In fact, there is a whole PEP:

http://legacy.python.org/dev/peps/pep-3131/

I see "Which normalization form should be used, NFC or NFKC?" without answer, sorry.

I guess that NFKC avoids confusion when you use a font where two different characters have the same glyph or a very similer glyph.
msg229826 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-10-22 14:03
The unicode standard explains some of the tradeoffs.
http://www.unicode.org/reports/tr31/tr31-21.html#normalization_and_case

On Wed, Oct 22, 2014, at 07:42, Drekin wrote:
> 
> Drekin added the comment:
> 
> I understand. I have found
> https://mail.python.org/pipermail/python-3000/2007-May/007995.html as a
> reason for using NFKC rather than NFC. On the other hand I think one may
> want these double-struct mathematical letters to be different from the
> ordinary ones if used as variable names. So I wonder if there are some
> other reasons for choosing NFKC over NFC.
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue22667>
> _______________________________________
History
Date User Action Args
2022-04-11 14:58:09adminsetgithub: 66857
2014-10-22 14:03:53benjamin.petersonsetmessages: + msg229826
2014-10-22 12:14:00vstinnersetmessages: + msg229814
2014-10-22 11:42:58Drekinsetmessages: + msg229812
2014-10-18 19:41:13benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg229656

resolution: not a bug
2014-10-18 19:26:20Drekincreate