Skip to content

Unicode is normalised after keywords are checked for #77886

Description

@stevendaprano
BPO 33705
Nosy @vstinner, @ezio-melotti, @stevendaprano

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2018-05-31.04:53:08.938>
labels = ['interpreter-core', 'type-bug', 'expert-unicode']
title = 'Unicode is normalised after keywords are checked for'
updated_at = <Date 2018-05-31.04:54:23.515>
user = 'https://github.com/stevendaprano'

bugs.python.org fields:

activity = <Date 2018-05-31.04:54:23.515>
actor = 'steven.daprano'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Interpreter Core', 'Unicode']
creation = <Date 2018-05-31.04:53:08.938>
creator = 'steven.daprano'
dependencies = []
files = []
hgrepos = []
issue_num = 33705
keywords = []
message_count = 2.0
messages = ['318250', '318251']
nosy_count = 3.0
nosy_names = ['vstinner', 'ezio.melotti', 'steven.daprano']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue33705'
versions = []

Activity

  1. stevendaprano commented on May 31, 2018

    @stevendaprano
    MemberAuthor

    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

  2. stevendaprano commented on May 31, 2018

    @stevendaprano
    MemberAuthor

    Possibly the correct term is canonicalisation rather than normalisation, although I think the two are interchangeable.

  3. transferred this issue fromon Apr 10, 2022
  4. StanFromIreland commented on Sep 26, 2025

    @StanFromIreland
    Member

    In #86846 it was concluded this is a docs issue, closing as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-unicodetype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions