Fix Python 3.11 compatibility in calendar .ics export

calendar_routes.py used a backslash inside an f-string expression, valid
only on Python 3.12+. Hoist the newline-escaping out of the f-string so
the app imports on Python 3.11, as the README states.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
yunggilja
2026-05-31 20:24:38 -05:00
parent 3d4b6b2c7b
commit 19ea04507d
+5 -1
View File
@@ -902,7 +902,11 @@ def setup_calendar_routes() -> APIRouter:
lines.append(f"DTSTART:{ev.dtstart.strftime('%Y%m%dT%H%M%S')}")
lines.append(f"DTEND:{ev.dtend.strftime('%Y%m%dT%H%M%S')}")
if ev.description:
lines.append(f"DESCRIPTION:{ev.description.replace(chr(10), '\\n')}")
# Escape newlines to the literal \n the iCalendar spec wants.
# Kept out of the f-string expression so this stays valid on
# Python 3.11 (backslashes in f-string expressions need 3.12+).
_desc = ev.description.replace(chr(10), "\\n")
lines.append(f"DESCRIPTION:{_desc}")
if ev.location:
lines.append(f"LOCATION:{ev.location}")
if ev.rrule: