aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/misc/cfg.py
diff options
context:
space:
mode:
authorJ08nY2023-02-05 16:25:43 +0100
committerJ08nY2023-02-05 16:25:43 +0100
commita796a68e02521a1db2ee309c021671a904fe14df (patch)
tree927edd15b15a04cb9e582b05d718e8943d6f757d /pyecsca/misc/cfg.py
parent0f5c105c8e34b8443c0da168d7f05f6cd9a03a59 (diff)
downloadpyecsca-a796a68e02521a1db2ee309c021671a904fe14df.tar.gz
pyecsca-a796a68e02521a1db2ee309c021671a904fe14df.tar.zst
pyecsca-a796a68e02521a1db2ee309c021671a904fe14df.zip
Diffstat (limited to 'pyecsca/misc/cfg.py')
-rw-r--r--pyecsca/misc/cfg.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pyecsca/misc/cfg.py b/pyecsca/misc/cfg.py
index 24b83f8..54579d9 100644
--- a/pyecsca/misc/cfg.py
+++ b/pyecsca/misc/cfg.py
@@ -5,6 +5,7 @@ This includes how errors are handled, or which :py:class:`~pyecsca.ec.mod.Mod` i
"""
from copy import deepcopy
from contextvars import ContextVar, Token
+from typing import Optional
from public import public
@@ -178,6 +179,7 @@ class TemporaryConfig:
cfg.some_property = some_value
...
"""
+ token: Optional[Token]
def __init__(self):
self.token = None
@@ -188,4 +190,5 @@ class TemporaryConfig:
return self.new_config
def __exit__(self, t, v, tb):
- resetconfig(self.token)
+ if self.token:
+ resetconfig(self.token)