From 8d3c9c766e1b492a7b2b486c5acd2680bdff3d8c Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Wed, 10 Aug 2022 20:02:23 +0100
Subject: [PATCH] update so None is overwritten in merge_dicts if the other
 value is non-None

---
 binarycpython/utils/dicts.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/binarycpython/utils/dicts.py b/binarycpython/utils/dicts.py
index a873117ea..eeb2a0591 100644
--- a/binarycpython/utils/dicts.py
+++ b/binarycpython/utils/dicts.py
@@ -510,6 +510,21 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict:
             ):
                 new_dict[key] = merge_dicts(dict_1[key], dict_2[key])
 
+            # one key is None, just use the other
+            elif dict_1[key] is None:
+                try:
+                    new_dict[key] = dict_2[key]
+                except:
+                    msg = f"{key}: Failed to set from {dict_2[key]} when other key was of NoneType "
+                    raise ValueError(msg) from e
+
+            elif dict_1[key] is None:
+                try:
+                    new_dict[key] = dict_1[key]
+                except:
+                    msg = f"{key}: Failed to set from {dict_1[key]} when other key was of NoneType "
+                    raise ValueError(msg) from e
+
             # string-int clash : convert both to ints and save
             elif (
                 isinstance(dict_1[key], str)
@@ -525,6 +540,7 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict:
                     )
                     raise ValueError(msg) from e
 
+
             # string-float clash : convert both to floats and save
             elif (
                 isinstance(dict_1[key], str)
-- 
GitLab