diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2018-06-23 23:46:32 +0900 |
---|---|---|
committer | Eric V. Smith <ericvsmith@users.noreply.github.com> | 2018-06-23 10:46:32 -0400 |
commit | 3d70f7aef614c396f516b5fccedeebe98598714d (patch) | |
tree | b811dc51f5c680418baa0629eb16fb5b6fca9b94 /Lib/dataclasses.py | |
parent | 66ecefcfe77348ce12d3a951e8e6cd3ad274b24a (diff) | |
download | cpython-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.py | 3 |
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 |