Przeglądaj źródła

fix "TypeError: object of type 'vDDDLists' has no len()" in `_event_prop_equal`

Fabian Peter Hammerle 3 dni temu
rodzic
commit
c3fa4a6af2
3 zmienionych plików z 55 dodań i 2 usunięć
  1. 2 0
      CHANGELOG.md
  2. 4 2
      ical2vdir/__init__.py
  3. 49 0
      tests/event_test.py

+ 2 - 0
CHANGELOG.md

@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 
 ## [Unreleased]
 ## [Unreleased]
+### Fixed
+- `_event_prop_equal`: fix "TypeError: object of type 'vDDDLists' has no len()"
 
 
 ## [2.0.0] - 2026-01-14
 ## [2.0.0] - 2026-01-14
 ### Added
 ### Added

+ 4 - 2
ical2vdir/__init__.py

@@ -34,8 +34,10 @@ _VDIR_EVENT_FILE_EXTENSION = ".ics"
 
 
 def _event_prop_equal(prop_a: typing.Any, prop_b: typing.Any) -> bool:
 def _event_prop_equal(prop_a: typing.Any, prop_b: typing.Any) -> bool:
     if isinstance(prop_a, list):
     if isinstance(prop_a, list):
-        return len(prop_a) == len(prop_b) and all(
-            _event_prop_equal(*pair) for pair in zip(prop_a, prop_b)
+        return (
+            isinstance(prop_b, list)
+            and len(prop_a) == len(prop_b)
+            and all(_event_prop_equal(*pair) for pair in zip(prop_a, prop_b))
         )
         )
     if isinstance(prop_a, icalendar.prop.vDDDLists):
     if isinstance(prop_a, icalendar.prop.vDDDLists):
         # https://www.kanzaki.com/docs/ical/exdate.html
         # https://www.kanzaki.com/docs/ical/exdate.html

+ 49 - 0
tests/event_test.py

@@ -141,6 +141,55 @@ END:VEVENT
 """,
 """,
                 True,
                 True,
             ),
             ),
+            (
+                """BEGIN:VEVENT
+SUMMARY:exdate test unchanged
+DTSTART;TZID=Europe/Vienna:20260120T160000
+DTEND;TZID=Europe/Vienna:20260120T163000
+DTSTAMP:20260130T123456Z
+UID:c27cfee4-60a5-4bc4-9ab6-ef4fb3dce111
+RRULE:FREQ=WEEKLY;WKST=TU
+EXDATE;TZID=Europe/Vienna:20260120T160000
+EXDATE;TZID=Europe/Vienna:20260127T160000
+END:VEVENT
+""",
+                """BEGIN:VEVENT
+SUMMARY:exdate test unchanged
+DTSTART;TZID=Europe/Vienna:20260120T160000
+DTEND;TZID=Europe/Vienna:20260120T163000
+DTSTAMP:20260130T123457Z
+UID:c27cfee4-60a5-4bc4-9ab6-ef4fb3dce111
+RRULE:FREQ=WEEKLY;WKST=TU
+EXDATE;TZID=Europe/Vienna:20260120T160000
+EXDATE;TZID=Europe/Vienna:20260127T160000
+END:VEVENT
+""",
+                True,
+            ),
+            (
+                """BEGIN:VEVENT
+SUMMARY:exdate test changed
+DTSTART;TZID=Europe/Vienna:20260120T160000
+DTEND;TZID=Europe/Vienna:20260120T163000
+DTSTAMP:20260130T123456Z
+UID:c27cfee4-60a5-4bc4-9ab6-ef4fb3dce111
+RRULE:FREQ=WEEKLY;WKST=TU
+EXDATE;TZID=Europe/Vienna:20260120T160000
+EXDATE;TZID=Europe/Vienna:20260127T160000
+END:VEVENT
+""",
+                """BEGIN:VEVENT
+SUMMARY:exdate test changed
+DTSTART;TZID=Europe/Vienna:20260120T160000
+DTEND;TZID=Europe/Vienna:20260120T163000
+DTSTAMP:20260130T123456Z
+UID:c27cfee4-60a5-4bc4-9ab6-ef4fb3dce111
+RRULE:FREQ=WEEKLY;WKST=TU
+EXDATE;TZID=Europe/Vienna:20260120T160000
+END:VEVENT
+""",
+                False,
+            ),
         ]
         ]
     ),
     ),
 )
 )