]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix DeepSource alert
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Fri, 24 Sep 2021 17:36:22 +0000 (19:36 +0200)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Fri, 24 Sep 2021 17:52:36 +0000 (19:52 +0200)
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>
trojans/tncc-emulate.py

index b6f2093d8bc1c4096dcf971370ceaba25d1652b2..fea29deb34ab525514cd5a5b9df320cc497432a7 100755 (executable)
@@ -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: