From 8618708fd1468fbd171be65f2333902fba8986b3 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 30 Jun 2023 12:39:36 +0530 Subject: [PATCH] Try closing the config file explicitly, to avoid null byte errors --- ui/easydiffusion/app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/easydiffusion/app.py b/ui/easydiffusion/app.py index 8350ce8d..5b12ff81 100644 --- a/ui/easydiffusion/app.py +++ b/ui/easydiffusion/app.py @@ -158,8 +158,12 @@ def setConfig(config): config = commented_config yaml.indent(mapping=2, sequence=4, offset=2) - with open(config_yaml_path, "w", encoding="utf-8") as f: + + try: + f = open(config_yaml_path, "w", encoding="utf-8") yaml.dump(config, f) + finally: + f.close() # do this explicitly to avoid NUL bytes (rare bug when using 'with') except: log.error(traceback.format_exc())