From 44cb7934dbe73aaa098cbc6f191d133eeedc6157 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Thu, 12 Jun 2025 08:32:23 +0200 Subject: [PATCH] stages/systemd: don't validate keys In Python 3.14 configparser started validating keys. We use hacky bits to write duplicate keys which means we have delimiters in our keys which is now no longer allowed. Let's explicitly turn off key validation for now as suggested by mhroncok in [1]. [1]: https://github.com/osbuild/osbuild/issues/2109#issuecomment-2964585958 Signed-off-by: Simon de Vlieger --- stages/org.osbuild.systemd.unit.create | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stages/org.osbuild.systemd.unit.create b/stages/org.osbuild.systemd.unit.create index 74f6e295..f80dec52 100755 --- a/stages/org.osbuild.systemd.unit.create +++ b/stages/org.osbuild.systemd.unit.create @@ -34,6 +34,13 @@ def main(tree, options): # prevent conversion of the option name to lowercase config.optionxform = lambda option: option + # In Python 3.14 configparser validates key contents and doesn't allow delimiters in them. Due to the hack several + # lines above we explicitly use some interesting behavior to write duplicate keys by including the delimiter in them. + # We need to disable the key validation check. Thanks to mrhoncok [1] for this workaround. In time we should probably + # revisit how we write unit files because configparser isn't the best for this. + # [1]: https://github.com/osbuild/osbuild/issues/2109#issuecomment-2964585958 + config._validate_key_contents = lambda key: None # pylint: disable=protected-access + for section, opts in cfg.items(): if not config.has_section(section): config.add_section(section)