mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
bolt-gen: keep single instance of type_obj per type
we rely, perhaps a bit hackily, on there only being one copy of each type object floating about. using `deepcopy` on a Message for message extensions destroys this paradigm, which breaks things in the case where it's a later defined subtype that contains variable-length members. to fix this, we modify `__deepcopy__` on the Field class, such that it preserves the reference to the original type_obj instance.
This commit is contained in:
parent
009e9dc945
commit
cfd56d86ee
2 changed files with 11 additions and 0 deletions
|
@ -50,6 +50,15 @@ class Field(object):
|
|||
self.is_optional = optional
|
||||
self.field_comments = field_comments
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
deepcopy_method = self.__deepcopy__
|
||||
self.__deepcopy__ = None
|
||||
field = copy.deepcopy(self, memo)
|
||||
self.__deepcopy__ = deepcopy_method
|
||||
|
||||
field.type_obj = self.type_obj
|
||||
return field
|
||||
|
||||
def add_count(self, count):
|
||||
self.count = int(count)
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ msgdata,test_msg,test_sbt_varsize_var_assign,subtype_var_assign,
|
|||
msgdata,test_msg,test_sbt_var_len,subtype_var_len,
|
||||
msgdata,test_msg,test_sbt_varlen_varsize,subtype_varlen_varsize,
|
||||
msgdata,test_msg,test_sbt_arrays,subtype_arrays,
|
||||
# test extension fields
|
||||
msgdata,test_msg,extension_1,test_features,,option_short_id
|
||||
|
||||
msgtype,test_tlv1,2
|
||||
msgdata,test_tlv1,test_struct,test_short_id,
|
||||
|
|
Loading…
Add table
Reference in a new issue