From: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Fri, 24 Sep 2021 17:36:22 +0000 (+0200) Subject: Fix DeepSource alert X-Git-Tag: v8.20~61^2~6 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b0223f3d283ba4511e467686d734167342d57fde;p=users%2Fdwmw2%2Fopenconnect.git Fix DeepSource alert Consider using literal syntax to create the data structure Using the literal syntax can give minor performance bumps compared to using function calls to create `dict`, `list` and `tuple`. This is because here, the name `dict` must be looked up in the global scope in case it has been rebound. Same goes for the other two types `list()` and `tuple()`. Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> --- diff --git a/trojans/tncc-emulate.py b/trojans/tncc-emulate.py index b6f2093d..fea29deb 100755 --- a/trojans/tncc-emulate.py +++ b/trojans/tncc-emulate.py @@ -395,9 +395,9 @@ class tncc(object): def parse_funk_response(self, msg_data): e = xml.etree.ElementTree.fromstring(msg_data) - req_certs = dict() + req_certs = {} for cert in e.find('AttributeRequest').findall('CertData'): - dns = dict() + dns = {} cert_id = cert.attrib['Id'] for attr in cert.findall('Attribute'): name = attr.attrib['Name'] @@ -552,7 +552,7 @@ class tncc(object): # Pull the data out of the 'value' key in the htmlish stuff returned policy_objs = [] - req_certs = dict() + req_certs = {} for str_id, sub_str in sub_strings: if str_id == MSG_POLICY: policy_objs += self.parse_policy_response(sub_str.decode()) @@ -568,7 +568,7 @@ class tncc(object): logging.debug('\t%s %s', key, val) # Try to locate the required certificates - certs = dict() + certs = {} for cert_id, req_dns in req_certs.items(): for cert in self.avail_certs: fail = False @@ -624,7 +624,7 @@ class tncc_server(object): sys.exit(0) cmd, buf = buf.split('\n', 1) cmd = cmd.strip() - args = dict() + args = {} for n in buf.split('\n'): n = n.strip() if n: