lib.Uri: Fix stale cache in __new_with_path() #74
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/fix/20260820-lib-uri-fix-stale-cache-in-new-with-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
lib.Uri: Fix stale cache in __new_with_path()
__new_with_path() builds the new Uri by deep-copying self and then replacing __string. A deep copy, however, also carries over any cached_property values that were already computed on self (e.g. __p, path, scheme, full), so once __string changes, they stay stale: for a Uri on which any of those properties had been accessed before, new_add_path() and new_replace_path() returned objects whose to_string() showed the new string while path(), hostname(), full() and friends still described the old one.
Build a fresh instance with object.new() and initialize its three basic attributes instead of copying, so no computed cached state can be inherited.