From a271852b1ba74ddbbf2b1c7cc509615ed8cd0664 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 21 Sep 2017 17:45:25 +0200 Subject: [bug] fix initialization of default parameter to mutable data structure whoever wrote this in the first place needs to get introduced to import-time initialization, even if it was me. one of the nastiest python gotchas in my opinion :) --- src/leap/bitmask/bonafide/_http.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/leap/bitmask/bonafide/_http.py b/src/leap/bitmask/bonafide/_http.py index d4a0112c..a1120ab7 100644 --- a/src/leap/bitmask/bonafide/_http.py +++ b/src/leap/bitmask/bonafide/_http.py @@ -53,14 +53,22 @@ class Unchanged(Exception): # TODO this should be ported to use treq client. -def httpRequest(agent, url, values={}, headers={}, method='POST', token=None, - saveto=None): +def httpRequest(agent, url, values=None, headers=None, + method='POST', token=None, saveto=None): + if values is None: + values = {} + if headers is None: + headers = {} + data = '' mtime = None if values: data = urllib.urlencode(values) headers['Content-Type'] = ['application/x-www-form-urlencoded'] - if saveto is not None and os.path.isfile(saveto): + + isfile = os.path.isfile + + if saveto is not None and isfile(saveto): # TODO - I think we need a force parameter, because we might have a # malformed file. Or maybe just remove the file if sanity check does # not pass. -- cgit v1.2.3