Skip to content

17.3.0 cmp/default/hash/WeakKeyDictionary interaction #289

Description

@glyph

On 17.3.0, an @attr.s(hash=False) class which has an attr.ib with a @default that looks itself up in a WeakKeyDictionary into which it has previously been placed by an earlier @default raises an AttributeError on construction, unless @attr.s(cmp=False) is also set.

This worked properly on 17.2.0.

import attr
import weakref
bugs = weakref.WeakKeyDictionary()

@attr.s(hash=False)
class Bug(object):
    a = attr.ib()
    @a.default
    def make_a(self):
        bugs[self] = 1
        return 1

    b = attr.ib()
    @b.default
    def make_b(self):
        bugs[self]
        return 2

Bug()

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions