summaryrefslogtreecommitdiff
path: root/Lib/dataclasses.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2018-06-23 23:46:32 +0900
committerEric V. Smith <ericvsmith@users.noreply.github.com>2018-06-23 10:46:32 -0400
commit3d70f7aef614c396f516b5fccedeebe98598714d (patch)
treeb811dc51f5c680418baa0629eb16fb5b6fca9b94 /Lib/dataclasses.py
parent66ecefcfe77348ce12d3a951e8e6cd3ad274b24a (diff)
downloadcpython-git-3d70f7aef614c396f516b5fccedeebe98598714d.tar.gz
bpo-33805: Improve error message of dataclasses.replace() (GH-7580)
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r--Lib/dataclasses.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 96bf6e1df4..ad7bf0f759 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -1173,6 +1173,9 @@ def replace(obj, **changes):
continue
if f.name not in changes:
+ if f._field_type is _FIELD_INITVAR:
+ raise ValueError(f"InitVar {f.name!r} "
+ 'must be specified with replace()')
changes[f.name] = getattr(obj, f.name)
# Create the new object, which calls __init__() and