Skip to content

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

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

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

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 5131d723d84b7ebca4bcf266cb891f33e51555ef)

Co-authored-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
@gpshead
gpshead merged commit dda8544 into python:3.14 Nov 15, 2026
52 checks passed
@miss-islington
miss-islington deleted the backport-5131d72-3.14 branch November 15, 2026 06:17
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