Issue 34213: Frozen dataclass init fails for "object" property" (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/78394

classification

Title: Frozen dataclass __init__ fails for "object" property"
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7

process

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.

Files
File name Uploaded Description Edit
frozen_dataclass_init_typeerror.py 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 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
msg322332 - (view) Author: Vadim Pushtaev (Vadim Pushtaev) * Date: 2018-07-24 21:33
Hello. This is my solution for this problem - https://github.com/python/cpython/pull/8452 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) https://github.com/python/cpython/commit/4d12e4dc28b7c782c368bae2e8fd3815167ed37d
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) https://github.com/python/cpython/commit/32e58fc32188753d2a3604feacdf9540fe9515fb
History
Date User Action Args
2022-04-11 14:59:03 admin set github: 78394
2018-09-10 22:43:33 eric.smith set status: open -> closedstage: patch review -> resolvedresolution: fixedversions: + Python 3.8
2018-08-13 03:32:51 miss-islington set nosy: + miss-islingtonmessages: +
2018-08-12 14:15:40 miss-islington set pull_requests: + <pull%5Frequest8229>
2018-08-12 11:46:29 miss-islington set pull_requests: + <pull%5Frequest8228>
2018-08-12 11:46:09 eric.smith set messages: +
2018-07-24 21:33:32 Vadim Pushtaev set messages: +
2018-07-24 21:28:55 python-dev set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest7976>
2018-07-24 20:37:03 Vadim Pushtaev set nosy: + Vadim Pushtaev
2018-07-24 18:44:43 eric.smith set assignee: eric.smithnosy: + eric.smith
2018-07-24 18:34:20 Omenien create