classification
Title: Dataclasses derived from empty frozen bases skip immutability checks
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, hbq1, miss-islington
Priority: normal Keywords: patch

Created on 2021-02-09 07:12 by hbq1, last changed 2021-04-06 15:07 by eric.smith. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24484 merged hbq1, 2021-02-09 07:12
PR 25205 merged miss-islington, 2021-04-06 05:14
PR 25206 merged miss-islington, 2021-04-06 05:14
PR 25215 merged eric.smith, 2021-04-06 13:52
PR 25217 merged miss-islington, 2021-04-06 14:08
PR 25218 merged miss-islington, 2021-04-06 14:08
Messages (8)
msg386695 - (view) Author: Iurii Kemaev (hbq1) * Date: 2021-02-09 07:12
Dataclasses derived from empty frozen bases skip immutability checks.

Repro snippet:

```
import dataclasses

@dataclasses.dataclass(frozen=True)
class Base:
  pass

@dataclasses.dataclass
class Derived(Base):
  a: int

d = Derived(2)
# OK
```

Usecase: sometimes developers define an empty frozen base dataclass with detailed docs and require other dataclasses to inherit from it as a code contract to avoid accidental in-place modifications. 
This bug makes this strategy ineffective.

Affects all versions of Python that support dataclasses (including the backport for py3.6).
msg390277 - (view) Author: miss-islington (miss-islington) Date: 2021-04-06 05:14
New changeset 376ffc6ac491da74920aed1b8e35bc371cb766ac by Iurii Kemaev in branch 'master':
bpo-43176: Fix processing of empty dataclasses (GH-24484)
https://github.com/python/cpython/commit/376ffc6ac491da74920aed1b8e35bc371cb766ac
msg390278 - (view) Author: miss-islington (miss-islington) Date: 2021-04-06 05:32
New changeset b132be8b43afa739b7eda271b82711d64a83da4f by Miss Islington (bot) in branch '3.8':
bpo-43176: Fix processing of empty dataclasses (GH-24484)
https://github.com/python/cpython/commit/b132be8b43afa739b7eda271b82711d64a83da4f
msg390280 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-04-06 06:04
Thanks!
msg390332 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-04-06 13:46
New changeset 8a34a0793bcb830350dac675524310bb285e5e4f by Miss Islington (bot) in branch '3.9':
bpo-43176: Fix processing of empty dataclasses (GH-24484) (GH-25205)
https://github.com/python/cpython/commit/8a34a0793bcb830350dac675524310bb285e5e4f
msg390336 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-04-06 14:08
New changeset 1744c96ebc98b240f2564f75191097704b37244f by Eric V. Smith in branch 'master':
Fix blurb for bpo-43176. (GH-25215)
https://github.com/python/cpython/commit/1744c96ebc98b240f2564f75191097704b37244f
msg390339 - (view) Author: miss-islington (miss-islington) Date: 2021-04-06 14:19
New changeset 76c4a9fb8ae370901b387a4edb609295bcc159e7 by Miss Islington (bot) in branch '3.8':
[3.8] Fix blurb for bpo-43176. (GH-25215) (GH-25218)
https://github.com/python/cpython/commit/76c4a9fb8ae370901b387a4edb609295bcc159e7
msg390344 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-04-06 15:07
New changeset 2df971afd5f29574be3bb44f2d8569cc240b800d by Miss Islington (bot) in branch '3.9':
Fix blurb for bpo-43176. (GH-25215) (GH-25217)
https://github.com/python/cpython/commit/2df971afd5f29574be3bb44f2d8569cc240b800d
History
Date User Action Args
2021-04-06 15:07:14eric.smithsetmessages: + msg390344
2021-04-06 14:19:05miss-islingtonsetmessages: + msg390339
2021-04-06 14:08:47eric.smithsetmessages: + msg390336
2021-04-06 14:08:45miss-islingtonsetpull_requests: + pull_request23956
2021-04-06 14:08:34miss-islingtonsetpull_requests: + pull_request23955
2021-04-06 13:52:16eric.smithsetpull_requests: + pull_request23953
2021-04-06 13:46:37eric.smithsetmessages: + msg390332
2021-04-06 06:04:27eric.smithsetstatus: open -> closed
versions: - Python 3.6, Python 3.7
messages: + msg390280

resolution: fixed
stage: patch review -> resolved
2021-04-06 05:32:02miss-islingtonsetmessages: + msg390278
2021-04-06 05:14:45miss-islingtonsetpull_requests: + pull_request23945
2021-04-06 05:14:36miss-islingtonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23944
2021-04-06 05:14:08miss-islingtonsetnosy: + miss-islington
messages: + msg390277
2021-02-09 07:14:17xtreaksetnosy: + eric.smith
2021-02-09 07:12:39hbq1create