mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +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:
committed by
Rusty Russell
parent
009e9dc945
commit
cfd56d86ee
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user