From 1ce0925b6108e3dc77855a0e6767db988bb2c36d Mon Sep 17 00:00:00 2001 From: dupondje Date: Tue, 12 Mar 2024 11:14:43 +0100 Subject: [PATCH] Copy head_parsers list on construct. (#150) We need to create a copy of the head_parsers. Otherwise the self.value_formats contains just a reference to head_parsers. But the self.value_formats is modified in the _parse_values, causing invalid values in the head_parsers list. --- dsmr_parser/parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsmr_parser/parsers.py b/dsmr_parser/parsers.py index 61515fc..d49d2bd 100644 --- a/dsmr_parser/parsers.py +++ b/dsmr_parser/parsers.py @@ -335,7 +335,7 @@ class ProfileGenericParser(DSMRObjectParser): """ def __init__(self, buffer_types, head_parsers, parsers_for_unidentified): - self.value_formats = head_parsers + self.value_formats = head_parsers.copy() self.buffer_types = buffer_types self.parsers_for_unidentified = parsers_for_unidentified