Skip to content

Commit 432e336

Browse files
committed
fix: use AsyncHTTPDigestAuth instead of HTTPDigestAuth for niquests async client
When using niquests in async mode, digest auth must use AsyncHTTPDigestAuth. The sync HTTPDigestAuth.handle_401() calls r.connection.send() which returns a coroutine in async context, causing "AttributeError: 'coroutine' object has no attribute 'history'". Reported at jawah/niquests#387 (comment) prompt: Please check jawah/niquests#387 (comment), the last comment hints that the problem is in the caldav library AI Prompts: claude-sonnet-4-6: Please check jawah/niquests#387 (comment), the last comment hints that the problem is in the caldav library
1 parent cf606f3 commit 432e336

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

caldav/async_davclient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,9 @@ def build_auth_object(self, auth_types: list[str] | None = None) -> None:
835835
if _USE_HTTPX:
836836
self.auth = httpx.DigestAuth(self.username, self.password)
837837
else:
838-
from niquests.auth import HTTPDigestAuth
838+
from niquests.auth import AsyncHTTPDigestAuth
839839

840-
self.auth = HTTPDigestAuth(self.username, self.password)
840+
self.auth = AsyncHTTPDigestAuth(self.username, self.password)
841841
elif auth_type == "basic":
842842
if _USE_HTTPX:
843843
self.auth = httpx.BasicAuth(self.username, self.password)

docs/source/v3-migration.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ replace it with:
3838
from caldav import Event, Todo, Calendar # OK
3939
4040
All public symbols that were in ``caldav.objects`` should remain available directly
41-
from the ``caldav`` namespace
41+
from the ``caldav`` namespace. Exceptions may apply.
4242

4343
Wildcard import into caldav.* removed
4444
-------------------------------------
45-
Earlier a wildcard import ``from caldav.objects import *`` was done into the ``caldav`` namespace. This has been removed. In normal circumstances, your imports should continue to work - but there are no guarantees that all imports will continue working. If you have any issues, see :doc:`contact`.
45+
Earlier a wildcard import ``from caldav.objects import *`` was done into the ``caldav`` namespace. This has been removed. Imports should work, but corner cases may exists. If you have any issues, see :doc:`contact`.
4646

4747
Config-file parse errors now raise exceptions
4848
---------------------------------------------
@@ -308,9 +308,7 @@ context-manager "borrow" methods that give exclusive, safe write access.
308308
309309
While inside the ``with`` block, the borrowed representation is the
310310
single source of truth. Attempting to borrow a *different*
311-
representation raises ``RuntimeError``. This means the current
312-
pattern is not completely thread-safe as of v3.x - but an explicit
313-
error is often better than updates silently being dropped.
311+
representation raises ``RuntimeError``.
314312

315313
**The data representation remains the same:**
316314

examples/basic_usage_examples.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ def find_delete_calendar_demo(my_principal, calendar_name):
113113
def add_stuff_to_calendar_demo(calendar):
114114
"""
115115
This demo adds some stuff to the calendar
116-
117-
Unfortunately the arguments that it's possible to pass to save_* is poorly documented.
118-
https://github.com/python-caldav/caldav/issues/253
119116
"""
120117
## Add an event with some certain attributes
121118
print("Saving an event")

0 commit comments

Comments
 (0)