|
1 | 1 | import functools |
2 | 2 | import inspect |
3 | 3 | import os |
| 4 | +import platform |
4 | 5 | import select |
5 | 6 | import string |
6 | 7 | import sys |
@@ -86,6 +87,18 @@ def wrapped(self, *args, **kwargs): |
86 | 87 | BROKEN_NEWTERM = _ncurses_version is not None and _ncurses_version < (6, 5) |
87 | 88 | USE_NEWTERM = hasattr(curses, 'newterm') and not BROKEN_NEWTERM |
88 | 89 |
|
| 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 | + |
89 | 102 | # newterm() is used when available (it reports errors instead of exiting), but |
90 | 103 | # initscr() is still the fallback, and an unusable $TERM has no terminal to |
91 | 104 | # drive either way. |
@@ -411,7 +424,8 @@ def test_addch_emoji(self): |
411 | 424 | stdscr = self.stdscr |
412 | 425 | if self._encodable('\U0001f600'): |
413 | 426 | 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'): |
415 | 429 | stdscr.addch(1, 0, '\u263a\ufe0f') # WHITE SMILING FACE + VS-16 |
416 | 430 | # An emoji ZWJ sequence or an emoji with a modifier is more than one |
417 | 431 | # spacing character and cannot share a single cell. |
|
0 commit comments