Fix qbt-config-patch for Python 3.14: use lambda in re.sub replacements

Python 3.14 raises PatternError for backslash sequences like \P in
re.sub replacement strings. Switch to lambda replacements which bypass
that interpretation. Also pin to python:3.13-alpine to avoid future
surprises from pulling :3-alpine.
This commit is contained in:
Will Anderson
2026-04-14 20:00:24 -05:00
parent 07f75c7dc8
commit b5f481d9a4
+6 -6
View File
@@ -35,7 +35,7 @@ spec:
securityContext: securityContext:
privileged: true privileged: true
- name: qbt-config-patch - name: qbt-config-patch
image: python:3-alpine image: python:3.13-alpine
command: command:
- python3 - python3
- -c - -c
@@ -51,10 +51,10 @@ spec:
"""Set key=value under [section], inserting if missing.""" """Set key=value under [section], inserting if missing."""
key_pat = re.compile(r'^' + re.escape(key) + r'=.*', re.M) key_pat = re.compile(r'^' + re.escape(key) + r'=.*', re.M)
if key_pat.search(text): if key_pat.search(text):
return key_pat.sub(key + '=' + value, text) return key_pat.sub(lambda m: key + '=' + value, text)
sec_pat = re.compile(r'^\[' + re.escape(section) + r'\]', re.M) sec_pat = re.compile(r'^\[' + re.escape(section) + r'\]', re.M)
if sec_pat.search(text): if sec_pat.search(text):
return sec_pat.sub('[' + section + ']\n' + key + '=' + value, text) return sec_pat.sub(lambda m: '[' + section + ']\n' + key + '=' + value, text)
return text + f'\n[{section}]\n{key}={value}\n' return text + f'\n[{section}]\n{key}={value}\n'
HASH = '@ByteArray(HqYj1eGsdXlQ4CSy597Y9A==:J9hsJIlU5FYfHb5rY5qQoIpVpTijryS/H+CE07oMtplL/ytneBVFd2tfVJtqGjhdht8tEi4wmqSSlqTgEu444w==)' HASH = '@ByteArray(HqYj1eGsdXlQ4CSy597Y9A==:J9hsJIlU5FYfHb5rY5qQoIpVpTijryS/H+CE07oMtplL/ytneBVFd2tfVJtqGjhdht8tEi4wmqSSlqTgEu444w==)'
@@ -241,7 +241,7 @@ spec:
securityContext: securityContext:
privileged: true privileged: true
- name: qbt-config-patch - name: qbt-config-patch
image: python:3-alpine image: python:3.13-alpine
command: command:
- python3 - python3
- -c - -c
@@ -257,10 +257,10 @@ spec:
"""Set key=value under [section], inserting if missing.""" """Set key=value under [section], inserting if missing."""
key_pat = re.compile(r'^' + re.escape(key) + r'=.*', re.M) key_pat = re.compile(r'^' + re.escape(key) + r'=.*', re.M)
if key_pat.search(text): if key_pat.search(text):
return key_pat.sub(key + '=' + value, text) return key_pat.sub(lambda m: key + '=' + value, text)
sec_pat = re.compile(r'^\[' + re.escape(section) + r'\]', re.M) sec_pat = re.compile(r'^\[' + re.escape(section) + r'\]', re.M)
if sec_pat.search(text): if sec_pat.search(text):
return sec_pat.sub('[' + section + ']\n' + key + '=' + value, text) return sec_pat.sub(lambda m: '[' + section + ']\n' + key + '=' + value, text)
return text + f'\n[{section}]\n{key}={value}\n' return text + f'\n[{section}]\n{key}={value}\n'
HASH = '@ByteArray(HqYj1eGsdXlQ4CSy597Y9A==:J9hsJIlU5FYfHb5rY5qQoIpVpTijryS/H+CE07oMtplL/ytneBVFd2tfVJtqGjhdht8tEi4wmqSSlqTgEu444w==)' HASH = '@ByteArray(HqYj1eGsdXlQ4CSy597Y9A==:J9hsJIlU5FYfHb5rY5qQoIpVpTijryS/H+CE07oMtplL/ytneBVFd2tfVJtqGjhdht8tEi4wmqSSlqTgEu444w==)'