GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Segfault compiling a class that binds `__classdict__` and contains a generic class · Issue #161849 · python/cpython

Segfault compiling a class that binds __classdict__ and contains a generic class #161849

New issue
Copy link
New issue
Copy link
Open
Open
Segfault compiling a class that binds __classdict__ and contains a generic class#161849
Copy link

Description

@0z5a
0z5a
opened on Nov 12, 2026
Issue body actions

Crash report

What happened?

class C:
    __classdict__ = 1
    class D[T]: pass

A release build of main segfaults while compiling this (in _PyCode_ConstantKey, called from _PyCompile_ConstCacheMergeOne). A debug build aborts with

Assertion failed: (offset > cellvar_offset), function compute_localsplus_info, file assemble.c, line 617.

With an annotated function in place of the generic class the compiler raises SystemError instead:

class C:
    __classdict__ = 1
    def f(x: int): pass
SystemError: compiler_lookup_arg(name='__classdict__') with reftype=5 failed in C; freevars of code __annotate__: ('__classdict__',)

global __classdict__ or for __classdict__ in (): pass in place of the assignment behave the same way. Without the __classdict__ line both classes compile and run.

3.14 behaves like main. On 3.13 the first example segfaults too; the second one compiles there, but def f[T: int](x): pass in its place gives the same kind of SystemError.

gh-149805 fixed the bare annotation __classdict__: a; the cases above still fail on main (35e2c5a).

I have a small change to analyze_name() in Python/symtable.c plus a test that makes these compile and keeps the annotations resolving against the class namespace. I can open a PR if that is wanted.

CPython versions tested on:

3.13, 3.14, CPython main branch

Operating systems tested on:

macOS

Output from running 'python -VV' on the command line:

Python 3.16.0a2+dev (heads/main:35e2c5a, Nov 12 2026, 05:12:02) [Clang 21.0.0 (clang-2100.1.1.101)]

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.