[3.15] gh-154874: Fix the sign of curses.termattrs() (GH-154875) - #155548
Open
sankalpsthakur wants to merge 1 commit into
Open
[3.15] gh-154874: Fix the sign of curses.termattrs() (GH-154875)#155548sankalpsthakur wants to merge 1 commit into
sankalpsthakur wants to merge 1 commit into
Conversation
This was referenced Aug 11, 2026
…154875) termattrs() returns a chtype mask, but it was routed through an int, so a terminal that advertises A_ITALIC came back negative and the result could no longer be passed to the attribute functions. (cherry picked from commit 0b083c4) Co-authored-by: Vyron Vasileiadis <hi@fedonman.com> Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
sankalpsthakur
force-pushed
the
fix/154874-termattrs-backport-3.15
branch
from
August 11, 2026 09:47
e5cf968 to
225795a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of GH-154875 to 3.15.
curses.termattrs()returns achtypemask, but it was routed through anintto check forERR. On a terminal that advertisesA_ITALIC(topmost bit of a 32-bit mask), the result came back negative and the attribute functions rejected it:This returns the mask unsigned via
PyLong_FromUnsignedLong, matchinggetattrs(),slk_attr(), andterm_attrs().The main-branch regression test uses
newterm()over a pseudo-terminal (NewtermTestBase), which is not present on 3.15. The 3.15 test is adapted ontoTestCursesand skips when the current terminal does not advertise a top-bit attribute.(cherry picked from commit 0b083c4)
Fixes #154874
Test plan
test_curses(requires curses resource)Modules/_cursesmodule.cand includes NEWS + adapted unit test.AI/LLM disclosure
Made with Cursor