You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
slots=True do not play nice with __init_subclass__ #269
A class annotated with attr.s(slots=True) can't call super().__init__subclass__ within its own __init_subclass__ method - a TypeError: super(type, obj): obj must be an instance or subtype of type is raised.
So I'm sitting here trying to write a test for this and for some reason, the test I've written is passing even when I comment out the fix.
Turns out CPython will actually reuse closure cells sometimes. So if a class has a normal method that needs to be rewritten, the problem will not manifest. 😱
Activity
hynek commentedon Oct 17, 2017
Uh is that another thing with cells? Is it fixable? And more importantly, is this something we’re breaking with #260 for dict classes too? :|
Tinche commentedon Oct 17, 2017
I'll take a look. This is a PEP 487 thing I see, Python 3.6+.
Tinche commentedon Oct 17, 2017
It's fixable. I can push a commit to the replace-class branch a little later.
Tinche commentedon Oct 17, 2017
So I'm sitting here trying to write a test for this and for some reason, the test I've written is passing even when I comment out the fix.
Turns out CPython will actually reuse closure cells sometimes. So if a class has a normal method that needs to be rewritten, the problem will not manifest. 😱
hynek commentedon Oct 20, 2017
JFTR @malinoff, you prevented us from making a huge mistake and release it – in the last minute! So many thanks for that!
malinoff commentedon Oct 20, 2017
@hynek my pleasure!
Merge #167
Merge #161
Merge #118