Skip to content

Support non-ascii identifiers #586

Closed

Description

@JukkaL

We should support non-ascii (unicode) identifiers as variable names, etc.

Activity

  1. o11c commented on Aug 8, 2015

    @o11c
    Contributor

    I'm actually not sure how to support this since it is defined in terms of unicode classes, which are not supported by python's regex engine, and there is no efficient way to enumerate the characters in each category (let alone DTRT for the particular version of unicode supported by any given python3 release).

    Really seems like more of a misfeature than a feature to me.

  2. JukkaL commented on Aug 9, 2015

    @JukkaL
    CollaboratorAuthor

    Hmm. I haven't actually looked into this in much detail. We should still be able to implement this in an efficient manner for the 99% of code that doesn't use unicode identifiers. It's fine if using unicode identifiers slows down parsing, but it's not okay if this feature slows down parsing everything else.

    Maybe something like this:

    Have a separate case in the lexer for all non-ascii characters outside string literals and comments (character code >= 128). Fall back to a possibly slow implementation that can do whatever needed to get this working when we hit this, but skip this code path altogether for code that doesn't use any unicode identifiers.

    Also, the unicodedata module could be useful.

  3. gvanrossum commented on Nov 1, 2016

    @gvanrossum
    Member

    I'm going to close this as a won't fix because the new parser will solve this and we're not going to put any work in the old parser/lexer.

  4. vedgar commented on Feb 1, 2017

    @vedgar

    May I ask what's the status of that New Parser? Maybe I can even work on it, if it's Python-only. I was extremely surprised to learn that mypy still doesn't understand Python naming rules. PEP 3131 is almost a decade old. :-o

  5. gvanrossum commented on Feb 1, 2017

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions