Skip to content
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

frozen=True doesn't play well with converters #76

Deewiant opened this issue Sep 5, 2016 · 1 comment

frozen=True doesn't play well with converters #76

Deewiant opened this issue Sep 5, 2016 · 1 comment


Copy link

Deewiant commented Sep 5, 2016

Code that I would expect to run without errors:

import attr

class Ice:
    x = attr.ib(convert=lambda y: y + 1)

assert Ice(1).x == 2

Actual runtime result:

Traceback (most recent call last):
  File "", line 7, in <module>
    assert Ice(1).x == 2
  File "<attrs generated init cd74cad05a4efad0b01528e489d51126583d23cb>", line 4, in __init__
  File "/usr/lib/python3.5/site-packages/attr/", line 483, in _convert
    setattr(inst,, a.convert(getattr(inst,
  File "/usr/lib/python3.5/site-packages/attr/", line 156, in _frozen_setattrs
    raise FrozenInstanceError()

Clearly _convert isn't aware of the class's frozenness. I took a quick peek at the code and it seems like it should perhaps be using _cached_setattr instead of the ordinary setattr?

Copy link

Tinche commented Sep 5, 2016

Roger, I can put together a fix in the evening.

@hynek hynek closed this as completed in a624035 Sep 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants