[New-bugs-announce] [issue46555] Unicode-mangled names refer inconsistently to constants

Kodiologist report at bugs.python.org
Thu Jan 27 16:57:22 EST 2022

New submission from Kodiologist <nonce0010lep at arfer.net>:

I'm not sure if this is a bug, but it certainly surprised me. Most reserved words, when Unicode-mangled, as in "𝕕𝕖𝕗", act like ordinary identifiers (see e.g. bpo-46520). `True`, `False`, and `None` are weird in that Unicode-mangled versions of them refer to those same constants initially, but can take on their own identity as variables if assigned to:

    Python 3.9.7 (default, Sep 10 2021, 14:59:43) 
    [GCC 11.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 𝕋𝕣𝕦𝕖
    >>> True = 0
      File "<stdin>", line 1
        True = 0
    SyntaxError: cannot assign to True
    >>> 𝕋𝕣𝕦𝕖 = 0
    >>> True
    >>> 𝕋𝕣𝕦𝕖

I think that `𝕋𝕣𝕦𝕖 = 1` should probably be forbidden. The fact that `𝕋𝕣𝕦𝕖` doesn't always mean the same thing as `True` seems to break the rule in PEP 3131 that "comparison of identifiers is based on NFKC".

messages: 411930
nosy: Kodiologist
priority: normal
severity: normal
status: open
title: Unicode-mangled names refer inconsistently to constants
type: behavior
versions: Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list