From c8ba44c07d1d6bed032f2b01b80d3a41b2b225ee Mon Sep 17 00:00:00 2001 From: cecilia Date: Tue, 18 Aug 2026 11:44:37 +0000 Subject: [PATCH] fix: extract backslash replace out of f-string for Python <3.12 compatibility The f-string expression contained a backslash escape, raising 'SyntaxError: f-string expression part cannot include a backslash' on Python 3.10/3.11, which contradicts the README's Python 3.11+ requirement. Hoist the replace() call out of the f-string to restore compatibility. --- echobot/app/services/web_console/live2d/catalog.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/echobot/app/services/web_console/live2d/catalog.py b/echobot/app/services/web_console/live2d/catalog.py index 9105b94..609c7bf 100644 --- a/echobot/app/services/web_console/live2d/catalog.py +++ b/echobot/app/services/web_console/live2d/catalog.py @@ -124,9 +124,12 @@ def selection_key_for(self, candidate: Live2DModelCandidate) -> str: return f"{candidate.source}:{candidate.model_relative_path.as_posix()}" def asset_url_for(self, candidate: Live2DModelCandidate, relative_path: str) -> str: + # 注意:此处 replace('\\', '/') 不能直接写在 f-string 的表达式内, + # 因为 Python < 3.12 不允许 f-string 表达式部分含有反斜杠(PEP 701) + normalized = str(relative_path or "").replace("\\", "/") return ( f"/api/web/live2d/{candidate.source}/" - f"{quote(str(relative_path or '').replace('\\', '/'), safe='/')}" + f"{quote(normalized, safe='/')}" ) def directory_name_for(self, candidate: Live2DModelCandidate) -> str: