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.

classification
Title: dataclasses.replace() fails with the field named "obj"
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, eric.smith, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-06-05 11:13 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13877 merged serhiy.storchaka, 2019-06-07 05:22
PR 14390 merged serhiy.storchaka, 2019-06-26 07:51
PR 14405 merged serhiy.storchaka, 2019-06-26 16:24
Messages (8)
msg344704 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-05 11:13
>>> from dataclasses import *
>>> @dataclass
... class D:
...     obj: object
... 
>>> replace(D(123), obj='abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: replace() got multiple values for argument 'obj'
msg344707 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-06-05 11:21
Possibly a use for positional-only parameters. Backward compatibility is the question, of course.
msg344741 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-05 16:01
I propose to add a deprecation warning in 3.8 and use the PEP 570 syntax in 3.9 (which means a TypeError if obj is passed by keyword argument).
msg344751 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-06-05 17:21
+1 for Serhiy's suggestion
msg344896 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-06-07 04:28
+1 to Serhiy's proposal
msg346022 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-19 07:33
New changeset f5b89afde1196ec9f74b7dc0333cec9bc4d4c2db by Serhiy Storchaka in branch '3.8':
bpo-37163: Deprecate passing argument obj of dataclasses.replace() by keyword. (GH-13877)
https://github.com/python/cpython/commit/f5b89afde1196ec9f74b7dc0333cec9bc4d4c2db
msg346647 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-26 16:07
New changeset 2d88e63bfcf7bccba925ab80b3f47ccf8b7aefa8 by Serhiy Storchaka in branch 'master':
bpo-37163: Make the obj argument of dataclasses.replace() a positional-only. (GH-14390)
https://github.com/python/cpython/commit/2d88e63bfcf7bccba925ab80b3f47ccf8b7aefa8
msg346674 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-26 20:03
New changeset 6ef103fbdbc05adbc20838c94b1f0c40fa6c159a by Serhiy Storchaka in branch '3.7':
[3.7] bpo-37163: dataclasses.replace() now supports the field named "obj". (GH-13877) (GH-14405)
https://github.com/python/cpython/commit/6ef103fbdbc05adbc20838c94b1f0c40fa6c159a
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81344
2019-06-26 20:16:55serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-26 20:03:14serhiy.storchakasetmessages: + msg346674
2019-06-26 16:24:55serhiy.storchakasetpull_requests: + pull_request14217
2019-06-26 16:07:47serhiy.storchakasetmessages: + msg346647
2019-06-26 07:51:11serhiy.storchakasetstage: resolved -> patch review
pull_requests: + pull_request14204
2019-06-25 23:25:29pablogsalsetstatus: closed -> open
resolution: fixed -> (no value)
2019-06-25 23:24:06pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-19 07:33:32serhiy.storchakasetmessages: + msg346022
2019-06-07 05:22:25serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request13755
2019-06-07 04:28:52pablogsalsetnosy: + pablogsal
messages: + msg344896
2019-06-05 17:21:22brett.cannonsetnosy: + brett.cannon
messages: + msg344751
2019-06-05 16:01:35serhiy.storchakasetmessages: + msg344741
2019-06-05 11:21:59eric.smithsetmessages: + msg344707
2019-06-05 11:13:04serhiy.storchakacreate