From eeb5fab01429f7b15aae10d6730fdf1d43719adb Mon Sep 17 00:00:00 2001 From: Kumar Anirudha Date: Sun, 4 Oct 2026 17:22:34 +0530 Subject: [PATCH 1/2] Expose termios baud rate constants and IBSHIFT on Linux When CPython is built against glibc 2.42 or newer, the termios module on Linux exposes B7200, B14400, B28800, B76800 (Python 3.13+) and IBSHIFT, but the stub only declared them on other platforms. - Declare the B* constants for Python 3.13+ on all non-Windows platforms - Declare IBSHIFT on all non-macOS platforms, including Linux - Allowlist them as optional for stubtest, since the GitHub Actions runners build against an older glibc that lacks the macros --- stdlib/@tests/stubtest_allowlists/linux.txt | 7 +++++++ stdlib/termios.pyi | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/linux.txt b/stdlib/@tests/stubtest_allowlists/linux.txt index 058563c14e50..e2b09917706f 100644 --- a/stdlib/@tests/stubtest_allowlists/linux.txt +++ b/stdlib/@tests/stubtest_allowlists/linux.txt @@ -137,5 +137,12 @@ _?socket.SOL_ROSE # not present on GitHub Actions runners. termios.TIOCTTYGSTRUCT +# Only defined when Python was built against glibc 2.42 or newer +(termios.B7200)? +(termios.B14400)? +(termios.B28800)? +(termios.B76800)? +(termios.IBSHIFT)? + tkinter.Tk.createfilehandler # Methods that come from __getattr__() at runtime tkinter.Tk.deletefilehandler # Methods that come from __getattr__() at runtime diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index 971c9ad46bf4..36285935998e 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -183,15 +183,15 @@ if sys.platform != "win32": VWERASE: Final[int] if sys.version_info >= (3, 13): + B14400: Final[int] + B28800: Final[int] + B7200: Final[int] + B76800: Final[int] EXTPROC: Final[int] IUTF8: Final[int] if sys.platform == "darwin" and sys.version_info >= (3, 13): ALTWERASE: Final[int] - B14400: Final[int] - B28800: Final[int] - B7200: Final[int] - B76800: Final[int] CCAR_OFLOW: Final[int] CCTS_OFLOW: Final[int] CDSR_OFLOW: Final[int] @@ -274,6 +274,7 @@ if sys.platform != "win32": B460800: Final[int] B500000: Final[int] B921600: Final[int] + IBSHIFT: Final[int] if sys.platform != "linux": TCSASOFT: Final[int] @@ -286,7 +287,6 @@ if sys.platform != "win32": CNUL: Final[int] COMMON: Final[int] CSWTCH: Final[int] - IBSHIFT: Final[int] INIT_C_CC: Final[int] NSWTCH: Final[int] From 5d29918905e9f817f3bb7f84b8d3379add89ad64 Mon Sep 17 00:00:00 2001 From: Kumar Anirudha Date: Mon, 5 Oct 2026 19:01:32 +0530 Subject: [PATCH 2/2] Add glibc 2.42 requirement for termios constants in the stub --- stdlib/termios.pyi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index 36285935998e..5d9c81ed5488 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -183,12 +183,14 @@ if sys.platform != "win32": VWERASE: Final[int] if sys.version_info >= (3, 13): + EXTPROC: Final[int] + IUTF8: Final[int] + + # On Linux, only available when Python was built against glibc 2.42 or newer. B14400: Final[int] B28800: Final[int] B7200: Final[int] B76800: Final[int] - EXTPROC: Final[int] - IUTF8: Final[int] if sys.platform == "darwin" and sys.version_info >= (3, 13): ALTWERASE: Final[int] @@ -274,6 +276,7 @@ if sys.platform != "win32": B460800: Final[int] B500000: Final[int] B921600: Final[int] + # On Linux, only available when Python was built against glibc 2.42 or newer. IBSHIFT: Final[int] if sys.platform != "linux":