Fix: expand REPORT leaves recurrence properties on expanded instances

_strip_single_event() removed the recurrence-defining properties (RRULE,
EXDATE, EXRULE, RDATE) with a single try/except around sequential
delattr() calls. When one of them was absent (e.g. an event with no
EXDATE), the AttributeError aborted the whole block and the following
properties -- notably RDATE -- were left on the expanded
single-occurrence VEVENTs returned by a calendar-data expand REPORT.

Remove each property independently so a missing one no longer prevents
removal of the others. Add a regression test and fixture.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TowyTowy
2026-07-12 22:30:47 +02:00
parent ffb90de841
commit 9d46d5b63d
4 changed files with 53 additions and 7 deletions

View File

@@ -638,13 +638,15 @@ def _strip_single_event(
_convert_to_utc(vevent, 'dtend', dt_format)
_convert_to_utc(vevent, 'recurrence_id', dt_format)
try:
delattr(vevent, 'rrule')
delattr(vevent, 'exdate')
delattr(vevent, 'exrule')
delattr(vevent, 'rdate')
except AttributeError:
pass
# Remove every recurrence-defining property independently: a single
# try/except around the sequential delattr() calls stopped at the first
# property that was absent, leaving the following ones (e.g. RDATE) on the
# expanded single-occurrence instance.
for prop in ('rrule', 'exdate', 'exrule', 'rdate'):
try:
delattr(vevent, prop)
except AttributeError:
pass
def _strip_component(vevent: vobject.base.Component) -> None: