[Python-Dev] Re: Preventing Unicode-related gotchas (Was: pre-PEP: Unicode Security Considerations for Python)

2021年11月14日 10:26:48 -0800

On 2021年11月14日 17:17, Christopher Barker wrote:
On Sat, Nov 13, 2021 at 2:03 PM <[email protected] <mailto:[email protected]>> wrote:
 def hello():
 __
   try:____
 hello_ = "Hello"____
 world_ = "World"____
     print(f"{hello_}, {world_}!")____
   except TypeError as exc:____
 print("failed: {}".format(exc))
Wow. Just Wow.
So why does Python apply NFKC normalization to variable names?? I can't for the life of me figure out why that would be helpful at all.
The string methods, sure, but names?
And, in fact, the normalization is not used for string comparisons or hashes as far as I can tell.
[snip]
It's probably to deal with "é" vs "é", i.e. "\N{LATIN SMALL LETTER E}\N{COMBINING ACUTE ACCENT}" vs "\N{LATIN SMALL LETTER E WITH ACUTE}", which are different ways of writing the same thing. Unfortunately, it goes too far, because it's unlikely that we want "p" ("\N{MODIFIER LETTER SMALL P}') to be equivalent to "P" ("\N{LATIN CAPITAL LETTER P}".
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/PNZICEQGVEAQH7KNBCBSS4LPAO25JBF3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to