Skip to content

Commit 5c97b6b

Browse files
committed
Use curses for capability discovery on 3.13
1 parent 7ac58e5 commit 5c97b6b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,14 +1428,17 @@ def test_no_newline(self):
14281428
# Build patterns for escape sequences that don't affect cursor position
14291429
# or visual output. Use terminfo to get platform-specific sequences,
14301430
# falling back to hard-coded patterns for capabilities not in terminfo.
1431-
from _pyrepl.terminfo import TermInfo
1432-
ti = TermInfo(os.environ.get("TERM", ""))
1431+
try:
1432+
from _pyrepl import curses
1433+
except ImportError:
1434+
self.skipTest("curses required for capability discovery")
14331435

1436+
curses.setupterm(os.environ.get("TERM", ""), 1)
14341437
safe_patterns = []
14351438

14361439
# smkx/rmkx - application cursor keys and keypad mode
1437-
smkx = ti.get("smkx")
1438-
rmkx = ti.get("rmkx")
1440+
smkx = curses.tigetstr("smkx")
1441+
rmkx = curses.tigetstr("rmkx")
14391442
if smkx:
14401443
safe_patterns.append(re.escape(smkx.decode("ascii")))
14411444
if rmkx:
@@ -1445,15 +1448,15 @@ def test_no_newline(self):
14451448
safe_patterns.append(r'\x1b[=>]') # application keypad mode
14461449

14471450
# ich1 - insert character (only safe form that inserts exactly 1 char)
1448-
ich1 = ti.get("ich1")
1451+
ich1 = curses.tigetstr("ich1")
14491452
if ich1:
14501453
safe_patterns.append(re.escape(ich1.decode("ascii")) + r'(?=[ -~])')
14511454
else:
14521455
safe_patterns.append(r'\x1b\[(?:1)?@(?=[ -~])')
14531456

14541457
# civis/cnorm - cursor visibility (may include cursor blinking control)
1455-
civis = ti.get("civis")
1456-
cnorm = ti.get("cnorm")
1458+
civis = curses.tigetstr("civis")
1459+
cnorm = curses.tigetstr("cnorm")
14571460
if civis:
14581461
safe_patterns.append(re.escape(civis.decode("ascii")))
14591462
if cnorm:

0 commit comments

Comments
 (0)