[tor-commits] [ooni-probe/master] Use a non mutable default argument (as noted by @darkk)

art at torproject.org art at torproject.org
Fri Oct 14 19:00:56 UTC 2016


commit 84c710704d49492f23998bfaa88c34f5fb6ec75d
Author: Arturo Filastò <arturo at 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',





More information about the tor-commits mailing list