commit 84c710704d49492f23998bfaa88c34f5fb6ec75d Author: Arturo Filastò arturo@filasto.net Date: Fri Oct 14 12:57:48 2016 +0200
Use a non mutable default argument (as noted by @darkk)
* Log some warning if we notice that annotations is not a dictionary and clear it --- ooni/nettest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ooni/nettest.py b/ooni/nettest.py index b81678b..150858c 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -169,10 +169,12 @@ class NetTestLoader(object): requiresTor = False
def __init__(self, options, test_file=None, test_string=None, - annotations={}): + annotations=None): self.options = options - # Ensure annotations are always dicts + if annotations is None: + annotations = {} if not isinstance(annotations, dict): + log.warn("BUG: Annotations is not a dictionary. Resetting it.") annotations = {} self.annotations = annotations self.annotations['platform'] = self.annotations.get('platform',