From 87375530e1a0f7a50a50ac57797d1da9a60f9e58 Mon Sep 17 00:00:00 2001 From: Reguna <60984878+regunakyle@users.noreply.github.com> Date: Sat, 1 Jun 2024 15:56:42 +0800 Subject: [PATCH] Remove trailing comma from hooks.json and fix SyntaxWarning in Python 3.12 --- hooks | 5 +++-- hooks.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hooks b/hooks index b81dd3e..9425ed0 100755 --- a/hooks +++ b/hooks @@ -41,7 +41,7 @@ IPTABLES_BINARY = os.getenv('IPTABLES_BINARY') or subprocess.check_output([ # Allow comments in json, copied from https://github.com/getify/JSON.minify def json_minify(string, strip_space=True): - tokenizer = re.compile('"|(/\*)|(\*/)|(//)|\n|\r') + tokenizer = re.compile(r'"|(/\*)|(\*/)|(//)|\n|\r') end_slashes_re = re.compile(r'(\\)*$') in_string = False @@ -64,11 +64,12 @@ def json_minify(string, strip_space=True): # the correct column numbers on parsing errors. new_str.append(' ' * (match.start() - index)) + last_index = index index = match.end() val = match.group() if val == '"' and not (in_multi or in_single): - escaped = end_slashes_re.search(string, 0, match.start()) + escaped = end_slashes_re.search(string, last_index, match.start()) # start of string or unescaped quote character to end string if not in_string or (escaped is None or len(escaped.group()) % 2 == 0): # noqa diff --git a/hooks.json b/hooks.json index 4805405..41d5f50 100644 --- a/hooks.json +++ b/hooks.json @@ -56,5 +56,5 @@ "protocol": "udp" } ] - }, + } }