Skip to content

Commit

Permalink
Fix setting the idna_encode_size
Browse files Browse the repository at this point in the history
There was a refactoring error in #1348 that set this to the decode size

Fix the bug and add coverage to ensure it does not break again.

This change never made it to a release
  • Loading branch information
bdraco committed Oct 21, 2024
1 parent fff1f15 commit 0fb61f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def test_cache_configure_explicit() -> None:
idna_encode_size=128,
encode_host_size=128,
)
assert yarl.cache_info()["idna_decode"].maxsize == 128
assert yarl.cache_info()["idna_encode"].maxsize == 128
assert yarl.cache_info()["encode_host"].maxsize == 128


def test_cache_configure_waring() -> None:
Expand Down
4 changes: 2 additions & 2 deletions yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ def cache_info() -> CacheInfo:
@rewrite_module
def cache_configure(
*,
idna_encode_size: Union[int, None, object] = _DEFAULT_IDNA_SIZE,
idna_encode_size: Union[int, None] = _DEFAULT_IDNA_SIZE,
idna_decode_size: Union[int, None] = _DEFAULT_IDNA_SIZE,
ip_address_size: Union[int, None, object] = _SENTINEL,
host_validate_size: Union[int, None, object] = _SENTINEL,
Expand Down Expand Up @@ -1796,4 +1796,4 @@ def cache_configure(

_encode_host = lru_cache(encode_host_size)(_encode_host.__wrapped__)
_idna_decode = lru_cache(idna_decode_size)(_idna_decode.__wrapped__)
_idna_encode = lru_cache(idna_decode_size)(_idna_encode.__wrapped__)
_idna_encode = lru_cache(idna_encode_size)(_idna_encode.__wrapped__)

0 comments on commit 0fb61f0

Please sign in to comment.