From 235efc63e2c650620260ff4c0c250a308e5c063a Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Fri, 24 Sep 2021 23:31:25 +0200 Subject: [PATCH] Use `()` and `{}` instead of `list()` and `dict()` This fixes a 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> --- trojans/tncc-emulate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trojans/tncc-emulate.py b/trojans/tncc-emulate.py index 0c918a64..d80abe54 100755 --- a/trojans/tncc-emulate.py +++ b/trojans/tncc-emulate.py @@ -161,7 +161,7 @@ def decode_0ce7(buf, indent): # 0cf0 - encapsulation def decode_0cf0(buf, indent): logging.debug('%scmd 0cf0 (encapsulation) %d bytes', indent, len(buf)) - ret = dict() + ret = {} cmd, _, out = decode_packet(buf, indent + " ") ret[cmd] = out return ret @@ -274,7 +274,7 @@ class x509cert: @staticmethod def decode_names(names): - ret = dict() + ret = {} for name in names.chosen: for attr in name: type_dotted = attr['type'].dotted # dotted-quad value (e.g. '2.5.4.10' = organization) @@ -353,8 +353,8 @@ class tncc: self.cj.set_cookie(cookie) def parse_response(self): - # Read in key/token fields in HTTP response - response = dict() + # Read in key/token fields in HTTP responsedict + response = {} last_key = '' for line in self.r.readlines(): line = line.strip().decode() @@ -385,7 +385,7 @@ class tncc: if key.lower() == 'value': # It's made up of a bunch of key=value pairs separated # by semicolons - d = dict() + d = {} for field in value.split(';'): field = field.strip() try: -- 2.50.1