lib.Uri: Fix stale cache in __new_with_path() #74

Merged
Jan Lindemann merged 1 commit from jan/fix/20260820-lib-uri-fix-stale-cache-in-new-with-path into master 2026-08-20 07:58:38 +02:00 AGit

View file

@ -1,7 +1,5 @@
from __future__ import annotations
import copy
from functools import cached_property
from typing import TYPE_CHECKING, override
@ -149,7 +147,10 @@ class Uri:
)
def __new_with_path(self, base: str, path: str) -> Self:
ret = copy.deepcopy(self)
# -- Build a fresh instance rather than copying self: a copy would
# inherit computed cached_property values (e.g. __p, path, full),
# which would go stale as soon as __string is replaced below.
ret = object.__new__(type(self))
ret.__string = base
ret.__username = None
ret.__password = None