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
Frozen dataclass __init__ fails for "object" property" #78394
When __init__ is called for a class which 1) is annotated with @dataclasses.dataclass(frozen=True) and 2) has a attribute named object a TypeError is raised because object is overridden for the local scope and as a result __setattr__ is called on the passed in argument value instead of the standard object base type.
New changeset 4d12e4d by Eric V. Smith (Vadim Pushtaev) in branch 'master': bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452) 4d12e4d
Activity
Omenien commentedon Jul 24, 2018
When
__init__is called for a class which 1) is annotated with@dataclasses.dataclass(frozen=True)and 2) has a attribute namedobjecta TypeError is raised becauseobjectis overridden for the local scope and as a result__setattr__is called on the passed in argument value instead of the standardobjectbase type.I was able to reproduce this in a Docker container running https://github.com/docker-library/python/blob/7a794688c7246e7eff898f5288716a3e7dc08484/3.7/stretch/Dockerfile with the attached .py file.
Python 3.7.0 (default, Jul 17 2018, 11:04:33)
[GCC 6.3.0 20170516] on linux
VadimPushtaev commentedon Jul 24, 2018
Hello.
This is my solution for this problem - #8452
Sorry if I'm not supposed to do anything about the already assigned issue, feel free to ignore my PR.
ericvsmith commentedon Aug 12, 2018
New changeset 4d12e4d by Eric V. Smith (Vadim Pushtaev) in branch 'master':
bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452)
4d12e4d
miss-islington commentedon Aug 13, 2018
New changeset 32e58fc by Miss Islington (bot) in branch '3.7':
bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452)
32e58fc