Skip to content

gh-162574: Mangle private names in nested generic headers - #162661

Closed
pqminh27 wants to merge 1 commit into
python:mainfrom
pqminh27:gh-162574-nested-generic-mangling
Closed

pqminh27 wants to merge 1 commit into
python:mainfrom
pqminh27:gh-162574-nested-generic-mangling

Conversation

@pqminh27

@pqminh27 pqminh27 commented Nov 26, 2026 •

Copy link
Copy Markdown

Fixes #162574.

Nested generic class headers resolve private names using the enclosing lexical class's mangling context. Private type-parameter names continue to use the generic class's own context, preserving their behavior in bounds, bases, and class bodies.

Validation:

  • Full GIL debug suite on the previous base: ./python.exe -m test -j2 (52,574 tests run; passed; expected platform/resource skips)
  • On the current base, ./python.exe -m test -j2 test_type_params test_type_aliases test_symtable test_compile test_typing (1,156 tests; two skipped)
  • ./python.exe -m test -R 3:2 test_type_params test_symtable (174 tests)
  • make patchcheck

AI disclosure: AI assistance was used to prepare this PR.

@python-cla-bot

python-cla-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@pqminh27
pqminh27 force-pushed the gh-162574-nested-generic-mangling branch from 55169df to c2f4f31 Compare November 26, 2026 05:37
@pqminh27
pqminh27 marked this pull request as ready for review November 26, 2026 06:43
PyObject *ste_children; /* list of child blocks */
PyObject *ste_directives;/* locations of global and nonlocal statements */
PyObject *ste_mangled_names; /* set of names for which mangling should be applied */
PyObject *ste_mangled_names; /* type parameter names in a generic class header */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing this comment? the naming of the field is also clearly wwrong if it's only for type params now.

Comment thread Python/symtable.c
}
st->st_private = s->v.ClassDef.name;
st->st_cur->ste_mangled_names = PySet_New(NULL);
Py_XSETREF(st->st_cur->ste_mangled_names, PySet_New(NULL));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@picnixz picnixz added the AI-guidelines-not-met The contribution does not meet our guidelines for using AI tools and is closed automatically. label Nov 26, 2026
@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors.

We believe this contribution does not meet our guidelines for using AI tools, so we're closing it. If you think we've misunderstood your contribution, please let us know. You're welcome to explain your approach or ask questions about the guidelines.

Please read our guidelines for using AI tools.

@bedevere-app bedevere-app Bot closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-guidelines-not-met The contribution does not meet our guidelines for using AI tools and is closed automatically. awaiting changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Private names in the bases of a generic class nested in a class are not mangled

2 participants