gh-135676: Simplify docs on lexing names#140464
Merged
encukou merged 8 commits intopython:mainpython/cpython:mainfrom Nov 26, 2025
encukou:lex-analysis-names-simplerencukou/cpython:lex-analysis-names-simplerCopy head branch name to clipboard
Merged
gh-135676: Simplify docs on lexing names#140464encukou merged 8 commits intopython:mainpython/cpython:mainfrom encukou:lex-analysis-names-simplerencukou/cpython:lex-analysis-names-simplerCopy head branch name to clipboard
encukou merged 8 commits intopython:mainpython/cpython:mainfrom
encukou:lex-analysis-names-simplerencukou/cpython:lex-analysis-names-simplerCopy head branch name to clipboard
Conversation
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Blaise Pabon <blaise@gmail.com> Co-authored-by: Micha Albert <info@micha.zone> Co-authored-by: KeithTheEE <kmurrayis@gmail.com>
willingc
approved these changes
Oct 22, 2025
Doc/reference/lexical_analysis.rst
Outdated
| This means that, for example, some typographic variants of characters are | ||
| converted to their "basic" form, for example:: | ||
|
|
||
| >>> nᵘₘᵇₑʳ = 3 |
Contributor
There was a problem hiding this comment.
It would be helpful to add an explicit comment that the normalized form of nᵘₘᵇₑʳis number.
Member
Author
|
There was an insightful conversation in #140269. I'll update this PR to make things even clearer. |
willingc
approved these changes
Nov 10, 2025
willingc
approved these changes
Nov 19, 2025
Member
Author
|
Thank you for the review! @malemburg, do you also want to take a look? |
|
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @encukou, I could not cleanly backport this to |
|
GH-142015 is a backport of this pull request to the 3.14 branch. |
StanFromIreland
added a commit
to StanFromIreland/cpython
that referenced
this pull request
Nov 27, 2025
This simplifies the Lexical Analysis section on Names (but keeps it technically correct) by putting all the info about non-ASCII characters in a separate (and very technical) section. It uses a mental model where the parser doesn't handle Unicode complexity “immediately”, but: - parses any non-ASCII character (outside strings/comments) as part of a name, since these can't (yet) be e.g. operators - normalizes the name - validates the name, using the xid_start/xid_continue sets (cherry picked from commit 2ff8608) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Blaise Pabon <blaise@gmail.com> Co-authored-by: Micha Albert <info@micha.zone> Co-authored-by: KeithTheEE <kmurrayis@gmail.com>
encukou
added a commit
that referenced
this pull request
Dec 3, 2025
This simplifies the Lexical Analysis section on Names (but keeps it technically correct) by putting all the info about non-ASCII characters in a separate (and very technical) section. It uses a mental model where the parser doesn't handle Unicode complexity “immediately”, but: - parses any non-ASCII character (outside strings/comments) as part of a name, since these can't (yet) be e.g. operators - normalizes the name - validates the name, using the xid_start/xid_continue sets (cherry picked from commit 2ff8608) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Blaise Pabon <blaise@gmail.com> Co-authored-by: Micha Albert <info@micha.zone> Co-authored-by: KeithTheEE <kmurrayis@gmail.com>
StanFromIreland
added a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
This simplifies the Lexical Analysis section on Names (but keeps it technically correct) by putting all the info about non-ASCII characters in a separate (and very technical) section. It uses a mental model where the parser doesn't handle Unicode complexity “immediately”, but: - parses any non-ASCII character (outside strings/comments) as part of a name, since these can't (yet) be e.g. operators - normalizes the name - validates the name, using the xid_start/xid_continue sets Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Blaise Pabon <blaise@gmail.com> Co-authored-by: Micha Albert <info@micha.zone> Co-authored-by: KeithTheEE <kmurrayis@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This simplifies the Lexical Analysis section on Names (but keeps it technically correct) by putting all the info about non-ASCII characters in a separate (and very technical) section.
It uses a mental model where the parser doesn't handle Unicode complexity “immediately”, but:
id_start/id_continuesets (referred to in previous sections as “letter-like” and “number-like” characters, with a link to the details)This also means we don't need
xid_start/xid_continueto define the behaviour :)📚 Documentation preview 📚: https://cpython-previews--140464.org.readthedocs.build/