@@ -802,7 +802,7 @@ def find_source(self) -> Tuple[Optional["Referable"], Optional[List[str]]]: # t
802802
803803 def update_from (self , other : "Referable" , update_source : bool = False ):
804804 """
805- Internal function to updates the object's attributes from another object of a similar type .
805+ Internal function to update the object's attributes from a different version of the exact same object .
806806
807807 This function should not be used directly. It is typically used by backend implementations (database adapters,
808808 protocol clients, etc.) to update the object's data, after ``update()`` has been called.
@@ -829,20 +829,13 @@ def update_from(self, other: "Referable", update_source: bool = False):
829829 # update the elements of the NameSpaceSet
830830 getattr (self , name ).update_nss_from (attr )
831831 else :
832- try :
833- # Check if this is a property and if it has no setter
834- prop = getattr (type (self ), name , None )
835- if isinstance (prop , property ) and prop .fset is None :
836- # Attempt to set the underlying private attribute instead
837- private_name = f"_{ name } "
838- if hasattr (self , private_name ):
839- setattr (self , private_name , attr )
840- else :
841- raise AttributeError (f"underlying object has no attribute { private_name } " )
842- else :
843- setattr (self , name , attr )
844- except AttributeError :
845- raise
832+ # Check if this is a property and if it has no setter
833+ prop = getattr (type (self ), name , None )
834+ if isinstance (prop , property ) and prop .fset is None :
835+ if getattr (self , name ) != attr :
836+ raise ValueError (f"property { name } is immutable but has changed between versions of the object" )
837+ else :
838+ setattr (self , name , attr )
846839
847840 def commit (self ) -> None :
848841 """
0 commit comments