Skip to content

[3.15] gh-161849: Fix crash compiling a class that binds __classdict__ (GH-161933) - #162020

Merged
gpshead merged 1 commit into
python:3.15from
miss-islington:backport-5131d72-3.15
Nov 15, 2026
Merged

gpshead merged 1 commit into
python:3.15from
miss-islington:backport-5131d72-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

When a class body binds classdict (assignment, for target, global,
del), analyze_name() treated the name as global in the annotation and
type parameter scopes that can see the class, so they no longer got the
classdict cell the class creates for them. Compiling such a class
with a generic class inside crashed, and with an annotated method or a
type alias raised SystemError.

Skip that rule for classdict itself.
(cherry picked from commit 5131d72)

Co-authored-by: 0z5a dezhen.lu@student.uni-tuebingen.de

…_` (pythonGH-161933)

When a class body binds __classdict__ (assignment, for target, global,
del), analyze_name() treated the name as global in the annotation and
type parameter scopes that can see the class, so they no longer got the
__classdict__ cell the class creates for them. Compiling such a class
with a generic class inside crashed, and with an annotated method or a
type alias raised SystemError.

Skip that rule for __classdict__ itself.
(cherry picked from commit 5131d72)

Co-authored-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants