@@ -1558,14 +1558,14 @@ class C:
1558
1558
return _replace (obj , ** changes )
1559
1559
1560
1560
1561
- def _replace (obj , / , ** changes ):
1561
+ def _replace (self , / , ** changes ):
1562
1562
# We're going to mutate 'changes', but that's okay because it's a
1563
- # new dict, even if called with 'replace(obj , **my_changes)'.
1563
+ # new dict, even if called with 'replace(self , **my_changes)'.
1564
1564
1565
1565
# It's an error to have init=False fields in 'changes'.
1566
- # If a field is not in 'changes', read its value from the provided obj .
1566
+ # If a field is not in 'changes', read its value from the provided 'self' .
1567
1567
1568
- for f in getattr (obj , _FIELDS ).values ():
1568
+ for f in getattr (self , _FIELDS ).values ():
1569
1569
# Only consider normal fields or InitVars.
1570
1570
if f ._field_type is _FIELD_CLASSVAR :
1571
1571
continue
@@ -1582,11 +1582,11 @@ def _replace(obj, /, **changes):
1582
1582
if f ._field_type is _FIELD_INITVAR and f .default is MISSING :
1583
1583
raise TypeError (f"InitVar { f .name !r} "
1584
1584
f'must be specified with replace()' )
1585
- changes [f .name ] = getattr (obj , f .name )
1585
+ changes [f .name ] = getattr (self , f .name )
1586
1586
1587
1587
# Create the new object, which calls __init__() and
1588
1588
# __post_init__() (if defined), using all of the init fields we've
1589
1589
# added and/or left in 'changes'. If there are values supplied in
1590
1590
# changes that aren't fields, this will correctly raise a
1591
1591
# TypeError.
1592
- return obj .__class__ (** changes )
1592
+ return self .__class__ (** changes )
0 commit comments