Skip to content

The elements in Grammar/python.gram stripped by peg_lexer.py still shows in generated PO files #142714

Closed

Description

@mattwang44

My original question has answered by Stan. I leave it here as a record:

Click to expand

I'm not sure if it's done deliberately, but it seems odd to me and I can't find out why it happens so far.


The reference/grammar.rst includes Grammar/python.gram

.. literalinclude:: ../../Grammar/python.gram
:language: peg

and Grammar/python.gram has a section for invalid rules at the bottom.

cpython/Grammar/python.gram

Lines 1193 to 1202 in 78a50ee

# ========================= END OF THE GRAMMAR ===========================
# ========================= START OF INVALID RULES =======================
# From here on, there are rules for invalid syntax with specialised error messages
invalid_arguments:
| ((','.(starred_expression | ( assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) a=',' ','.(starred_expression !'=')+ {

However, the content after START OF INVALID RULES is missing on the page

snapshot Image

I checked the previous version and found out the doc has this issue since 3.11 (after PEG parser is introduced).


Other info:
I translated this page into Traditional Chinese (zh-tw) recently and somehow it shows correctly on the translated page

snapshot Image

So here's the revised issue description:

Some elements in Grammar/python.gram are stripped by peg_lexer.py, and hence they're hidden on the reference/grammar docs. However, the full content of Grammar/python.gram is still remained in the generated PO files (e.g. the one in zh-tw).

Linked PRs

Activity

  1. StanFromIreland commented on Dec 14, 2025

    @StanFromIreland
    Member

    This is intentional, as the introduction states:

    The version here omits details related to code generation and error recovery.

    This lexer strips the following elements from the grammar:
    - Meta-tags
    - Variable assignments
    - Actions
    - Lookaheads
    - Rule types
    - Rule options
    - Rules named `invalid_*` or `incorrect_*`

    Why this is not done for translations is a bug.

  2. mattwang44 commented on Dec 14, 2025

    @mattwang44
    ContributorAuthor

    ok thanks! I'll revise the issue description in-place then.

  3. changed the title [-]"INVALID RULES" part in `reference/grammar` page is missing after rendered[/-] [+]The elements in `Grammar/python.gram` stripped by `peg_lexer.py` still shows in generated PO files[/+] on Dec 14, 2025
  4. added a commit that references this issue on Oct 14, 2026
  5. added 4 commits that reference this issue on Oct 28, 2026
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

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions