From 1ff4966314d82c9880fd2efd2e241b274a7f5d07 Mon Sep 17 00:00:00 2001 From: Jake Fennick Date: Mon, 20 May 2024 13:22:35 -1000 Subject: [PATCH 1/2] Do not deepcopy the cache! Signed-off-by: Jake Fennick --- src/prov/model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/prov/model.py b/src/prov/model.py index 186ac43..709a196 100644 --- a/src/prov/model.py +++ b/src/prov/model.py @@ -1178,6 +1178,7 @@ def valid_qualified_name(self, qname): new_qname = existing_ns[local_part] else: # Do not reuse the namespace object + namespace._cache = dict() # Do not deepcopy the cache! ns = self.add_namespace(deepcopy(namespace)) # minting the same Qualified Name from the namespace's copy new_qname = ns[qname.localpart] From 050ee3b7c8ec192f5b9efd8a9a4da3c5db399b9d Mon Sep 17 00:00:00 2001 From: Jake Fennick Date: Mon, 27 May 2024 14:00:50 -1000 Subject: [PATCH 2/2] make a copy of Namespace manually (rather than using deepcopy) --- src/prov/model.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/prov/model.py b/src/prov/model.py index 709a196..5df3b60 100644 --- a/src/prov/model.py +++ b/src/prov/model.py @@ -7,7 +7,6 @@ PROV-JSON: https://openprovenance.org/prov-json/ """ from collections import defaultdict -from copy import deepcopy import datetime import io import itertools @@ -1177,9 +1176,8 @@ def valid_qualified_name(self, qname): # reuse the existing namespace new_qname = existing_ns[local_part] else: - # Do not reuse the namespace object - namespace._cache = dict() # Do not deepcopy the cache! - ns = self.add_namespace(deepcopy(namespace)) + # Do not reuse the namespace object, making an identical copy + ns = self.add_namespace(Namespace(namespace.prefix, namespace.uri)) # minting the same Qualified Name from the namespace's copy new_qname = ns[qname.localpart] # returning the new qname