Skip to content

Python @dataclasses(slots=True) breaks super() #132544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rdong8 opened this issue Apr 15, 2025 · 1 comment
Closed

Python @dataclasses(slots=True) breaks super() #132544

rdong8 opened this issue Apr 15, 2025 · 1 comment
Labels
type-bug An unexpected behavior, bug, or error

Comments

@rdong8
Copy link

rdong8 commented Apr 15, 2025

Bug report

Bug description:

import abc
import dataclasses
import typing


SLOTS = False


@dataclasses.dataclass(slots=SLOTS)
class Base:
    @abc.abstractmethod
    def f(self) -> None:
        pass


@dataclasses.dataclass(slots=SLOTS)
class Derived(Base):
    @typing.override
    def f(self) -> None:
        super().f()


d = Derived()
d.f()

If SLOTS = False, then this works. If SLOTS = True, then it fails:

Traceback (most recent call last):
  File "/app/output.s", line 24, in <module>
    d.f()
    ~~~^^
  File "/app/output.s", line 20, in f
    super().f()
    ^^^^^^^^^
TypeError: super(type, obj): obj (instance of Derived) is not an instance or subtype of type (Derived).

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@rdong8 rdong8 added the type-bug An unexpected behavior, bug, or error label Apr 15, 2025
@ericvsmith
Copy link
Member

This is a duplicate of issue #90562, and has been fixed in 3.14.

@ericvsmith ericvsmith closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants