From 75f75f24754ec602f5f293e606ac560c6ba05cea Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 27 Oct 2020 08:44:25 -0700 Subject: [PATCH 1/2] adds assertion to check for deleted contexts --- coreir/context.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coreir/context.py b/coreir/context.py index 945bbbc..0feb943 100644 --- a/coreir/context.py +++ b/coreir/context.py @@ -48,6 +48,8 @@ def __getitem__(self, key): def namespace_cache(f): def method(self, name: str): + if self.context is None: + raise ValueError("Cannot use deleted context!") c_addr = ct.addressof(self.context) if name in _library_cache[c_addr]: return _library_cache[c_addr][name] @@ -263,6 +265,7 @@ def delete(self): None check for all the API code, instead we assume if this is used that the user is certain that the context object will no longer be used. """ + print("DELETING", self) if self.context is None: raise Exception("Context already deleted") c_addr = ct.addressof(self.context) From cf88486c54cffed092fb77fe024bb963cd78ce15 Mon Sep 17 00:00:00 2001 From: Ross Daly Date: Tue, 27 Oct 2020 09:49:22 -0700 Subject: [PATCH 2/2] Removes extraneous print --- coreir/context.py | 1 - 1 file changed, 1 deletion(-) diff --git a/coreir/context.py b/coreir/context.py index 0feb943..f8a556d 100644 --- a/coreir/context.py +++ b/coreir/context.py @@ -265,7 +265,6 @@ def delete(self): None check for all the API code, instead we assume if this is used that the user is certain that the context object will no longer be used. """ - print("DELETING", self) if self.context is None: raise Exception("Context already deleted") c_addr = ct.addressof(self.context)