Skip to content

Commit 7d43173

Browse files
committed
Bugfix - search could give objects of wrong classes
1 parent 379ed8b commit 7d43173

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ This project should adhere to [Semantic Versioning](https://semver.org/spec/v2.0
1616

1717
## [Unreleased]
1818

19-
The niquests dependency has proven controversial. See https://github.com/python-caldav/caldav/issues/457 https://github.com/python-caldav/caldav/issues/530 https://github.com/jawah/niquests/issues/267 for details. While continuing work on the 2.x-series I've decided to always release two versions of caldav, one based on requests and the next one based on niquests - giving package maintainers and other parties the option to choose between niquests (which resolves some of the issues reported to the caldav library) and requests (which is mature and firmly established in the python community, although fading to irrelevance unless 3.0 is shipped soon). Master branch will use niquests, as it's more forward-leaning. I will make a new decision on this before starting work on 3.0.
19+
### Fixes
20+
21+
* A search without filtering on comp-type on a calendar containing a mix of events, journals and tasks should return a mix of such. (All the examples in the RFC includes the comp-type filter, so many servers does not support this). There were a bug in the auto-detection of comp-type, so tasks would typically be wrapped as events or vice-versa. https://github.com/python-caldav/caldav/pull/540
22+
23+
### Other
24+
25+
* Example code: Basic usage examples have been brushed up, thanks to David Greaves - https://github.com/python-caldav/caldav/pull/534
26+
* PEP 639 conforming license expression in the pyproject.toml, thanks to Marc Mueller - https://github.com/python-caldav/caldav/pull/538
2027

2128
## [2.0.1] - [2025-06-24]
2229

caldav/collection.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,13 +730,12 @@ def _request_report_build_resultlist(
730730
pdata = results[r]
731731
if cdav.CalendarData.tag in pdata:
732732
cdata = pdata.pop(cdav.CalendarData.tag)
733-
if comp_class is None:
734-
comp_class = self._calendar_comp_class_by_data(cdata)
733+
comp_class_ = self._calendar_comp_class_by_data(cdata) if comp_class is None else comp_class
735734
else:
736735
cdata = None
737-
if comp_class is None:
736+
if comp_class_ is None:
738737
## no CalendarData fetched - which is normal i.e. when doing a sync-token report and only asking for the URLs
739-
comp_class = CalendarObjectResource
738+
comp_class_ = CalendarObjectResource
740739
url = URL(r)
741740
if url.hostname is None:
742741
# Quote when result is not a full URL
@@ -745,7 +744,7 @@ def _request_report_build_resultlist(
745744
if self.url.join(url) == self.url:
746745
continue
747746
matches.append(
748-
comp_class(
747+
comp_class_(
749748
self.client,
750749
url=self.url.join(url),
751750
data=cdata,

tests/test_caldav.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,7 @@ def testSearchWithoutCompType(self):
24902490
cal.save_event(ev1)
24912491
objects = cal.search()
24922492
assert len(objects) == 2
2493-
assert set([str(type(x)) for x in objects]) == {"Todo", "Event"}
2493+
assert set([type(x).__name__ for x in objects]) == {"Todo", "Event"}
24942494

24952495
def testTodoCompletion(self):
24962496
"""

0 commit comments

Comments
 (0)