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 — dataclass(slots=True) fails if method has an empty `__class__` cell · Issue #148947 · python/cpython

dataclass(slots=True) fails if method has an empty __class__ cell #148947

New issue
Copy link
New issue
Copy link
Closed
Closed
dataclass(slots=True) fails if method has an empty __class__ cell#148947
Copy link
Assignees
JelleZijlstra
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@JelleZijlstra
JelleZijlstra
opened on Apr 24, 2026
Issue body actions

Bug report

Bug description:

On Python 3.14, this code:

def maker():
    if False:
        __class__ = 42

    def method(self):
        return __class__
    return method

from dataclasses import dataclass

@dataclass(slots=True)
class X:
    a: int

    meth = maker()

Fails with ValueError: Cell is empty, because some dataclasses machinery for updating the __class__ cell doesn't reckon with the possibility that the cell may be empty.

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-148947: dataclasses: fix error on empty __class__ cell  #148948
  • [3.14] gh-148947: dataclasses: fix error on empty __class__ cell (GH-148948) #148995

Activity

  1. JelleZijlstra
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 24, 2026
  2. JelleZijlstra
    self-assigned this
    on Apr 24, 2026
  3. johnslavik
    changed the title [-]dataclass(slots=True) crashes if method has an empty `__class__` cell[/-] [+]dataclass(slots=True) fails if method has an empty `__class__` cell[/+] on Apr 24, 2026
  4. johnslavik
    changed the title [-]dataclass(slots=True) fails if method has an empty `__class__` cell[/-] [+]dataclass(slots=True) crashes if method has an empty `__class__` cell[/+] on Apr 24, 2026
  5. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    topic-dataclasses
    on Apr 24, 2026
  6. johnslavik
    added
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    on Apr 24, 2026
  7. johnslavik
    changed the title [-]dataclass(slots=True) crashes if method has an empty `__class__` cell[/-] [+]dataclass(slots=True) fails if method has an empty `__class__` cell[/+] on Apr 24, 2026
  8. JelleZijlstra
    added a commit that references this issue on Apr 25, 2026

    gh-148947: dataclasses: fix error on empty __class__ cell (#148948)

    6d7bbee
  9. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-148947: dataclasses: fix error on empty __class__ cell (pyth…

    efe54da
  10. JelleZijlstra
    added a commit that references this issue on Apr 25, 2026

    [3.14] gh-148947: dataclasses: fix error on empty __class__ cell (GH-…

    15e2b64
  11. JelleZijlstra
    closed this as completedon Apr 25, 2026
  12. gpshead
    added 3 commits that reference this issue on Apr 25, 2026

    [3.13] pythongh-148947: dataclasses: fix error on empty __class__ cell (

    3abfebc

    [3.13] pythongh-148947: dataclasses: fix error on empty __class__ cell (

    678cc46

    [3.13] gh-105936: Properly update closure cells for __setattr__ and _…

    9651429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra

Labels

3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

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.