This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Frozen dataclass __init__ fails for "object" property"
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: Omenien, Vadim Pushtaev, eric.smith, miss-islington
Priority: normal Keywords: patch

Created on 2018-07-24 18:34 by Omenien, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit Omenien, 2018-07-24 18:34 Minimal .py demonstrating the error
Pull Requests
URL Status Linked Edit
PR 8452 merged python-dev, 2018-07-24 21:28
PR 8745 closed miss-islington, 2018-08-12 11:46
PR 8746 merged miss-islington, 2018-08-12 14:15
Messages (4)
msg322321 - (view) Author: Edward Jones (Omenien) Date: 2018-07-24 18:34
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.

I was able to reproduce this in a Docker container running with the attached .py file.
Python 3.7.0 (default, Jul 17 2018, 11:04:33) 
[GCC 6.3.0 20170516] on linux
msg322332 - (view) Author: Vadim Pushtaev (Vadim Pushtaev) * Date: 2018-07-24 21:33

This is my solution for this problem -

Sorry if I'm not supposed to do anything about the already assigned issue, feel free to ignore my PR.
msg323441 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2018-08-12 11:46
New changeset 4d12e4dc28b7c782c368bae2e8fd3815167ed37d by Eric V. Smith (Vadim Pushtaev) in branch 'master':
bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452)
msg323459 - (view) Author: miss-islington (miss-islington) Date: 2018-08-13 03:32
New changeset 32e58fc32188753d2a3604feacdf9540fe9515fb by Miss Islington (bot) in branch '3.7':
bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452)
Date User Action Args
2022-04-11 14:59:03adminsetgithub: 78394
2018-09-10 22:43:33eric.smithsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.8
2018-08-13 03:32:51miss-islingtonsetnosy: + miss-islington
messages: + msg323459
2018-08-12 14:15:40miss-islingtonsetpull_requests: + pull_request8229
2018-08-12 11:46:29miss-islingtonsetpull_requests: + pull_request8228
2018-08-12 11:46:09eric.smithsetmessages: + msg323441
2018-07-24 21:33:32Vadim Pushtaevsetmessages: + msg322332
2018-07-24 21:28:55python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request7976
2018-07-24 20:37:03Vadim Pushtaevsetnosy: + Vadim Pushtaev
2018-07-24 18:44:43eric.smithsetassignee: eric.smith

nosy: + eric.smith
2018-07-24 18:34:20Omeniencreate