Skip to content

A slots=False class inheriting from a slots=True class generates incorrect __getstate__ #475

@mooncake4132

Description

@mooncake4132

I understand that this is a fairly uncommon case, but I was expecting the following to work:

import attr
import copy


@attr.s(slots=True)
class A:
    a = attr.ib()


@attr.s
class B(A):
    b = attr.ib()


b = B(1, 2)
print('ver: {}'.format(attr.__version__))
print('b: {!r}'.format(b))
print('b.__getstate__: {!r}'.format(b.__getstate__()))
print('deecopy(b): {!r}'.format(copy.deepcopy(b)))

Output

ver: 18.2.0
b: B(a=1, b=2)
b.__getstate__: (1,)
deecopy(b): B(a=1, b=NOTHING)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions