Skip to content

gh-135621: Remove dependency on curses from PyREPL #136758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 21, 2025
Prev Previous commit
Next Next commit
Parse the terminfo file header in one go
  • Loading branch information
ambv committed Jul 19, 2025
commit 7aa2ec88b0b7fc494c2599e21b7745e80c8e5f6e
18 changes: 6 additions & 12 deletions Lib/_pyrepl/terminfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,14 @@ def _parse_terminfo_file(self, terminal_name: str) -> None:
"""
data = _read_terminfo_file(terminal_name)
too_short = f"TermInfo file for {terminal_name!r} too short"
offset = 0
if len(data) < 12:
offset = 12
if len(data) < offset:
raise ValueError(too_short)

magic = struct.unpack("<H", data[offset : offset + 2])[0]
magic, name_size, bool_count, num_count, str_count, str_size = (
struct.unpack("<Hhhhhh", data[:offset])
)

if magic == MAGIC16:
number_format = "<h" # 16-bit signed
number_size = 2
Expand All @@ -370,15 +373,6 @@ def _parse_terminfo_file(self, terminal_name: str) -> None:
f"TermInfo file for {terminal_name!r} uses unknown magic"
)

# Parse header
name_size = struct.unpack("<h", data[2:4])[0]
bool_count = struct.unpack("<h", data[4:6])[0]
num_count = struct.unpack("<h", data[6:8])[0]
str_count = struct.unpack("<h", data[8:10])[0]
str_size = struct.unpack("<h", data[10:12])[0]

offset = 12

# Read terminal names
if offset + name_size > len(data):
raise ValueError(too_short)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy