Skip to content

Commit f3fd9dc

Browse files
gh-151757: Skip curses variation-selector test on older macOS (GH-153344)
Older macOS reports a variation selector as a spacing character (wcwidth() returns 1) instead of a zero-width combining mark, so curses cannot put it in the same cell as its base. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d6855c8 commit f3fd9dc

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Lib/test/test_curses.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import inspect
33
import os
4+
import platform
45
import select
56
import string
67
import sys
@@ -86,6 +87,18 @@ def wrapped(self, *args, **kwargs):
8687
BROKEN_NEWTERM = _ncurses_version is not None and _ncurses_version < (6, 5)
8788
USE_NEWTERM = hasattr(curses, 'newterm') and not BROKEN_NEWTERM
8889

90+
# Older macOS reports a variation selector as a spacing character (wcwidth()
91+
# == 1) rather than a combining mark, so it cannot share a cell with its base.
92+
# The failure is confirmed on 14.2 and gone by 26, so skip below 26.
93+
def _broken_variation_selector_width():
94+
if sys.platform == 'darwin':
95+
mac_ver = platform.mac_ver()[0]
96+
if mac_ver:
97+
return tuple(map(int, mac_ver.split('.'))) < (26,)
98+
return False
99+
100+
BROKEN_VARIATION_SELECTOR_WIDTH = _broken_variation_selector_width()
101+
89102
# newterm() is used when available (it reports errors instead of exiting), but
90103
# initscr() is still the fallback, and an unusable $TERM has no terminal to
91104
# drive either way.
@@ -411,7 +424,8 @@ def test_addch_emoji(self):
411424
stdscr = self.stdscr
412425
if self._encodable('\U0001f600'):
413426
stdscr.addch(0, 0, '\U0001f600') # single emoji
414-
if self._encodable('\u263a\ufe0f'):
427+
# Skip the variation selector where the platform reports it as spacing.
428+
if not BROKEN_VARIATION_SELECTOR_WIDTH and self._encodable('\u263a\ufe0f'):
415429
stdscr.addch(1, 0, '\u263a\ufe0f') # WHITE SMILING FACE + VS-16
416430
# An emoji ZWJ sequence or an emoji with a modifier is more than one
417431
# spacing character and cannot share a single cell.

0 commit comments

Comments
 (0)