diff options
Diffstat (limited to 'contrib/python/wcwidth')
| -rw-r--r-- | contrib/python/wcwidth/py3/.dist-info/METADATA | 6 | ||||
| -rw-r--r-- | contrib/python/wcwidth/py3/tests/test_core.py | 6 | ||||
| -rw-r--r-- | contrib/python/wcwidth/py3/tests/test_term_overrides.py | 7 | ||||
| -rw-r--r-- | contrib/python/wcwidth/py3/wcwidth/__init__.py | 2 | ||||
| -rw-r--r-- | contrib/python/wcwidth/py3/wcwidth/_wcswidth.py | 4 | ||||
| -rw-r--r-- | contrib/python/wcwidth/py3/ya.make | 2 |
6 files changed, 22 insertions, 5 deletions
diff --git a/contrib/python/wcwidth/py3/.dist-info/METADATA b/contrib/python/wcwidth/py3/.dist-info/METADATA index ca4ef720666..e51569ea2b7 100644 --- a/contrib/python/wcwidth/py3/.dist-info/METADATA +++ b/contrib/python/wcwidth/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: wcwidth -Version: 0.8.1 +Version: 0.8.2 Summary: Measures the displayed width of unicode strings in a terminal Project-URL: Homepage, https://github.com/jquast/wcwidth Author-email: Jeff Quast <[email protected]> @@ -685,6 +685,10 @@ languages: History ======= +0.8.2 *2026-06-29* + * **Bugfix** Do not raise IndexError when given legacy POSIX ``n`` argument to `wcswidth()`_ or + `wcstwidth()`_ exceed string length without raising IndexError + 0.8.1 *2026-06-08* * **Improved** `wcstwidth()`_ with new ``zeroer``, ``narrow_wider``, and ``narrow_zeroer`` Corrections_. `PR #226`_ diff --git a/contrib/python/wcwidth/py3/tests/test_core.py b/contrib/python/wcwidth/py3/tests/test_core.py index 882b2eafc32..9d5007571b1 100644 --- a/contrib/python/wcwidth/py3/tests/test_core.py +++ b/contrib/python/wcwidth/py3/tests/test_core.py @@ -497,6 +497,12 @@ def test_zwj_at_end_of_string(): assert wcwidth.wcswidth('a\u200D') == 1 +def test_wcswidth_n_exceeds_length(): + """Verify wcswidth() with n > len(string) does not raise IndexError.""" + assert wcwidth.wcswidth('hello', n=999) == 5 + assert wcwidth.wcswidth('\u30B3\u30F3', n=999) == 4 + + def test_soft_hyphen(): # Test SOFT HYPHEN, category 'Cf' usually are zero-width, but most # implementations agree to draw it was '1' cell, visually diff --git a/contrib/python/wcwidth/py3/tests/test_term_overrides.py b/contrib/python/wcwidth/py3/tests/test_term_overrides.py index 75f88052ab6..0a7162ef800 100644 --- a/contrib/python/wcwidth/py3/tests/test_term_overrides.py +++ b/contrib/python/wcwidth/py3/tests/test_term_overrides.py @@ -418,6 +418,13 @@ def test_get_term_overrides_narrow_wider_still_empty(): assert overrides.narrow_wider == () [email protected]('func', [wcwidth.wcstwidth, wcwidth.width]) +def test_narrow_wider_width(func): + """Verify width() & wcstwidth() match result of narrow_wider overrides.""" + assert wcwidth.wcswidth('\u261d') == 1 + assert func('\u261d', term_program='kitty') == 2 + + @pytest.mark.parametrize('codepoint', [ '\u00ad', '\u0600', diff --git a/contrib/python/wcwidth/py3/wcwidth/__init__.py b/contrib/python/wcwidth/py3/wcwidth/__init__.py index 2e619eb0603..366911bd2d0 100644 --- a/contrib/python/wcwidth/py3/wcwidth/__init__.py +++ b/contrib/python/wcwidth/py3/wcwidth/__init__.py @@ -78,4 +78,4 @@ __all__ = ('wcwidth', 'wcswidth', 'wcstwidth', 'width', 'iter_sequences', 'iter_ # Using 'hatchling', it does not seem to provide the pyproject.toml nicety, "dynamic = ['version']" # like flit_core, maybe there is some better way but for now we have to duplicate it in both places # Prefer the installed distribution version when available (helps test environments) -__version__ = '0.8.1' # don't forget to also update pyproject.toml:version +__version__ = '0.8.2' # don't forget to also update pyproject.toml:version diff --git a/contrib/python/wcwidth/py3/wcwidth/_wcswidth.py b/contrib/python/wcwidth/py3/wcwidth/_wcswidth.py index 4b473fa76dc..32488d5bcbf 100644 --- a/contrib/python/wcwidth/py3/wcwidth/_wcswidth.py +++ b/contrib/python/wcwidth/py3/wcwidth/_wcswidth.py @@ -98,7 +98,7 @@ def wcswidth( _wcwidth = wcwidth if ambiguous_width == 1 else lambda c: wcwidth(c, 'auto', ambiguous_width) - end = len(pwcs) if n is None else n + end = len(pwcs) if n is None else min(n, len(pwcs)) total_width = 0 idx = 0 @@ -262,7 +262,7 @@ def wcstwidth( # Select wcwidth call pattern for best lru_cache performance _wcwidth = wcwidth if ambiguous_width == 1 else lambda c: wcwidth(c, 'auto', ambiguous_width) - end = len(pwcs) if n is None else n + end = len(pwcs) if n is None else min(n, len(pwcs)) total_width = 0 idx = 0 diff --git a/contrib/python/wcwidth/py3/ya.make b/contrib/python/wcwidth/py3/ya.make index f05dd459817..4eb46696608 100644 --- a/contrib/python/wcwidth/py3/ya.make +++ b/contrib/python/wcwidth/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(0.8.1) +VERSION(0.8.2) LICENSE(MIT) |
