Sigurd Ljødal <sigurd+pyt...@ljodal.no> added the comment:

I think you misunderstood the issue here. I'm not trying to replace the class 
variable itself, I'm changing another field on a class that has a class 
variable. The problem is that the replace method includes the class variable in 
the change dict when copying fields that are not included in the function call.

My call is: dataclasses.replace(obj, a=2) where I try to replace a, but it 
fails because class_var is included in the attributes to __init__ by the 
replace function.

The problem is on this line: 
https://github.com/python/cpython/blob/master/Lib/dataclasses.py#L1162
The _FIELDS attribute includes the class variable as a field, and it is 
therefore added to the changes dict.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33796>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to