From c4917318c476d5436f39f62614fcfe675c3e0161 Mon Sep 17 00:00:00 2001 From: Chris Levy Date: Tue, 1 Aug 2017 08:56:39 +0100 Subject: [PATCH] Replacing del with pop() Replacing del with pop() to allow deletion of keys which do not exist --- mongo_connector/doc_managers/doc_manager_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mongo_connector/doc_managers/doc_manager_base.py b/mongo_connector/doc_managers/doc_manager_base.py index 2320b8f9..b7076008 100644 --- a/mongo_connector/doc_managers/doc_manager_base.py +++ b/mongo_connector/doc_managers/doc_manager_base.py @@ -84,9 +84,9 @@ def _unset_field(doc, to_unset): where[index_or_key] = None else: # Unset field removes it entirely. - del where[index_or_key] + where.pop(index_or_key, None) else: - del doc[to_unset] + doc.pop(to_unset, None) except (KeyError, IndexError, ValueError): source_version = get_mininum_mongodb_version() if source_version is None or source_version.at_least(2, 6):